From 119f965f494d881c69704a346443aeb4bfcbe3ef Mon Sep 17 00:00:00 2001 From: "Christopher R. Hertel" Date: Sun, 9 Jul 2000 02:10:24 +0000 Subject: Quick change to short-circuit WINS queries if the WINS server returns a Negative Name Query Response. We should't wait through the timeouts and retry twice if we've been told "No Such Entry". (This used to be commit 2bbd16903db02aacb729d1ad140056b180e2a776) --- source3/libsmb/namequery.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 8fb607bd8f..82c8c8f93d 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -271,7 +271,18 @@ struct in_addr *name_query(int fd,const char *name,int name_type, if ((p2=receive_nmb_packet(fd,90,nmb->header.name_trn_id))) { struct nmb_packet *nmb2 = &p2->packet.nmb; debug_nmb_packet(p2); - + + if( 0 == nmb2->header.opcode /* A query response */ + && !(bcast) /* from a WINS server */ + && 0x03 == nmb2->header.rcode /* Name doesn't exist */ + ) { + /* If we get a Negative Name Query Response from a WINS + * server, we should give up. + */ + free_packet(p2); + return( NULL ); + } + if (nmb2->header.opcode != 0 || nmb2->header.nm_flags.bcast || nmb2->header.rcode || @@ -499,13 +510,16 @@ static BOOL resolve_wins(const char *name, int name_type, wins_ip = *interpret_addr2(lp_wins_server()); wins_ismyip = ismyip(wins_ip); + DEBUG(3, ("resolve_wins: WINS server == <%s>\n", inet_ntoa(wins_ip)) ); if((wins_ismyip && !global_in_nmbd) || !wins_ismyip) { - sock = open_socket_in( SOCK_DGRAM, 0, 3, - interpret_addr(lp_socket_address()), True ); - + sock = open_socket_in( SOCK_DGRAM, 0, 3, + interpret_addr(lp_socket_address()), + True ); if (sock != -1) { - *return_iplist = name_query(sock, name, name_type, False, - True, wins_ip, return_count); + *return_iplist = name_query( sock, name, + name_type, False, + True, wins_ip, + return_count); if(*return_iplist != NULL) { close(sock); return True; -- cgit