summaryrefslogtreecommitdiffstats
path: root/source/libsmb/namequery.c
diff options
context:
space:
mode:
authorChristopher R. Hertel <crh@samba.org>2000-07-12 04:25:12 +0000
committerChristopher R. Hertel <crh@samba.org>2000-07-12 04:25:12 +0000
commitd8656304d51844335e72babe852673f2dececfdc (patch)
tree4c224612d7bf324c23cac7e3bf1d3bc9b4634fb1 /source/libsmb/namequery.c
parent6ee63ecfa5f9c984f51c15597a50e085ab722e87 (diff)
downloadsamba-d8656304d51844335e72babe852673f2dececfdc.tar.gz
samba-d8656304d51844335e72babe852673f2dececfdc.tar.xz
samba-d8656304d51844335e72babe852673f2dececfdc.zip
An improved version of the Negative Query Response fix. The earlier fix
only did a short-cut on an rcode of 3, which is 'name not found'. This does a short-cut on any non-zero rcode. It also puts out a DEBUG message (if DEBUGLEVEL is >= 3) detailing the error. Chris -)-----
Diffstat (limited to 'source/libsmb/namequery.c')
-rw-r--r--source/libsmb/namequery.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index 82c8c8f93df..193731768f4 100644
--- a/source/libsmb/namequery.c
+++ b/source/libsmb/namequery.c
@@ -272,16 +272,42 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
struct nmb_packet *nmb2 = &p2->packet.nmb;
debug_nmb_packet(p2);
+ /* If we get a Negative Name Query Response from a WINS
+ * server, we should report it and give up.
+ */
if( 0 == nmb2->header.opcode /* A query response */
&& !(bcast) /* from a WINS server */
- && 0x03 == nmb2->header.rcode /* Name doesn't exist */
+ && nmb2->header.rcode /* Error returned */
) {
- /* If we get a Negative Name Query Response from a WINS
- * server, we should give up.
- */
- free_packet(p2);
- return( NULL );
+
+ if( DEBUGLVL( 3 ) ) {
+ /* Only executed if DEBUGLEVEL >= 3 */
+ dbgtext( "Negative name query response, rcode 0x%02x: ",
+ nmb2->header.rcode );
+ switch( nmb2->header.rcode ) {
+ case 0x01:
+ dbgtext( "Request was invalidly formatted.\n" );
+ break;
+ case 0x02:
+ dbgtext( "Problem with NBNS, cannot process name.\n");
+ break;
+ case 0x03:
+ dbgtext( "The name requested does not exist.\n" );
+ break;
+ case 0x04:
+ dbgtext( "Unsupported request error.\n" );
+ break;
+ case 0x05:
+ dbgtext( "Refused error.\n" );
+ break;
+ default:
+ dbgtext( "Unrecognized error code.\n" );
+ break;
+ }
}
+ free_packet(p2);
+ return( NULL );
+ }
if (nmb2->header.opcode != 0 ||
nmb2->header.nm_flags.bcast ||
@@ -295,17 +321,18 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
continue;
}
- ip_list = (struct in_addr *)Realloc(ip_list, sizeof(ip_list[0]) *
- ((*count)+nmb2->answers->rdlength/6));
+ ip_list = (struct in_addr *)Realloc( ip_list,
+ sizeof( ip_list[0] )
+ * ( (*count) + nmb2->answers->rdlength/6 ) );
if (ip_list) {
DEBUG(2,("Got a positive name query response from %s ( ",
inet_ntoa(p2->ip)));
for (i=0;i<nmb2->answers->rdlength/6;i++) {
putip((char *)&ip_list[(*count)],&nmb2->answers->rdata[2+i*6]);
- DEBUG(2,("%s ",inet_ntoa(ip_list[(*count)])));
+ DEBUGADD(2,("%s ",inet_ntoa(ip_list[(*count)])));
(*count)++;
}
- DEBUG(2,(")\n"));
+ DEBUGADD(2,(")\n"));
}
found=True;