Quick change to short-circuit WINS queries if the WINS server returns a
authorChristopher R. Hertel <crh@samba.org>
Sun, 9 Jul 2000 02:10:24 +0000 (02:10 +0000)
committerChristopher R. Hertel <crh@samba.org>
Sun, 9 Jul 2000 02:10:24 +0000 (02:10 +0000)
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

index 8fb607bd8fcffe08401271538cb976d9eddc7c1d..82c8c8f93df8724a499b59554b95adc49eec1db2 100644 (file)
@@ -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;