nameannounce.c: Made sure recurse flag set correctly.
authorSamba Release Account <samba-bugs@samba.org>
Mon, 2 Jun 1997 19:51:56 +0000 (19:51 +0000)
committerSamba Release Account <samba-bugs@samba.org>
Mon, 2 Jun 1997 19:51:56 +0000 (19:51 +0000)
namedbname.c: Made sure wins.dat updated when list changes.
Changed to returning 255.255.255.255 when 1e name
queried.
namepacket.c: Made sure recurse flags set correctly.
nameserv.c: Made sure recurse flags set correctly.
nameservreply.c: Made send_name_response() static, Made sure recurse flags set correctly.
Changed to returning 255.255.255.255 when 1e name
                        queried.
proto.h: Removed send_name_response().
Jeremy jallison@whistle.com
(This used to be commit 4e9fd24f65971bbbda5f76499e5d14f90eef8038)

source3/include/proto.h
source3/nameannounce.c
source3/namedbname.c
source3/namepacket.c
source3/nameserv.c
source3/nameservreply.c

index e6d39c3a3faf66c30d1b2a583f76b4e817396fe7..2b30b7174ea0101701ebdd73cfad2ce82dfae393 100644 (file)
@@ -496,10 +496,6 @@ void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
                                struct nmb_name *name,
                                int nb_flags, int ttl, struct in_addr register_ip,
                                BOOL new_owner, struct in_addr reply_to_ip);
-void send_name_response(int fd, struct in_addr from_ip,
-                               int name_trn_id, int opcode, BOOL success, BOOL recurse,
-                               struct nmb_name *reply_name, int nb_flags, int ttl,
-                               struct in_addr ip);
 void reply_name_release(struct packet_struct *p);
 void reply_name_reg(struct packet_struct *p);
 void reply_name_status(struct packet_struct *p);
index b1d13ce7ac89bfbf9c727995164570d74b4b6a9e..899fcd7e3b572c1240f17446c4e8ee17a2111d1d 100644 (file)
@@ -234,7 +234,7 @@ void announce_server(struct subnet_record *d, struct work_record *work,
                                         NAME_QUERY_ANNOUNCE_HOST,
                                         work->work_group,0x1b,0,ttl*1000,
                                         server_type,name,comment,
-                                        False, False, ipzero, d->bcast_ip);
+                                        False, True, ipzero, d->bcast_ip);
                        }
                        else
                        {
@@ -472,7 +472,7 @@ workgroup %s\n", am_master, work->work_group));
                     NMB_QUERY,NAME_QUERY_DOM_SRV_CHK,
                     name, type, 0,0,0,
                     work->work_group,NULL,
-                    False, False, ipzero, ipzero);
+                    False, True, ipzero, ipzero);
         }
       else if(lp_wins_support()) 
         {
index 7d91b6e04516565288f2bc1e3ce5536eb6956817..06e23b0a7878f2193ab787b9b0e7e360775986e0 100644 (file)
@@ -36,6 +36,7 @@ extern int DEBUGLEVEL;
 extern pstring scope;
 extern struct in_addr ipzero;
 extern struct in_addr wins_ip;
+extern BOOL updatedlists;
 
 extern struct subnet_record *subnetlist;
 
@@ -111,6 +112,9 @@ static void add_name(struct subnet_record *d, struct name_record *n)
   n2->next = n;
   n->next = NULL;
   n->prev = n2;
+
+  if(d == wins_subnet)
+    updatedlists = True;
 }
 
 
@@ -133,6 +137,9 @@ void remove_name(struct subnet_record *d, struct name_record *n)
     if (nlist->prev) nlist->prev->next = nlist->next;
     free(nlist);
   }
+
+  if(d == wins_subnet)
+    updatedlists = True;
 }
 
 
@@ -460,12 +467,6 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
     }
   }
 
-  if(type == 0x1e)      
-  {  
-    /* Add all 1e names as address 255.255.255.255 */  
-    ip = *interpret_addr2("255.255.255.255");  
-  }  
-
   n = (struct name_record *)malloc(sizeof(*n));
   if (!n) return(NULL);
 
index 418155bbd85b1fa19baa70093f432c3a1e39becc..55b525d6c5076c7f4b1f9ce0baf87a541e1a14c3 100644 (file)
@@ -194,7 +194,6 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
   struct nmb_packet *nmb = &p.packet.nmb;
   struct res_rec answers;
   char *packet_type = "unknown";
-  BOOL recursion_desired = False;
   
   p = *p1;
 
@@ -203,31 +202,26 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
     case NMB_STATUS:
        {
       packet_type = "nmb_status";
-      recursion_desired = True;
       break;
     }
     case NMB_QUERY:
        {
       packet_type = "nmb_query";
-      recursion_desired = True;
       break;
     }
     case NMB_REG:
        {
       packet_type = "nmb_reg";
-      recursion_desired = True;
       break;
     }
     case NMB_REL:
        {
       packet_type = "nmb_rel";
-      recursion_desired = False;
       break;
     }
     case NMB_WAIT_ACK:
        {
       packet_type = "nmb_wack";
-      recursion_desired = False;
       break;
     }
     default:
@@ -246,8 +240,8 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
   nmb->header.opcode = opcode;
   nmb->header.response = True;
   nmb->header.nm_flags.bcast = False;
-  nmb->header.nm_flags.recursion_available = recurse;
-  nmb->header.nm_flags.recursion_desired = recursion_desired;
+  nmb->header.nm_flags.recursion_available = (lp_wins_support() ? True : False );
+  nmb->header.nm_flags.recursion_desired = (lp_wins_support() ? recurse : False );
   nmb->header.nm_flags.trunc = False;
   nmb->header.nm_flags.authoritative = True;
   
index aba7ddadb60eecaadb63bff5814bb88e582b3132..f1b34482c85dd8fe178a82e4e5b3fe7480a5424a 100644 (file)
@@ -115,7 +115,7 @@ void remove_name_entry(struct subnet_record *d, char *name,int type, BOOL direct
       /* local interface: release them on the network */
       queue_netbios_packet(d,ClientNMB,NMB_REL,NAME_RELEASE,
                         name, type, 0, 0,0,NULL,NULL,
-                        True, True, d->bcast_ip, d->bcast_ip);
+                        True, False, d->bcast_ip, d->bcast_ip);
   }
 }
 
@@ -191,7 +191,7 @@ void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags,
       queue_netbios_packet(d,ClientNMB,
         re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER,
          name, type, nb_flags, GET_TTL(0),0,NULL,NULL,
-        True, True, d->bcast_ip, ipzero);
+        True, False, d->bcast_ip, ipzero);
     }
   }
 }
@@ -273,7 +273,7 @@ on workgroup %s\n", myworkgroup));
             queue_netbios_pkt_wins(ClientNMB,NMB_QUERY,NAME_QUERY_DOMAIN,
                                myworkgroup, 0x1b,
                                0, 0,0,NULL,NULL,
-                               False, False, ipzero, ipzero);
+                               False, True, ipzero, ipzero);
           }
         }
         else
index 9f7b3da70ba7cf8a9425f974907773398ad1f7bd..db517dff82590cfd0bf99d3a79ad0cb16430ef98 100644 (file)
@@ -38,30 +38,10 @@ extern int DEBUGLEVEL;
 
 extern struct in_addr wins_ip;
 
-
-/****************************************************************************
-  add a netbios entry. respond to the (possibly new) owner.
-  **************************************************************************/
-void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
-                               uint16 response_id,
-                               struct nmb_name *name,
-                               int nb_flags, int ttl, struct in_addr register_ip,
-                               BOOL new_owner, struct in_addr reply_to_ip)
-{
-       /* register the old or the new owners' ip */
-       add_netbios_entry(d,name->name,name->name_type,
-                                               nb_flags,ttl,REGISTER,register_ip,False,True);
-
-       /* reply yes or no to the host that requested the name */
-       send_name_response(fd,from_ip, response_id, NMB_REG,
-                               new_owner, True,
-                               name, nb_flags, ttl, reply_to_ip);
-}
-
 /****************************************************************************
 send a registration / release response: pos/neg
 **************************************************************************/
-void send_name_response(int fd, struct in_addr from_ip,
+static void send_name_response(int fd, struct in_addr from_ip,
                                int name_trn_id, int opcode, BOOL success, BOOL recurse,
                                struct nmb_name *reply_name, int nb_flags, int ttl,
                                struct in_addr ip)
@@ -99,6 +79,25 @@ void send_name_response(int fd, struct in_addr from_ip,
                       rdata, 6);
 }
 
+/****************************************************************************
+  add a netbios entry. respond to the (possibly new) owner.
+  **************************************************************************/
+void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
+                               uint16 response_id,
+                               struct nmb_name *name,
+                               int nb_flags, int ttl, struct in_addr register_ip,
+                               BOOL new_owner, struct in_addr reply_to_ip)
+{
+  /* register the old or the new owners' ip */
+  add_netbios_entry(d,name->name,name->name_type,
+                    nb_flags,ttl,REGISTER,register_ip,False,True);
+
+  /* reply yes or no to the host that requested the name */
+  send_name_response(fd,from_ip, response_id, NMB_REG,
+                     new_owner, False,
+                     name, nb_flags, ttl, reply_to_ip);
+}
+
 
 /****************************************************************************
 reply to a name release
@@ -150,7 +149,7 @@ void reply_name_release(struct packet_struct *p)
   
   /* Send a NAME RELEASE RESPONSE (pos/neg) see rfc1002.txt 4.2.10-11 */
   send_name_response(p->fd,p->ip, nmb->header.name_trn_id, NMB_REL,
-                    success, False,
+                    success, nmb->header.nm_flags.recursion_desired,
                     &nmb->question.question_name, nb_flags, 0, ip);
 }
 
@@ -193,7 +192,7 @@ void reply_name_reg(struct packet_struct *p)
     {
       /* apparently we should return 255.255.255.255 for group queries
         (email from MS) */
-      ip = wins_ip;
+      ip = *interpret_addr2("255.255.255.255");
     }
   
   if (!(d = find_req_subnet(p->ip, bcast)))
@@ -298,10 +297,10 @@ void reply_name_reg(struct packet_struct *p)
 
     /* initiate some enquiries to the current owner. */
        queue_netbios_packet(d,ClientNMB,NMB_QUERY,
-                                                NAME_REGISTER_CHALLENGE,
-                                                reply_name->name,reply_name->name_type,
-                            nb_flags,0,0,NULL,NULL,
-                                                False, False, n->ip_flgs[0].ip, p->ip);
+                        NAME_REGISTER_CHALLENGE,
+                        reply_name->name,reply_name->name_type,
+                        nb_flags,0,0,NULL,NULL,
+                        False, False, n->ip_flgs[0].ip, p->ip);
   }
   else
   {
@@ -310,8 +309,8 @@ void reply_name_reg(struct packet_struct *p)
      */
 
        send_name_response(p->fd,p->ip, nmb->header.name_trn_id, NMB_REG,
-                                               success, True,
-                                               reply_name, nb_flags, ttl, ip);
+                       success, nmb->header.nm_flags.recursion_desired,
+                       reply_name, nb_flags, ttl, ip);
   }
 }
 
@@ -540,7 +539,7 @@ void reply_name_query(struct packet_struct *p)
     success = False;
   }
 
-  if (!bcast && name_type == 0x1d)
+  if (!bcast && (name_type == 0x1d) && lp_wins_support())
   {
     /* see WINS manager HELP - 'How WINS Handles Special Names' */
     /* a WINS query (unicasted) for a 0x1d name must always return False */
@@ -585,8 +584,8 @@ void reply_name_query(struct packet_struct *p)
         {
              /* never reply with a negative response to broadcast queries */
              return;
-           }
-         }
+        }
+      }
       
       /* name is directed query, or it's self, or it's a Domain Master type
          name, or we're replying on behalf of a caller because they are on a
@@ -608,6 +607,13 @@ void reply_name_query(struct packet_struct *p)
   /* if the IP is 0 then substitute my IP */
   if (zero_ip(retip)) retip = *iface_ip(p->ip);
 
+  /* SPECIAL CASE... If we are a WINS server and the request is explicitly
+     *to* the WINS server and the name type is WORKGROUP<0x1e> we should 
+     respond with the local broadcast address 255.255.255.255.
+   */
+  if(!bcast && (name_type == 0x1e) && lp_wins_support())
+    retip = *interpret_addr2("255.255.255.255");
+
   if (success)
   {
       rcode = 0;