RIP BOOL. Convert BOOL -> bool. I found a few interesting
[samba.git] / source3 / nmbd / nmbd_mynames.c
index 2e93eb5ef31f9ebfbfee78142749ccbfd8671711..2eb376fc179ed7d0975b7578d131b9f3026ecc5f 100644 (file)
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
 */
 
@@ -111,10 +110,11 @@ static void insert_refresh_name_into_unicast( struct subnet_record *subrec,
   Also add the magic Samba names.
 **************************************************************************/
 
-BOOL register_my_workgroup_and_names(void)
+bool register_my_workgroup_and_names(void)
 {
        struct subnet_record *subrec;
        int i;
+       const char **cluster_addresses = NULL;
 
        for(subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) {
                register_my_workgroup_one_subnet(subrec);
@@ -145,6 +145,35 @@ BOOL register_my_workgroup_and_names(void)
                }
        }
 
+       /*
+        * add in any cluster addresses. We need to response to these,
+        * but not listen on them. This allows us to run nmbd on every
+        * node in the cluster, and have all of them register with a
+        * WINS server correctly
+        */
+       if (lp_clustering()) {
+               cluster_addresses = lp_cluster_addresses();
+       }
+       if (cluster_addresses) {
+               int a, n;
+               unsigned name_types[] = {0x20, 0x3, 0x0};
+               
+               for (i=0; my_netbios_names(i); i++) {
+                       for(subrec = FIRST_SUBNET; subrec; subrec = subrec->next) {
+                               for (n=0;n<ARRAY_SIZE(name_types);n++) {
+                                       struct name_record *namerec;
+                                       struct nmb_name nmbname;                        
+                                       make_nmb_name(&nmbname, my_netbios_names(i), name_types[n]);
+                                       namerec = find_name_on_subnet(unicast_subnet, &nmbname, FIND_SELF_NAME);
+                                       if (namerec == NULL) continue;
+                                       for (a=0;cluster_addresses[a];a++) {
+                                               add_ip_to_name_record(namerec, *interpret_addr2(cluster_addresses[a]));
+                                       }
+                               }
+                       }
+               }
+       }
+
        /*
         * Add the WORKGROUP<0> and WORKGROUP<1e> group names to the unicast subnet
         * also for the same reasons.