minor patch to allow host announcements to remote subnets
authorAndrew Tridgell <tridge@samba.org>
Mon, 10 Jun 1996 06:08:50 +0000 (06:08 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 10 Jun 1996 06:08:50 +0000 (06:08 +0000)
source/nameannounce.c
source/namedb.c
source/nameelect.c

index bb09a5d433d82455fee681097bdeb6eab97cf774..9b0ef7067f2d2140c9bdb3b3fcf2fd9050c1418b 100644 (file)
@@ -201,9 +201,6 @@ void announce_host(void)
     {
       struct work_record *work;
       
-      if (!d->my_interface)
-       continue;
-
       for (work = d->workgrouplist; work; work = work->next)
        {
          uint32 stype = work->ServerType;
@@ -228,6 +225,9 @@ void announce_host(void)
          
          work->lastannounce_time = t;
 
+         /* when announcing to remote networks we make sure we don't
+             claim to be any sort of special server, otherwise we may
+             stuff up their browsing */
          if (!d->my_interface) {
            stype &= ~(SV_TYPE_POTENTIAL_BROWSER | SV_TYPE_MASTER_BROWSER |
                       SV_TYPE_DOMAIN_MASTER | SV_TYPE_BACKUP_BROWSER |
@@ -263,62 +263,58 @@ void announce_host(void)
              p = p+31;
              p = skip_string(p,1);
              
-             if (d->my_interface)
+             if (d->my_interface && AM_MASTER(work))
                {
-                 if (AM_MASTER(work))
-                   {
-                     SIVAL(stypep,0,work->ServerType);
-                     
-                     DEBUG(2,("sending local master announce to %s for %s\n",
-                              inet_ntoa(d->bcast_ip),work->work_group));
-
-                     CVAL(outbuf,0) = ANN_LocalMasterAnnouncement;
-                     
-                     send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
-                                         PTR_DIFF(p,outbuf),
-                                         my_name,work->work_group,0,
-                                         0x1e,d->bcast_ip,
-                                         *iface_ip(d->bcast_ip));
-                     
-                     DEBUG(2,("sending domain announce to %s for %s\n",
-                              inet_ntoa(d->bcast_ip),work->work_group));
-
-                     CVAL(outbuf,0) = ANN_DomainAnnouncement;
-                     
-                     StrnCpy(namep,work->work_group,15);
-                     strupper(namep);
-                     StrnCpy(commentp,myname,15);
-                     strupper(commentp);
-                     
-                     SIVAL(stypep,0,(unsigned)0x80000000);
-                     p = commentp + strlen(commentp) + 1;
-                     
-                     send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
-                                         PTR_DIFF(p,outbuf),
-                                         my_name,MSBROWSE,0,0x01,d->bcast_ip,
-                                         *iface_ip(d->bcast_ip));
-                   }
-                 else
-                   {
-                     DEBUG(2,("sending host announce to %s for %s\n",
-                              inet_ntoa(d->bcast_ip),work->work_group));
-
-                     CVAL(outbuf,0) = ANN_HostAnnouncement;
-                     
-                     send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
-                                         PTR_DIFF(p,outbuf),
-                                         my_name,work->work_group,0,0x1d,
-                                         d->bcast_ip,*iface_ip(d->bcast_ip));
-                   }
+                 SIVAL(stypep,0,work->ServerType);
+                 
+                 DEBUG(2,("sending local master announce to %s for %s\n",
+                          inet_ntoa(d->bcast_ip),work->work_group));
+                 
+                 CVAL(outbuf,0) = ANN_LocalMasterAnnouncement;
+                 
+                 send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
+                                     PTR_DIFF(p,outbuf),
+                                     my_name,work->work_group,0,
+                                     0x1e,d->bcast_ip,
+                                     *iface_ip(d->bcast_ip));
+                 
+                 DEBUG(2,("sending domain announce to %s for %s\n",
+                          inet_ntoa(d->bcast_ip),work->work_group));
+                 
+                 CVAL(outbuf,0) = ANN_DomainAnnouncement;
+                 
+                 StrnCpy(namep,work->work_group,15);
+                 strupper(namep);
+                 StrnCpy(commentp,myname,15);
+                 strupper(commentp);
+                 
+                 SIVAL(stypep,0,(unsigned)0x80000000);
+                 p = commentp + strlen(commentp) + 1;
+                 
+                 send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
+                                     PTR_DIFF(p,outbuf),
+                                     my_name,MSBROWSE,0,0x01,d->bcast_ip,
+                                     *iface_ip(d->bcast_ip));
+               }
+             else
+               {
+                 DEBUG(2,("sending host announce to %s for %s\n",
+                          inet_ntoa(d->bcast_ip),work->work_group));
+                 
+                 CVAL(outbuf,0) = ANN_HostAnnouncement;
+                 
+                 send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
+                                     PTR_DIFF(p,outbuf),
+                                     my_name,work->work_group,0,0x1d,
+                                     d->bcast_ip,*iface_ip(d->bcast_ip));
                }
            }
          
-         if (work->needannounce)
-           {
-             work->needannounce = False;
-             break;
-             /* sorry: can't do too many announces. do some more later */
-           }
+         if (work->needannounce) {
+           work->needannounce = False;
+           break;
+           /* sorry: can't do too many announces. do some more later */
+         }
        }
     }
 }
index 11eea6976d7ba4a3e920bd5791dc219c09d4a027..ea5b13a80094c9c81d77fc6364a6c9abad3c3331 100644 (file)
@@ -339,6 +339,8 @@ struct work_record *find_workgroupstruct(struct subnet_record *d,
   
   if ((work = make_workgroup(name)))
     {
+      work->needelection = False;
+
       if (lp_preferred_master() &&
          strequal(lp_workgroup(), name) &&
          d->my_interface)
@@ -347,10 +349,6 @@ struct work_record *find_workgroupstruct(struct subnet_record *d,
          work->needelection = True;
          work->ElectionCriterion |= (1<<3);
        }
-      if (!d->my_interface)
-       {
-         work->needelection = False;
-       }
       add_workgroup(work, d);
       return(work);
     }
index 4479f660c9f030dc111af2e0ae82ee3ff5034e93..1832240a1168308b6d8aa509be931839d31c5b2a 100644 (file)
@@ -355,6 +355,10 @@ BOOL check_elections(void)
   for (d = subnetlist; d; d = d->next)
     {
       struct work_record *work;
+      
+      /* we only want to run elections on our own interfaces */
+      if (!d->my_interface) continue;
+
       for (work = d->workgrouplist; work; work = work->next)
        {
          run_any_election |= work->RunningElection;