summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1997-10-23 22:30:57 +0000
committerJeremy Allison <jra@samba.org>1997-10-23 22:30:57 +0000
commitabb255cfe674a39c6a42f5083af9c5facdbcca05 (patch)
treebccbf53d36ce62b7a0e23cbcf628a53850c2db95
parent5557ab3c007b79c132e9a2da16e41be7b13f1b39 (diff)
downloadsamba-abb255cfe674a39c6a42f5083af9c5facdbcca05.tar.gz
samba-abb255cfe674a39c6a42f5083af9c5facdbcca05.tar.bz2
samba-abb255cfe674a39c6a42f5083af9c5facdbcca05.zip
Big change to make nmbd code more readable/understandable.
Main change is removal of find_name_search() confusion. This has been replaced with find_name_on_subnet() which makes it explicit what is being searched. Also changed wins_subnet to be wins_client_subnet in preparation for splitting the wins subnet into client and server pieces. This is a big nmbd change and I'd appreciate any bug reports. Specific changes follow : asyncdns.c: Removed wins entry from add_netbios_entry(). This is now explicit in the subnet_record parameter. interface.c: iface_bcast(), iface_nmask(), iface_ip() return the default interface if none can be found. Made this behavior explicit - some code in nmbd incorrectly depended upon this (reply_name_status() for instance). nameannounce.c: find_name_search changes to find_name_on_subnet. namebrowse.c: wins_subnet renamed to wins_client_subnet. namedbname.c: find_name_search removed. find_name_on_subnet added. add_netbios_entry - wins parameter removed. namedbsubnet.c: find_req_subnet removed - not explicit enough. nameelect.c: wins_subnet renamed to wins_client_subnet. namepacket.c: listening() simplified. nameresp.c: wins_subnet renamed to wins_client_subnet. nameserv.c: find_name_search moved to find_name_on_subnet. nameserv.h: FIND_XXX -> changed to FIND_SELF_NAME, FIND_ANY_NAME. nameservreply.c: find_name_search moved to find_name_on_subnet. Debug entries changed. nameservresp.c: wins_subnet renamed to wins_client_subnet. namework.c: wins_subnet renamed to wins_client_subnet. nmbd.c: wins parameter removed from add_netbios_entry. nmbsync: wins_subnet renamed to wins_client_subnet. proto.h: The usual. server.c: remove accepted fd from fd_set. Jeremy (jallison@whistle.com) (This used to be commit 2c97b33fc0b5ef181dbf51a50cb61074935165bf)
-rw-r--r--source3/include/nameserv.h11
-rw-r--r--source3/include/proto.h20
-rw-r--r--source3/lib/interface.c14
-rw-r--r--source3/nameannounce.c154
-rw-r--r--source3/namebrowse.c2
-rw-r--r--source3/namedbname.c106
-rw-r--r--source3/namedbsubnet.c44
-rw-r--r--source3/nameelect.c11
-rw-r--r--source3/namepacket.c11
-rw-r--r--source3/nameresp.c7
-rw-r--r--source3/nameserv.c145
-rw-r--r--source3/nameservreply.c98
-rw-r--r--source3/nameservresp.c11
-rw-r--r--source3/namework.c6
-rw-r--r--source3/nmbd/asyncdns.c32
-rw-r--r--source3/nmbd/nmbd.c4
-rw-r--r--source3/nmbsync.c2
-rw-r--r--source3/smbd/server.c2
18 files changed, 309 insertions, 371 deletions
diff --git a/source3/include/nameserv.h b/source3/include/nameserv.h
index 5c8ec1e4eb..2a7bb29070 100644
--- a/source3/include/nameserv.h
+++ b/source3/include/nameserv.h
@@ -38,9 +38,8 @@
#define NMB_WAIT_ACK 0x07 /* see rfc1002.txt 4.2.16 */
/* XXXX what about all the other types?? 0x1, 0x2, 0x3, 0x4, 0x8? */
-#define FIND_SELF 0x01
-#define FIND_WINS 0x02
-#define FIND_LOCAL 0x04
+#define FIND_ANY_NAME 0
+#define FIND_SELF_NAME 1
/* NetBIOS flags */
#define NB_GROUP 0x80
@@ -428,11 +427,11 @@ struct packet_struct
the WINS subnet. */
extern struct subnet_record *subnetlist;
-extern struct subnet_record *wins_subnet;
+extern struct subnet_record *wins_client_subnet;
#define FIRST_SUBNET subnetlist
#define NEXT_SUBNET_EXCLUDING_WINS(x) ((x)->next)
-#define NEXT_SUBNET_INCLUDING_WINS(x) ( ((x) == wins_subnet) ? NULL : \
- (((x)->next == NULL) ? wins_subnet : \
+#define NEXT_SUBNET_INCLUDING_WINS(x) ( ((x) == wins_client_subnet) ? NULL : \
+ (((x)->next == NULL) ? wins_client_subnet : \
(x)->next))
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 96c4779e62..603399758f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -440,20 +440,15 @@ void set_samba_nb_type(void);
BOOL name_equal(struct nmb_name *n1,struct nmb_name *n2);
BOOL ms_browser_name(char *name, int type);
void remove_name(struct subnet_record *d, struct name_record *n);
-struct name_record *find_name(struct name_record *n,
- struct nmb_name *name, int search);
-struct name_record *find_name_search(struct subnet_record **d,
- struct nmb_name *name,
- int search, struct in_addr ip);
+struct name_record *find_name_on_subnet(struct subnet_record *d,
+ struct nmb_name *name, BOOL self_only);
void dump_names(void);
void load_netbios_names(void);
void remove_netbios_name(struct subnet_record *d,
- char *name,int type, enum name_source source,
- struct in_addr ip);
+ char *name,int type, enum name_source source);
struct name_record *add_netbios_entry(struct subnet_record *d,
- char *name, int type, int nb_flags,
- int ttl, enum name_source source, struct in_addr ip,
- BOOL new_only,BOOL wins);
+ char *name, int type, int nb_flags, int ttl,
+ enum name_source source, struct in_addr ip, BOOL new_only);
void expire_names(time_t t);
/*The following definitions come from namedbresp.c */
@@ -486,9 +481,8 @@ void expire_servers(time_t t);
/*The following definitions come from namedbsubnet.c */
-struct subnet_record *find_subnet(struct in_addr bcast_ip);
-struct subnet_record *find_req_subnet(struct in_addr ip, BOOL bcast);
-struct subnet_record *find_subnet_all(struct in_addr bcast_ip);
+struct subnet_record *find_subnet(struct in_addr ip);
+struct subnet_record *find_subnet_all(struct in_addr ip);
void add_workgroup_to_subnet( struct subnet_record *d, char *group);
void add_my_subnets(char *group);
void write_browse_list(time_t t);
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index c920cc0cfc..3b038dcda6 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -438,6 +438,9 @@ struct in_addr *iface_n_ip(int n)
return NULL;
}
+/****************************************************************************
+Try and find an interface that matches an ip. If we cannot, return NULL
+ **************************************************************************/
static struct interface *iface_find(struct in_addr ip)
{
struct interface *i;
@@ -446,7 +449,7 @@ static struct interface *iface_find(struct in_addr ip)
for (i=local_interfaces;i;i=i->next)
if (same_net(i->ip,ip,i->nmask)) return i;
- return local_interfaces;
+ return NULL;
}
/* these 3 functions return the ip/bcast/nmask for the interface
@@ -454,17 +457,20 @@ static struct interface *iface_find(struct in_addr ip)
struct in_addr *iface_bcast(struct in_addr ip)
{
- return(&iface_find(ip)->bcast);
+ struct interface *i = iface_find(ip);
+ return(i ? &i->bcast : &local_interfaces->bcast);
}
struct in_addr *iface_nmask(struct in_addr ip)
{
- return(&iface_find(ip)->nmask);
+ struct interface *i = iface_find(ip);
+ return(i ? &i->nmask : &local_interfaces->nmask);
}
struct in_addr *iface_ip(struct in_addr ip)
{
- return(&iface_find(ip)->ip);
+ struct interface *i = iface_find(ip);
+ return(i ? &i->ip : &local_interfaces->ip);
}
diff --git a/source3/nameannounce.c b/source3/nameannounce.c
index b8dcb71fff..ef23e87e58 100644
--- a/source3/nameannounce.c
+++ b/source3/nameannounce.c
@@ -367,32 +367,32 @@ void announce_master(time_t t)
if (!announce_timer_last) announce_timer_last = t;
if (t-announce_timer_last < CHECK_TIME_MST_ANNOUNCE * 60)
- {
- DEBUG(10,("announce_master: t (%d) - last(%d) < %d\n",
- t, announce_timer_last, CHECK_TIME_MST_ANNOUNCE * 60 ));
- return;
- }
+ {
+ DEBUG(10,("announce_master: t (%d) - last(%d) < %d\n",
+ t, announce_timer_last, CHECK_TIME_MST_ANNOUNCE * 60 ));
+ return;
+ }
- if(wins_subnet == NULL)
- {
- DEBUG(10,("announce_master: no wins subnet, ignoring.\n"));
- return;
- }
+ if(wins_client_subnet == NULL)
+ {
+ DEBUG(10,("announce_master: no wins subnet, ignoring.\n"));
+ return;
+ }
announce_timer_last = t;
for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_EXCLUDING_WINS(d))
+ {
+ for (work = d->workgrouplist; work; work = work->next)
{
- for (work = d->workgrouplist; work; work = work->next)
- {
- if (AM_MASTER(work))
- {
- am_master = True;
- DEBUG(4,( "announce_master: am_master = %d for \
+ if (AM_MASTER(work))
+ {
+ am_master = True;
+ DEBUG(4,( "announce_master: am_master = %d for \
workgroup %s\n", am_master, work->work_group));
- }
- }
+ }
}
+ }
if (!am_master) return; /* only proceed if we are a master browser */
@@ -400,79 +400,71 @@ workgroup %s\n", am_master, work->work_group));
and that we *only* do this on the WINS subnet. */
/* Try and find our workgroup on the WINS subnet */
- work = find_workgroupstruct(wins_subnet, myworkgroup, False);
+ work = find_workgroupstruct(wins_client_subnet, myworkgroup, False);
if (work)
+ {
+ /* assume that the domain master browser we want to sync
+ with is our own domain.
+ */
+ char *name = work->work_group;
+ int type = 0x1b;
+
+ /* check the existence of a dmb for this workgroup, and if
+ one exists at the specified ip, sync with it and announce
+ ourselves as a master browser to it
+ */
+
+ if (!lp_wins_support() && *lp_wins_server() )
+ {
+ DEBUG(4, ("Local Announce: find %s<%02x> from WINS server %s\n",
+ name, type, lp_wins_server()));
+
+ queue_netbios_pkt_wins(ClientNMB,
+ NMB_QUERY,NAME_QUERY_DOM_SRV_CHK,
+ name, type, 0,0,0,
+ work->work_group,NULL,
+ ipzero, ipzero);
+ }
+ else if(lp_wins_support())
{
- char *name;
- int type;
-
- {
- /* assume that the domain master browser we want to sync
- with is our own domain.
- */
- name = work->work_group;
- type = 0x1b;
- }
-
- /* check the existence of a dmb for this workgroup, and if
- one exists at the specified ip, sync with it and announce
- ourselves as a master browser to it
- */
-
- if (!lp_wins_support() && *lp_wins_server() )
- {
- DEBUG(4, ("Local Announce: find %s<%02x> from WINS server %s\n",
- name, type, lp_wins_server()));
-
- queue_netbios_pkt_wins(ClientNMB,
- NMB_QUERY,NAME_QUERY_DOM_SRV_CHK,
- name, type, 0,0,0,
- work->work_group,NULL,
- ipzero, ipzero);
- }
- else if(lp_wins_support())
- {
- /* We are the WINS server - query ourselves for the dmb name. */
-
- struct nmb_name netb_name;
- struct name_record *nr = 0;
-
- d = NULL;
-
- make_nmb_name(&netb_name, name, type, scope);
-
- if ((nr = find_name_search(&d, &netb_name, FIND_WINS, ipzero)) == 0)
- {
- DEBUG(0, ("announce_master: unable to find domain master browser for workgroup %s \
+ /* We are the WINS server - query ourselves for the dmb name. */
+
+ struct nmb_name netb_name;
+ struct name_record *nr = 0;
+
+ make_nmb_name(&netb_name, name, type, scope);
+
+ if ((nr = find_name_on_subnet(wins_client_subnet, &netb_name, FIND_ANY_NAME)) == 0)
+ {
+ DEBUG(0, ("announce_master: unable to find domain master browser for workgroup %s \
in our own WINS database.\n", work->work_group));
- return;
- }
-
- /* Check that this isn't one of our addresses (ie. we are not domain master
- ourselves) */
- if(ismyip(nr->ip_flgs[0].ip) || ip_equal(nr->ip_flgs[0].ip, ipzero))
- {
- DEBUG(4, ("announce_master: domain master ip found (%s) for workgroup %s \
+ return;
+ }
+
+ /* Check that this isn't one of our addresses (ie. we are not domain master
+ ourselves) */
+ if(ismyip(nr->ip_flgs[0].ip) || ip_equal(nr->ip_flgs[0].ip, ipzero))
+ {
+ DEBUG(4, ("announce_master: domain master ip found (%s) for workgroup %s \
is one of our interfaces.\n", work->work_group, inet_ntoa(nr->ip_flgs[0].ip) ));
- return;
- }
+ return;
+ }
- /* Issue a NAME_STATUS_DOM_SRV_CHK immediately - short circuit the
- NAME_QUERY_DOM_SRV_CHK which is done only if we are talking to a
- remote WINS server. */
+ /* Issue a NAME_STATUS_DOM_SRV_CHK immediately - short circuit the
+ NAME_QUERY_DOM_SRV_CHK which is done only if we are talking to a
+ remote WINS server. */
- DEBUG(4, ("announce_master: doing name status for %s<%02x> to domain master ip %s \
+ DEBUG(4, ("announce_master: doing name status for %s<%02x> to domain master ip %s \
for workgroup %s\n", name, type, inet_ntoa(nr->ip_flgs[0].ip), work->work_group ));
- queue_netbios_packet(wins_subnet, ClientNMB,
- NMB_QUERY,NAME_STATUS_DOM_SRV_CHK,
- name, type, 0,0,0,
- work->work_group,NULL,
- False, False, nr->ip_flgs[0].ip, nr->ip_flgs[0].ip, 0);
- }
-
+ queue_netbios_packet(wins_client_subnet, ClientNMB,
+ NMB_QUERY,NAME_STATUS_DOM_SRV_CHK,
+ name, type, 0,0,0,
+ work->work_group,NULL,
+ False, False, nr->ip_flgs[0].ip, nr->ip_flgs[0].ip, 0);
}
+ }
}
/****************************************************************************
diff --git a/source3/namebrowse.c b/source3/namebrowse.c
index ae5f00ce10..c0deaff0fa 100644
--- a/source3/namebrowse.c
+++ b/source3/namebrowse.c
@@ -170,7 +170,7 @@ static void start_sync_browse_entry(struct browse_cache_record *b)
struct work_record *work;
/* Check panic conditions - these should not be true. */
- if(b->subnet != wins_subnet) {
+ if(b->subnet != wins_client_subnet) {
DEBUG(0,
("start_sync_browse_entry: ERROR sync requested on non-WINS subnet.\n"));
return;
diff --git a/source3/namedbname.c b/source3/namedbname.c
index f126b4651c..6ff20f4d45 100644
--- a/source3/namedbname.c
+++ b/source3/namedbname.c
@@ -113,7 +113,7 @@ static void add_name(struct subnet_record *d, struct name_record *n)
n->next = NULL;
n->prev = n2;
- if((d == wins_subnet) && lp_wins_support())
+ if((d == wins_client_subnet) && lp_wins_support())
updatedlists = True;
}
@@ -144,17 +144,18 @@ void remove_name(struct subnet_record *d, struct name_record *n)
free(nlist);
}
- if((d == wins_subnet) && lp_wins_support())
+ if((d == wins_client_subnet) && lp_wins_support())
updatedlists = True;
}
/****************************************************************************
- find a name in a namelist.
+ find a name in a subnet.
**************************************************************************/
-struct name_record *find_name(struct name_record *n,
- struct nmb_name *name, int search)
+struct name_record *find_name_on_subnet(struct subnet_record *d,
+ struct nmb_name *name, BOOL self_only)
{
+ struct name_record *n = d->namelist;
struct name_record *ret;
for (ret = n; ret; ret = ret->next)
@@ -162,56 +163,20 @@ struct name_record *find_name(struct name_record *n,
if (name_equal(&ret->name,name))
{
/* self search: self names only */
- if ((search&FIND_SELF) == FIND_SELF && ret->source != SELF)
+ if (self_only && (ret->source != SELF))
{
continue;
}
- DEBUG(9,("find_name: found name %s(%02x) source=%d\n",
- name->name, name->name_type, ret->source));
+ DEBUG(9,("find_name_on_subnet: on subnet %s - found name %s(%02x) source=%d\n",
+ inet_ntoa(d->bcast_ip), name->name, name->name_type, ret->source));
return ret;
}
}
- DEBUG(9,("find_name: name %s(%02x) NOT FOUND\n", name->name,
- name->name_type));
+ DEBUG(9,("find_name_on_subnet: on subnet %s - name %s(%02x) NOT FOUND\n",
+ inet_ntoa(d->bcast_ip), name->name, name->name_type));
return NULL;
}
-
-/****************************************************************************
- find a name in the domain database namelist
- search can be any of:
- FIND_SELF - look exclusively for names the samba server has added for itself
- FIND_LOCAL - look for names in the local subnet record.
- FIND_WINS - look for names in the WINS record
- **************************************************************************/
-struct name_record *find_name_search(struct subnet_record **d,
- struct nmb_name *name,
- int search, struct in_addr ip)
-{
- if (d == NULL) return NULL; /* bad error! */
-
- if (search & FIND_LOCAL) {
- if (*d != NULL) {
- struct name_record *n = find_name((*d)->namelist, name, search);
- DEBUG(4,("find_name on local: %s %s search %x\n",
- namestr(name),inet_ntoa(ip), search));
- if (n) return n;
- }
- }
-
- if (!(search & FIND_WINS)) return NULL;
-
- /* find WINS subnet record. */
- *d = wins_subnet;
-
- if (*d == NULL) return NULL;
-
- DEBUG(4,("find_name on WINS: %s %s search %x\n",
- namestr(name),inet_ntoa(ip), search));
- return find_name((*d)->namelist, name, search);
-}
-
-
/****************************************************************************
dump a copy of the name table
**************************************************************************/
@@ -223,7 +188,7 @@ void dump_names(void)
FILE *f;
- if(lp_wins_support() == False || wins_subnet == 0)
+ if(lp_wins_support() == False || wins_client_subnet == NULL)
return;
fstrcpy(fname,lp_lockdir());
@@ -243,12 +208,12 @@ void dump_names(void)
DEBUG(4,("Dump of WINS name table:\n"));
- for (n = wins_subnet->namelist; n; n = n->next)
+ for (n = wins_client_subnet->namelist; n; n = n->next)
{
int i;
- DEBUG(4,("%15s ", inet_ntoa(wins_subnet->bcast_ip)));
- DEBUG(4,("%15s ", inet_ntoa(wins_subnet->mask_ip)));
+ DEBUG(4,("%15s ", inet_ntoa(wins_client_subnet->bcast_ip)));
+ DEBUG(4,("%15s ", inet_ntoa(wins_client_subnet->mask_ip)));
DEBUG(4,("%-19s TTL=%ld ",
namestr(&n->name),
n->death_time?n->death_time-t:0));
@@ -298,7 +263,7 @@ void dump_names(void)
****************************************************************************/
void load_netbios_names(void)
{
- struct subnet_record *d = wins_subnet;
+ struct subnet_record *d = wins_client_subnet;
fstring fname;
FILE *f;
@@ -398,7 +363,7 @@ void load_netbios_names(void)
time_t t = (ttd?ttd-time(NULL):0) / 3;
/* add netbios entry read from the wins.dat file. IF it's ok */
- add_netbios_entry(d,name,type,nb_flags,t,source,ipaddr,True,True);
+ add_netbios_entry(d,name,type,nb_flags,t,source,ipaddr,True);
}
}
@@ -410,14 +375,13 @@ void load_netbios_names(void)
remove an entry from the name list
****************************************************************************/
void remove_netbios_name(struct subnet_record *d,
- char *name,int type, enum name_source source,
- struct in_addr ip)
+ char *name,int type, enum name_source source)
{
struct nmb_name nn;
struct name_record *n;
make_nmb_name(&nn, name, type, scope);
- n = find_name_search(&d, &nn, FIND_LOCAL, ip);
+ n = find_name_on_subnet(d, &nn, FIND_ANY_NAME);
if (n && n->source == source) remove_name(d,n);
}
@@ -435,26 +399,21 @@ void remove_netbios_name(struct subnet_record *d,
****************************************************************************/
struct name_record *add_netbios_entry(struct subnet_record *d,
- char *name, int type, int nb_flags,
- int ttl, enum name_source source, struct in_addr ip,
- BOOL new_only,BOOL wins)
+ char *name, int type, int nb_flags, int ttl,
+ enum name_source source, struct in_addr ip, BOOL new_only)
{
struct name_record *n;
struct name_record *n2=NULL;
- struct subnet_record *found_subnet = 0;
- int search = 0;
- BOOL self = (source == SELF);
+ BOOL self = (source == SELF) ? FIND_SELF_NAME : FIND_ANY_NAME;
+ /* It's a WINS add if we're adding to the wins_client_subnet. */
+ BOOL wins = ( wins_client_subnet && (d == wins_client_subnet));
- /* add the name to the WINS list if the name comes from a directed query */
- search |= wins ? FIND_WINS : FIND_LOCAL;
-
- /* If it's a local search then we need to set the subnet
- we are looking at. */
- if(search & FIND_LOCAL)
- found_subnet = d;
-
- /* search for SELF names only */
- search |= self ? FIND_SELF : 0;
+ if(d == NULL)
+ {
+ DEBUG(0,("add_netbios_entry: called with NULL subnet record. This is a bug - \
+please report this.!\n"));
+ return NULL;
+ }
if (!self)
{
@@ -490,13 +449,12 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
make_nmb_name(&n->name,name,type,scope);
- if ((n2 = find_name_search(&found_subnet, &n->name, search, new_only?ipzero:ip)))
+ if ((n2 = find_name_on_subnet(d, &n->name, self)))
{
free(n->ip_flgs);
free(n);
if (new_only || (n2->source==SELF && source!=SELF)) return n2;
n = n2;
- d = found_subnet;
}
if (ttl)
@@ -513,7 +471,7 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
DEBUG(3,("Added netbios name %s at %s ttl=%d nb_flags=%2x to interface %s\n",
namestr(&n->name),inet_ntoa(ip),ttl,nb_flags,
- ip_equal(d->bcast_ip, wins_ip) ? "WINS" : (char *)inet_ntoa(d->bcast_ip)));
+ wins ? "WINS" : (char *)inet_ntoa(d->bcast_ip)));
return(n);
}
diff --git a/source3/namedbsubnet.c b/source3/namedbsubnet.c
index 3597c32387..27c1a0470e 100644
--- a/source3/namedbsubnet.c
+++ b/source3/namedbsubnet.c
@@ -55,7 +55,7 @@ struct subnet_record *subnetlist = NULL;
/* WINS subnet - keep this separate so enumeration code doesn't
run onto it by mistake. */
-struct subnet_record *wins_subnet = NULL;
+struct subnet_record *wins_client_subnet = NULL;
extern uint16 nb_type; /* samba's NetBIOS name type */
@@ -83,50 +83,34 @@ static void add_subnet(struct subnet_record *d)
/****************************************************************************
- find a subnet in the subnetlist - not including WINS.
+ find a subnet in the subnetlist that a given IP address could
+ match - not including WINS. Returns NULL if no match.
**************************************************************************/
-struct subnet_record *find_subnet(struct in_addr bcast_ip)
+struct subnet_record *find_subnet(struct in_addr ip)
{
- struct subnet_record *d;
+ struct subnet_record *d = NULL;
/* search through subnet list for broadcast/netmask that matches
the source ip address. */
for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_EXCLUDING_WINS(d))
{
- if (same_net(bcast_ip, d->bcast_ip, d->mask_ip))
- return d;
+ if (same_net(ip, d->bcast_ip, d->mask_ip))
+ break;
}
- return (NULL);
-}
-
-
-/****************************************************************************
- finds the appropriate subnet structure. directed packets (non-bcast) are
- assumed to come from a point-to-point (P or M node), and so the subnet we
- return in this instance is the WINS 'pseudo-subnet' with ip 255.255.255.255
- ****************************************************************************/
-struct subnet_record *find_req_subnet(struct in_addr ip, BOOL bcast)
-{
- if (bcast)
- {
- /* identify the subnet the broadcast request came from */
- return find_subnet(*iface_bcast(ip));
- }
- /* Return the subnet with the pseudo-ip of 255.255.255.255 */
- return wins_subnet;
+ return d;
}
/****************************************************************************
find a subnet in the subnetlist - if the subnet is not found
- then return the WINS subnet.
+ then return the WINS client subnet.
**************************************************************************/
-struct subnet_record *find_subnet_all(struct in_addr bcast_ip)
+struct subnet_record *find_subnet_all(struct in_addr ip)
{
- struct subnet_record *d = find_subnet(bcast_ip);
+ struct subnet_record *d = find_subnet(ip);
if(!d)
- return wins_subnet;
+ return wins_client_subnet;
return d;
}
@@ -235,7 +219,7 @@ static struct subnet_record *add_subnet_entry(struct in_addr myip,
return d;
}
if(ip_equal(bcast_ip, wins_ip))
- return wins_subnet;
+ return wins_client_subnet;
return find_subnet(bcast_ip);
}
@@ -329,7 +313,7 @@ void add_my_subnets(char *group)
if (lp_wins_support() || lp_wins_server())
{
struct in_addr wins_nmask = ipzero;
- wins_subnet = add_subnet_entry(ipzero, wins_ip, wins_nmask, group, create_subnets, False);
+ wins_client_subnet = add_subnet_entry(ipzero, wins_ip, wins_nmask, group, create_subnets, False);
}
/* Ensure we only create the subnets once. */
diff --git a/source3/nameelect.c b/source3/nameelect.c
index 215ee94feb..391320e84f 100644
--- a/source3/nameelect.c
+++ b/source3/nameelect.c
@@ -207,7 +207,7 @@ void name_unregister_work(struct subnet_record *d, char *name, int name_type)
int remove_type_domain = 0;
int remove_type_logon = 0;
- remove_netbios_name(d,name,name_type,SELF,ipzero);
+ remove_netbios_name(d,name,name_type,SELF);
if (!(work = find_workgroupstruct(d, name, False))) return;
@@ -254,7 +254,8 @@ void name_register_work(struct subnet_record *d, char *name, int name_type,
struct work_record *work = find_workgroupstruct(d,
myworkgroup, False);
- add_netbios_entry(d,name,name_type,nb_flags,ttl,source,ip,True,!bcast);
+ struct subnet_record *add_subnet = (!bcast) ? wins_client_subnet : d;
+ add_netbios_entry(add_subnet,name,name_type,nb_flags,ttl,source,ip,True);
if (work)
{
@@ -488,7 +489,7 @@ void become_domain_master(struct subnet_record *d, struct work_record *work)
DEBUG(0,("Samba is now a domain master browser for workgroup %s on subnet %s\n",
work->work_group, inet_ntoa(d->bcast_ip)));
- if (d == wins_subnet)
+ if (d == wins_client_subnet)
{
/* ok! we successfully registered by unicast with the
WINS server. we now expect to become the domain
@@ -642,8 +643,8 @@ void unbecome_domain_master(struct subnet_record *d, struct work_record *work,
}
/* Unregister the 1b name from the WINS server. */
- if(wins_subnet != NULL)
- remove_name_entry(wins_subnet, myworkgroup, 0x1b);
+ if(wins_client_subnet != NULL)
+ remove_name_entry(wins_client_subnet, myworkgroup, 0x1b);
}
}
diff --git a/source3/namepacket.c b/source3/namepacket.c
index 5b3f06f16d..626e50b788 100644
--- a/source3/namepacket.c
+++ b/source3/namepacket.c
@@ -319,13 +319,10 @@ void queue_packet(struct packet_struct *packet)
static BOOL listening(struct packet_struct *p,struct nmb_name *n)
{
struct subnet_record *d;
- struct name_record *n1;
+ struct name_record *n1 = NULL;
- /* We explicitly don't search WINS here - this will be done
- in find_name_search if it was a packet from a non-local subnet. */
- d = find_subnet(p->ip);
-
- n1 = find_name_search(&d,n,FIND_LOCAL|FIND_WINS|FIND_SELF,p->ip);
+ if((d = find_subnet_all(p->ip)) != NULL)
+ n1 = find_name_on_subnet(d, n, FIND_SELF_NAME);
return (n1 != NULL);
}
@@ -483,7 +480,7 @@ static void process_nmb(struct packet_struct *p)
******************************************************************/
void run_packet_queue()
{
- struct packet_struct *p, *nextp;
+ struct packet_struct *p;
while ((p=packet_queue)) {
packet_queue = p->next;
diff --git a/source3/nameresp.c b/source3/nameresp.c
index 81624fcaf1..de1f33c717 100644
--- a/source3/nameresp.c
+++ b/source3/nameresp.c
@@ -61,15 +61,14 @@ static void dead_netbios_entry(struct subnet_record *d,
if ((!NAME_GROUP(n->nb_flags)))
{
- struct subnet_record *d1 = wins_subnet;
+ struct subnet_record *d1 = wins_client_subnet;
if (d1)
{
/* remove the name that had been registered with us,
and we're now getting no response when challenging.
see rfc1001.txt 15.5.2
*/
- remove_netbios_name(d1, n->name.name, n->name.name_type,
- REGISTER, n->send_ip);
+ remove_netbios_name(d1, n->name.name, n->name.name_type, REGISTER);
}
}
}
@@ -271,7 +270,7 @@ struct response_record *queue_netbios_pkt_wins(
if (zero_ip(send_ip)) return NULL;
- return queue_netbios_packet(wins_subnet,fd, quest_type, state,
+ return queue_netbios_packet(wins_client_subnet,fd, quest_type, state,
name, name_type, nb_flags, ttl,
server_type,my_name,my_comment,
False, True, send_ip, reply_to_ip, 0);
diff --git a/source3/nameserv.c b/source3/nameserv.c
index a90b41f834..a05db3983e 100644
--- a/source3/nameserv.c
+++ b/source3/nameserv.c
@@ -59,18 +59,12 @@ void remove_name_entry(struct subnet_record *d, char *name,int type)
a de-registration packet to the local subnet before removing the
name from its local-subnet name database. */
- int search = FIND_SELF;
struct name_record n;
struct name_record *n2=NULL;
make_nmb_name(&n.name,name,type,scope);
- if(d == wins_subnet)
- search |= FIND_WINS;
- else
- search |= FIND_LOCAL;
-
- if ((n2 = find_name_search(&d, &n.name, search, ipzero)))
+ if ((n2 = find_name_on_subnet(d, &n.name, FIND_SELF_NAME)))
{
/* check name isn't already being de-registered */
if (NAME_DEREG(n2->ip_flgs[0].nb_flags))
@@ -94,7 +88,7 @@ void remove_name_entry(struct subnet_record *d, char *name,int type)
first try to release them, this is too dangerous with our current
name structures as otherwise we will end up replying to names we
don't really own */
- remove_netbios_name(d,name,type,SELF,n2->ip_flgs[0].ip);
+ remove_netbios_name(d,name,type,SELF);
if (ip_equal(d->bcast_ip, wins_ip))
{
@@ -134,7 +128,7 @@ void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags)
it must be re-registered, rather than just registered */
make_nmb_name(&n, name, type, scope);
- if (find_name(d->namelist, &n, SELF))
+ if (find_name_on_subnet(d, &n, FIND_SELF_NAME))
re_reg = True;
/* XXXX BUG: if samba is offering WINS support, it should still add the
@@ -182,30 +176,30 @@ void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags)
****************************************************************************/
void add_domain_logon_names(void)
{
- struct subnet_record *d;
+ struct subnet_record *d;
- if (!lp_domain_logons()) return;
+ if (!lp_domain_logons()) return;
- for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_INCLUDING_WINS(d))
- {
- struct work_record *work = find_workgroupstruct(d, myworkgroup, True);
+ for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_INCLUDING_WINS(d))
+ {
+ struct work_record *work = find_workgroupstruct(d, myworkgroup, True);
- if (work && work->log_state == LOGON_NONE)
- {
- struct nmb_name n;
- make_nmb_name(&n,myworkgroup,0x1c,scope);
+ if (work && work->log_state == LOGON_NONE)
+ {
+ struct nmb_name n;
+ make_nmb_name(&n,myworkgroup,0x1c,scope);
- if (!find_name(d->namelist, &n, FIND_SELF))
- {
- /* logon servers are group names. don't expect failure */
+ if (!find_name_on_subnet(d, &n, FIND_SELF_NAME))
+ {
+ /* logon servers are group names. don't expect failure */
- DEBUG(0,("%s attempting to become logon server for %s %s\n",
- timestring(), myworkgroup, inet_ntoa(d->bcast_ip)));
+ DEBUG(0,("%s attempting to become logon server for %s %s\n",
+ timestring(), myworkgroup, inet_ntoa(d->bcast_ip)));
- become_logon_server(d, work);
- }
- }
- }
+ become_logon_server(d, work);
+ }
+ }
+ }
}
@@ -227,7 +221,7 @@ void add_domain_master_bcast(void)
struct nmb_name n;
make_nmb_name(&n,myworkgroup,0x1b,scope);
- if (!find_name(d->namelist, &n, FIND_SELF))
+ if (!find_name_on_subnet(d, &n, FIND_SELF_NAME))
{
DEBUG(0,("%s add_domain_names: attempting to become domain \
master browser on workgroup %s %s\n", timestring(), myworkgroup, inet_ntoa(d->bcast_ip)));
@@ -259,57 +253,57 @@ for domain master on workgroup %s\n", inet_ntoa(d->bcast_ip), myworkgroup));
****************************************************************************/
void add_domain_master_wins(void)
{
- struct work_record *work;
+ struct work_record *work;
- if (!lp_domain_master() || wins_subnet == NULL) return;
+ if (!lp_domain_master() || wins_client_subnet == NULL) return;
- work = find_workgroupstruct(wins_subnet, myworkgroup, True);
+ work = find_workgroupstruct(wins_client_subnet, myworkgroup, True);
- if (work && work->dom_state == DOMAIN_NONE)
- {
- struct nmb_name n;
- make_nmb_name(&n,myworkgroup,0x1b,scope);
+ if (work && work->dom_state == DOMAIN_NONE)
+ {
+ struct nmb_name n;
+ make_nmb_name(&n,myworkgroup,0x1b,scope);
- if (!find_name(wins_subnet->namelist, &n, FIND_SELF))
- {
- DEBUG(0,("%s add_domain_names: attempting to become domain \
+ if (!find_name_on_subnet(wins_client_subnet, &n, FIND_SELF_NAME))
+ {
+ DEBUG(0,("%s add_domain_names: attempting to become domain \
master browser on workgroup %s %s\n",
- timestring(), myworkgroup, inet_ntoa(wins_subnet->bcast_ip)));
+ timestring(), myworkgroup, inet_ntoa(wins_client_subnet->bcast_ip)));
- if (lp_wins_support())
- {
- /* use the wins server's capabilities (indirectly). if
- someone has already registered the domain<1b>
- name with the WINS server, then the WINS
- server's job is to _check_ that the owner still
- wants it, before giving it away.
- */
+ if (lp_wins_support())
+ {
+ /* use the wins server's capabilities (indirectly). if
+ someone has already registered the domain<1b>
+ name with the WINS server, then the WINS
+ server's job is to _check_ that the owner still
+ wants it, before giving it away.
+ */
- DEBUG(1,("%s initiate become domain master for %s\n",
- timestring(), myworkgroup));
+ DEBUG(1,("%s initiate become domain master for %s\n",
+ timestring(), myworkgroup));
- become_domain_master(wins_subnet, work);
- }
- else
- {
- /* send out a query to establish whether there's a
- domain controller on the WINS subnet. if not,
- we can become a domain controller. it's only
- polite that we check, before claiming the
- NetBIOS name 0x1b.
- */
-
- DEBUG(0,("add_domain_names:querying WINS \
+ become_domain_master(wins_client_subnet, work);
+ }
+ else
+ {
+ /* send out a query to establish whether there's a
+ domain controller on the WINS subnet. if not,
+ we can become a domain controller. it's only
+ polite that we check, before claiming the
+ NetBIOS name 0x1b.
+ */
+
+ DEBUG(0,("add_domain_names:querying WINS \
for domain master on workgroup %s\n", myworkgroup));
- queue_netbios_pkt_wins(ClientNMB,NMB_QUERY,
- NAME_QUERY_DOMAIN,
- myworkgroup, 0x1b,
- 0, 0,0,NULL,NULL,
- ipzero, ipzero);
- }
- }
- }
+ queue_netbios_pkt_wins(ClientNMB,NMB_QUERY,
+ NAME_QUERY_DOMAIN,
+ myworkgroup, 0x1b,
+ 0, 0,0,NULL,NULL,
+ ipzero, ipzero);
+ }
+ }
+ }
}
@@ -332,7 +326,7 @@ void add_domain_names(time_t t)
add_domain_logon_names();
/* do the domain master names */
- if (wins_subnet != NULL)
+ if (wins_client_subnet != NULL)
{
/* if the registration of the <1b> name is successful, then
add_domain_master_bcast() will be called. this will
@@ -366,7 +360,6 @@ void add_my_names(void)
for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_INCLUDING_WINS(d))
{
int n;
- BOOL wins = (lp_wins_support() && (d == wins_subnet));
/* Add all our names including aliases. */
for (n=0; my_netbios_names[n]; n++)
@@ -378,10 +371,10 @@ void add_my_names(void)
/* these names are added permanently (ttl of zero) and will NOT be
refreshed with the WINS server */
- add_netbios_entry(d,"*",0x0,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins);
- add_netbios_entry(d,"*",0x20,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins);
- add_netbios_entry(d,"__SAMBA__",0x20,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins);
- add_netbios_entry(d,"__SAMBA__",0x00,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins);
+ add_netbios_entry(d,"*",0x0,nb_type|NB_ACTIVE,0,SELF,d->myip,False);
+ add_netbios_entry(d,"*",0x20,nb_type|NB_ACTIVE,0,SELF,d->myip,False);
+ add_netbios_entry(d,"__SAMBA__",0x20,nb_type|NB_ACTIVE,0,SELF,d->myip,False);
+ add_netbios_entry(d,"__SAMBA__",0x00,nb_type|NB_ACTIVE,0,SELF,d->myip,False);
}
}
@@ -452,7 +445,7 @@ void refresh_my_names(time_t t)
void query_refresh_names(time_t t)
{
struct name_record *n;
- struct subnet_record *d = wins_subnet;
+ struct subnet_record *d = wins_client_subnet;
static time_t lasttime = 0;
diff --git a/source3/nameservreply.c b/source3/nameservreply.c
index 6585a02261..d1cbbb026d 100644
--- a/source3/nameservreply.c
+++ b/source3/nameservreply.c
@@ -91,8 +91,8 @@ void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_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);
+ add_netbios_entry(wins_client_subnet,name->name,name->name_type,
+ nb_flags,ttl,REGISTER,register_ip,False);
/* reply yes or no to the host that requested the name */
/* see rfc1002.txt - 4.2.10 and 4.2.11 */
@@ -115,7 +115,6 @@ void reply_name_release(struct packet_struct *p)
BOOL bcast = nmb->header.nm_flags.bcast;
struct name_record *n;
struct subnet_record *d = NULL;
- int search = 0;
BOOL success = False;
putip((char *)&ip,&nmb->additional->rdata[2]);
@@ -123,20 +122,19 @@ void reply_name_release(struct packet_struct *p)
DEBUG(3,("Name release on name %s\n",
namestr(&nmb->question.question_name)));
- if (!(d = find_req_subnet(p->ip, bcast)))
- {
- DEBUG(3,("response packet: bcast %s not known\n",
- inet_ntoa(p->ip)));
- return;
- }
-
- if (bcast)
- search |= FIND_LOCAL;
+ if(!bcast)
+ d = wins_client_subnet;
else
- search |= FIND_WINS;
+ d = find_subnet(p->ip);
+
+ if (!d)
+ {
+ DEBUG(3,("response packet: can't match address %s to subnet\n",
+ inet_ntoa(p->ip)));
+ return;
+ }
- n = find_name_search(&d, &nmb->question.question_name,
- search, ip);
+ n = find_name_on_subnet(d, &nmb->question.question_name, FIND_ANY_NAME);
/* XXXX under what conditions should we reject the removal?? */
/* For now - remove if the names match and the group bit matches. */
@@ -196,7 +194,6 @@ void reply_name_reg(struct packet_struct *p)
BOOL secured_redirect = False;
struct in_addr ip, from_ip;
- int search = 0;
putip((char *)&from_ip,&nmb->additional->rdata[2]);
ip = from_ip;
@@ -211,20 +208,20 @@ void reply_name_reg(struct packet_struct *p)
ip = *interpret_addr2("255.255.255.255");
}
- if (!(d = find_req_subnet(p->ip, bcast)))
+ if (!bcast)
+ d = wins_client_subnet;
+ else
+ d = find_subnet(p->ip);
+
+ if (!d)
{
- DEBUG(3,("reply_name_reg: subnet %s not known\n",
+ DEBUG(3,("reply_name_reg: can't match address %s to subnet\n",
inet_ntoa(p->ip)));
return;
}
- if (bcast)
- search |= FIND_LOCAL;
- else
- search |= FIND_WINS;
-
/* see if the name already exists */
- n = find_name_search(&d, question, search, from_ip);
+ n = find_name_on_subnet(d, question, FIND_ANY_NAME);
if (n)
{
@@ -280,8 +277,7 @@ void reply_name_reg(struct packet_struct *p)
{
DEBUG(3,("not found\n"));
/* add the name to our name/subnet, or WINS, database */
- n = add_netbios_entry(d,qname,qname_type,nb_flags,ttl,REGISTER,ip,
- True,!bcast);
+ n = add_netbios_entry(d,qname,qname_type,nb_flags,ttl,REGISTER,ip,True);
}
/* if samba owns a unique name on a subnet, then it must respond and
@@ -373,23 +369,36 @@ void reply_name_status(struct packet_struct *p)
char *countptr, *buf, *bufend, *buf0;
int names_added,i;
struct name_record *n;
- struct subnet_record *d = NULL;
- int search = FIND_SELF | FIND_WINS | FIND_LOCAL;
+ struct subnet_record *d = wins_client_subnet;
+ BOOL bcast = nmb->header.nm_flags.bcast;
- /* NOTE: we always treat a name status lookup as a bcast */
- if (!(d = find_req_subnet(p->ip, True)))
+ /* This query shoud only be made point to point. */
+ if(bcast)
{
- DEBUG(3,("Name status req: bcast %s not known\n",
+ DEBUG(3,("Name status req: ignoring bcast from %s\n",
inet_ntoa(p->ip)));
return;
}
- DEBUG(3,("Name status for name %s %s\n",
+ if(d == NULL)
+ {
+ /* We are working broadcast only (no wins_client_subnet).
+ Use the first matching subnet. If none matches
+ then return.
+ */
+ if((d = find_subnet(p->ip)) == NULL)
+ {
+ DEBUG(3,("Name status req: can't match address %s to subnet\n",
+ inet_ntoa(p->ip)));
+ return;
+ }
+ }
+
+ DEBUG(3,("Name status for name %s from ip %s\n",
namestr(&nmb->question.question_name),
inet_ntoa(p->ip)));
- n = find_name_search(&d, &nmb->question.question_name,
- search, p->ip);
+ n = find_name_on_subnet(d, &nmb->question.question_name, FIND_SELF_NAME);
if (!n) return;
@@ -455,7 +464,7 @@ void reply_name_status(struct packet_struct *p)
/* end of this name list: add wins names too? */
struct subnet_record *w_d;
- if (!(w_d = wins_subnet)) break;
+ if (!(w_d = wins_client_subnet)) break;
if (w_d != d)
{
@@ -532,9 +541,9 @@ void reply_name_query(struct packet_struct *p)
if (query_is_to_wins_server)
{
/* queries to the WINS server involve the WINS server subnet */
- if (!(d = wins_subnet))
+ if (!(d = wins_client_subnet))
{
- DEBUG(3,("name query: wins search %s not known\n",
+ DEBUG(3,("name query: wins server query from %s and no wins subnet being used.\n",
inet_ntoa(p->ip)));
success = False;
}
@@ -546,9 +555,9 @@ void reply_name_query(struct packet_struct *p)
server entries. not good.
*/
- if (!(d = find_subnet(*iface_bcast(p->ip))))
+ if (!(d = find_subnet_all(p->ip)))
{
- DEBUG(3,("name query: interface for %s not known\n",
+ DEBUG(3,("name query: can't match address %s to subnet\n",
inet_ntoa(p->ip)));
success = False;
}
@@ -567,10 +576,13 @@ void reply_name_query(struct packet_struct *p)
if (success)
{
/* look up the name in the cache */
- n = find_name_search(&d, question, FIND_LOCAL, p->ip);
+ n = find_name_on_subnet(d, question, FIND_ANY_NAME);
+
+ /* check for a previous DNS lookup (these are stored
+ on the wins_client_subnet name list, if it exists */
- /* check for a previous DNS lookup */
- if (!n && (n = find_name_search(&d, question, FIND_WINS, p->ip))) {
+ if (!n && wins_client_subnet && (d != wins_client_subnet) &&
+ (n = find_name_on_subnet(wins_client_subnet, question, FIND_ANY_NAME))) {
if (n->source != DNS && n->source != DNSFAIL) {
n = NULL;
} else {
@@ -589,7 +601,7 @@ void reply_name_query(struct packet_struct *p)
/* do we want to do dns lookups? */
if (success && !n && (lp_dns_proxy() || !bcast)) {
BOOL dns_type = (name_type == 0x20 || name_type == 0);
- if (dns_type && wins_subnet) {
+ if (dns_type && wins_client_subnet) {
/* add it to the dns name query queue */
if (queue_dns_query(p, question, &n))
return;
diff --git a/source3/nameservresp.c b/source3/nameservresp.c
index 61e4a835f4..3349610da6 100644
--- a/source3/nameservresp.c
+++ b/source3/nameservresp.c
@@ -111,7 +111,7 @@ static void response_name_reg(struct nmb_name *ans_name,
treat such errors as success for this particular
case only. jallison@whistle.com.
*/
- if ( ((d != wins_subnet) && (nmb->header.rcode == 6) && strequal(myworkgroup, name) &&
+ if ( ((d != wins_client_subnet) && (nmb->header.rcode == 6) && strequal(myworkgroup, name) &&
(type == 0x1b)) ||
(nmb->header.rcode == 0 && nmb->answers && nmb->answers->rdata))
#else
@@ -426,10 +426,12 @@ static void response_name_query_sync(struct nmb_packet *nmb,
}
else
{
+ struct subnet_record *add_rec = (!bcast) ? wins_client_subnet : d;
+
/* update our netbios name list (re-register it if necessary) */
- add_netbios_entry(d, ans_name->name, ans_name->name_type,
+ add_netbios_entry(add_rec, ans_name->name, ans_name->name_type,
nb_flags,GET_TTL(0),REGISTER,
- found_ip,False,!bcast);
+ found_ip,False);
}
}
else
@@ -443,8 +445,7 @@ static void response_name_query_sync(struct nmb_packet *nmb,
then we're in a mess: our name database doesn't match
reality. sort it out
*/
- remove_netbios_name(d,n->name.name, n->name.name_type,
- REGISTER,n->send_ip);
+ remove_netbios_name(d,n->name.name, n->name.name_type, REGISTER);
}
}
}
diff --git a/source3/namework.c b/source3/namework.c
index 2de4a3016f..540aec5bfe 100644
--- a/source3/namework.c
+++ b/source3/namework.c
@@ -282,7 +282,7 @@ static void process_master_announce(struct packet_struct *p,char *buf)
if (same_context(dgram)) return;
- if (!wins_subnet)
+ if (!wins_client_subnet)
{
DEBUG(3,("process_master_announce: No wins subnet !\n"));
return;
@@ -294,12 +294,12 @@ static void process_master_announce(struct packet_struct *p,char *buf)
return;
}
- for (work = wins_subnet->workgrouplist; work; work = work->next)
+ for (work = wins_client_subnet->workgrouplist; work; work = work->next)
{
if (AM_MASTER(work) || AM_DOMMST(work))
{
/* merge browse lists with them */
- add_browser_entry(name,0x1d, work->work_group,30,wins_subnet,p->ip,True);
+ add_browser_entry(name,0x1d, work->work_group,30,wins_client_subnet,p->ip,True);
}
}
}
diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c
index 548781edea..94fd65b147 100644
--- a/source3/nmbd/asyncdns.c
+++ b/source3/nmbd/asyncdns.c
@@ -35,22 +35,22 @@ extern int DEBUGLEVEL;
****************************************************************************/
static struct name_record *add_dns_result(struct nmb_name *question, struct in_addr addr)
{
- int name_type = question->name_type;
- char *qname = question->name;
-
- if (!addr.s_addr) {
- /* add the fail to WINS cache of names. give it 1 hour in the cache */
- DEBUG(3,("Negative DNS answer for %s\n", qname));
- add_netbios_entry(wins_subnet,qname,name_type,NB_ACTIVE,60*60,DNSFAIL,addr,
- True, True);
- return NULL;
- }
-
- /* add it to our WINS cache of names. give it 2 hours in the cache */
- DEBUG(3,("DNS gave answer for %s of %s\n", qname, inet_ntoa(addr)));
-
- return add_netbios_entry(wins_subnet,qname,name_type,NB_ACTIVE,2*60*60,DNS,addr,
- True,True);
+ int name_type = question->name_type;
+ char *qname = question->name;
+
+ if (!addr.s_addr) {
+ /* add the fail to WINS cache of names. give it 1 hour in the cache */
+ DEBUG(3,("Negative DNS answer for %s\n", qname));
+ add_netbios_entry(wins_client_subnet,qname,name_type,NB_ACTIVE,60*60,
+ DNSFAIL,addr,True);
+ return NULL;
+ }
+
+ /* add it to our WINS cache of names. give it 2 hours in the cache */
+ DEBUG(3,("DNS gave answer for %s of %s\n", qname, inet_ntoa(addr)));
+
+ return add_netbios_entry(wins_client_subnet,qname,name_type,NB_ACTIVE,
+ 2*60*60,DNS,addr, True);
}
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 5feeb07c90..d53ec8c2e0 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -283,8 +283,8 @@ static void load_hosts_file(char *fname)
ipaddr = *interpret_addr2(ip);
d = find_subnet_all(ipaddr);
if (d) {
- add_netbios_entry(d,name,0x00,NB_ACTIVE,0,source,ipaddr,True,True);
- add_netbios_entry(d,name,0x20,NB_ACTIVE,0,source,ipaddr,True,True);
+ add_netbios_entry(d,name,0x00,NB_ACTIVE,0,source,ipaddr,True);
+ add_netbios_entry(d,name,0x20,NB_ACTIVE,0,source,ipaddr,True);
}
}
diff --git a/source3/nmbsync.c b/source3/nmbsync.c
index b4a40518cf..e0c36d5961 100644
--- a/source3/nmbsync.c
+++ b/source3/nmbsync.c
@@ -147,7 +147,7 @@ void sync_browse_lists(struct subnet_record *d, struct work_record *work,
if (!d || !work ) return;
- if(d != wins_subnet) {
+ if(d != wins_client_subnet) {
DEBUG(0,
("sync_browse_lists: ERROR sync requested on non-WINS subnet.\n"));
return;
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index d67247481f..20c1a1c1b7 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -2453,6 +2453,8 @@ max can be %d\n", num_interfaces, FD_SETSIZE));
if(FD_ISSET(fd_listenset[i],&lfds))
{
s = fd_listenset[i];
+ /* Clear this so we don't look at it again. */
+ FD_CLR(fd_listenset[i],&lfds);
break;
}
}