From 20b5dea237916902437ce3dcdb7c253fd1ad3585 Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Wed, 9 Apr 1997 01:19:25 +0000 Subject: Large changes from jra@cygnus.com. Mainly browser updates. access.c: Fixed crash if yp domain unavailable. includes.h: Moved ifdefs for minor platform. interface.c: Changed name of ipgrp to wins_ip to make it clearer. loadparm.c: Changed default of wins support to 'no'. nameannounce.c: Many changes to fix cross subnet browsing. namebrowse.c: Many changes to fix cross subnet browsing. namedbname.c: Many changes to fix cross subnet browsing. namedbresp.c: Many changes to fix cross subnet browsing. namedbsubnet.c: Many changes to fix cross subnet browsing. namedbwork.c: Many changes to fix cross subnet browsing. nameelect.c: Many changes to fix cross subnet browsing. namelogon.c: Many changes to fix cross subnet browsing. namepacket.c: Many changes to fix cross subnet browsing. nameresp.c: Many changes to fix cross subnet browsing. nameserv.c: Many changes to fix cross subnet browsing. nameserv.h: Many changes to fix cross subnet browsing. nameservreply.c: Many changes to fix cross subnet browsing. nameservresp.c: Many changes to fix cross subnet browsing. namework.c: Many changes to fix cross subnet browsing. nmbd.c: Change to search wins subnet. nmbsync.c: Change to check if we are any master before proceeding. proto.h: Added find_subnet_all() and check_work_servertype(). util.c: Moved 'done' settings on name resolution. (This used to be commit a82476eee2c521e5eed092bc367da0a7cef23de1) --- source3/namedbsubnet.c | 76 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 30 deletions(-) (limited to 'source3/namedbsubnet.c') diff --git a/source3/namedbsubnet.c b/source3/namedbsubnet.c index 367179b6c6..144729e1e1 100644 --- a/source3/namedbsubnet.c +++ b/source3/namedbsubnet.c @@ -36,7 +36,7 @@ extern int ClientDGRAM; extern int DEBUGLEVEL; -extern struct in_addr ipgrp; +extern struct in_addr wins_ip; extern struct in_addr ipzero; extern pstring myname; @@ -52,6 +52,11 @@ struct subnet_record *subnetlist = NULL; extern uint16 nb_type; /* samba's NetBIOS name type */ +/* Forward references. */ +static struct subnet_record *add_subnet_entry(struct in_addr bcast_ip, + struct in_addr mask_ip, + char *name, BOOL add, BOOL lmhosts); + /**************************************************************************** add a domain into the list **************************************************************************/ @@ -81,31 +86,30 @@ static void add_subnet(struct subnet_record *d) struct subnet_record *find_subnet(struct in_addr bcast_ip) { struct subnet_record *d; - struct in_addr wins_ip = ipgrp; /* search through subnet list for broadcast/netmask that matches the source ip address. a subnet 255.255.255.255 represents the WINS list. */ - for (d = subnetlist; d; d = d->next) + for (d = subnetlist; d; d = d->next) { - if (ip_equal(bcast_ip, wins_ip)) + if (ip_equal(bcast_ip, wins_ip)) + { + if (ip_equal(bcast_ip, d->bcast_ip)) { - if (ip_equal(bcast_ip, d->bcast_ip)) - { - return d; - } + return d; + } } - else if (same_net(bcast_ip, d->bcast_ip, d->mask_ip)) + else if (same_net(bcast_ip, d->bcast_ip, d->mask_ip)) + { + if (!ip_equal(d->bcast_ip, wins_ip)) { - if (!ip_equal(d->bcast_ip, wins_ip)) - { - return d; - } + return d; } + } } - return (NULL); + return (NULL); } @@ -122,9 +126,19 @@ struct subnet_record *find_req_subnet(struct in_addr ip, BOOL bcast) return find_subnet(*iface_bcast(ip)); } /* find the subnet under the pseudo-ip of 255.255.255.255 */ - return find_subnet(ipgrp); + return find_subnet(wins_ip); } +/**************************************************************************** + find a subnet in the subnetlist - if the subnet is not found + then return the WINS subnet. + **************************************************************************/ +struct subnet_record *find_subnet_all(struct in_addr bcast_ip) +{ + struct subnet_record *d = find_subnet(bcast_ip); + if(!d) + return find_subnet( wins_ip); +} /**************************************************************************** create a domain entry @@ -157,24 +171,24 @@ static struct subnet_record *make_subnet(struct in_addr bcast_ip, struct in_addr ****************************************************************************/ void add_subnet_interfaces(void) { - struct interface *i; + struct interface *i; - /* loop on all local interfaces */ - for (i = local_interfaces; i; i = i->next) + /* loop on all local interfaces */ + for (i = local_interfaces; i; i = i->next) + { + /* add the interface into our subnet database */ + if (!find_subnet(i->bcast)) { - /* add the interface into our subnet database */ - if (!find_subnet(i->bcast)) - { - make_subnet(i->bcast,i->nmask); - } + make_subnet(i->bcast,i->nmask); } + } - /* add the pseudo-ip interface for WINS: 255.255.255.255 */ - if (lp_wins_support() || (*lp_wins_server())) + /* add the pseudo-ip interface for WINS: 255.255.255.255 */ + if (lp_wins_support() || (*lp_wins_server())) { - struct in_addr wins_bcast = ipgrp; - struct in_addr wins_nmask = ipzero; - make_subnet(wins_bcast, wins_nmask); + struct in_addr wins_bcast = wins_ip; + struct in_addr wins_nmask = ipzero; + make_subnet(wins_bcast, wins_nmask); } } @@ -205,7 +219,7 @@ void add_my_subnets(char *group) add a domain entry. creates a workgroup, if necessary, and adds the domain to the named a workgroup. ****************************************************************************/ -struct subnet_record *add_subnet_entry(struct in_addr bcast_ip, +static struct subnet_record *add_subnet_entry(struct in_addr bcast_ip, struct in_addr mask_ip, char *name, BOOL add, BOOL lmhosts) { @@ -215,7 +229,7 @@ struct subnet_record *add_subnet_entry(struct in_addr bcast_ip, in the DEBUG comment. i assume that the DEBUG comment below actually intends to refer to bcast_ip? i don't know. - struct in_addr ip = ipgrp; + struct in_addr ip = wins_ip; */ @@ -223,6 +237,8 @@ struct subnet_record *add_subnet_entry(struct in_addr bcast_ip, bcast_ip = *iface_bcast(bcast_ip); /* add the domain into our domain database */ + /* Note that we never add into the WINS subnet as add_subnet_entry + is only called to add our local interfaces. */ if ((d = find_subnet(bcast_ip)) || (d = make_subnet(bcast_ip, mask_ip))) { -- cgit