summaryrefslogtreecommitdiffstats
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
commit2c97b33fc0b5ef181dbf51a50cb61074935165bf (patch)
tree940f8da80d7ea3fe4941d7e03ebbfa4f69b82472
parent25560cf40b997e400d16fa0c1380e5bc29c015a5 (diff)
downloadsamba-2c97b33fc0b5ef181dbf51a50cb61074935165bf.tar.gz
samba-2c97b33fc0b5ef181dbf51a50cb61074935165bf.tar.xz
samba-2c97b33fc0b5ef181dbf51a50cb61074935165bf.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)
-rw-r--r--source/include/nameserv.h11
-rw-r--r--source/include/proto.h20
-rw-r--r--source/lib/interface.c14
-rw-r--r--source/nameannounce.c154
-rw-r--r--source/namebrowse.c2
-rw-r--r--source/namedbname.c106
-rw-r--r--source/namedbsubnet.c44
-rw-r--r--source/nameelect.c11
-rw-r--r--source/namepacket.c11
-rw-r--r--source/nameresp.c7
-rw-r--r--source/nameserv.c145
-rw-r--r--source/nameservreply.c98
-rw-r--r--source/nameservresp.c11
-rw-r--r--source/namework.c6
-rw-r--r--source/nmbd/asyncdns.c32
-rw-r--r--source/nmbd/nmbd.c4
-rw-r--r--source/nmbsync.c2
-rw-r--r--source/smbd/server.c2
18 files changed, 309 insertions, 371 deletions
diff --git a/source/include/nameserv.h b/source/include/nameserv.h
index 5c8ec1e4ebd..2a7bb290709 100644
--- a/source/include/nameserv.h
+++ b/source/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/source/include/proto.h b/source/include/proto.h
index 96c4779e622..603399758f2 100644
--- a/source/include/proto.h
+++ b/source/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/source/lib/interface.c b/source/lib/interface.c
index c920cc0cfcf..3b038dcda69 100644
--- a/source/lib/interface.c
+++ b/source/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/source/nameannounce.c b/source/nameannounce.c
index b8dcb71fffd..ef23e87e58d 100644
--- a/source/nameannounce.c
+++ b/source/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/source/namebrowse.c b/source/namebrowse.c
index ae5f00ce10e..c0deaff0fae 100644
--- a/source/namebrowse.c
+++ b/source/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/source/namedbname.c b/source/namedbname.c
index f126b4651c9..6ff20f4d45c 100644
--- a/source/namedbname.c
+++ b/source/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/source/namedbsubnet.c b/source/namedbsubnet.c
index 3597c323875..27c1a0470e3 100644
--- a/source/namedbsubnet.c
+++ b/source/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/source/nameelect.c b/source/nameelect.c
index 215ee94febb..391320e84f8 100644
--- a/source/nameelect.c
+++ b/source/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/source/namepacket.c b/source/namepacket.c
index 5b3f06f16db..626e50b788a 100644
--- a/source/namepacket.c
+++ b/source/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/source/nameresp.c b/source/nameresp.c
index 81624fcaf1b..de1f33c7172 100644
--- a/source/nameresp.c
+++ b/source/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/source/nameserv.c b/source/nameserv.c
index a90b41f834c..a05db3983ec 100644
--- a/source/nameserv.c
+++ b/source/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/source/nameservreply.c b/source/nameservreply.c
index 6585a022611..d1cbbb026d5 100644
--- a/source/nameservreply.c
+++ b/source/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/source/nameservresp.c b/source/nameservresp.c
index 61e4a835f46..3349610da6e 100644
--- a/source/nameservresp.c
+++ b/source/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/source/namework.c b/source/namework.c
index 2de4a3016f7..540aec5bfea 100644
--- a/source/namework.c
+++ b/source/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/source/nmbd/asyncdns.c b/source/nmbd/asyncdns.c
index 548781edeab..94fd65b147a 100644
--- a/source/nmbd/asyncdns.c
+++ b/source/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/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index 5feeb07c90d..d53ec8c2e0c 100644
--- a/source/nmbd/nmbd.c
+++ b/source/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/source/nmbsync.c b/source/nmbsync.c
index b4a40518cfa..e0c36d59615 100644
--- a/source/nmbsync.c
+++ b/source/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/source/smbd/server.c b/source/smbd/server.c
index d67247481ff..20c1a1c1b78 100644
--- a/source/smbd/server.c
+++ b/source/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;
}
}