summaryrefslogtreecommitdiff
path: root/source3/nameservreply.c
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1996-08-01 17:49:40 +0000
committerSamba Release Account <samba-bugs@samba.org>1996-08-01 17:49:40 +0000
commit3ffb30e8be5bcddca9d0489e1993085a4995c3af (patch)
treea36a093e5ede9021bc01ca5d50cae3d82ac3bbea /source3/nameservreply.c
parent9bf446124b5ad991e071f92eeabcbb838eb9f50b (diff)
downloadsamba-3ffb30e8be5bcddca9d0489e1993085a4995c3af.tar.gz
samba-3ffb30e8be5bcddca9d0489e1993085a4995c3af.tar.bz2
samba-3ffb30e8be5bcddca9d0489e1993085a4995c3af.zip
local_only NetServerEnum syncs can now be issued.
bug spotted in nameservresp.c - arguments to test subnet the response is received on (same_net()) were the wrong way round (ccm@shentel.net) samba was adding WORKGROUP(1e) as a unique not a group name: fixed this bug in reply_name_status() and reply_name_query(): WINS entries weren't being looked up. name status reply adds local SELF entries to WINS SELF entries: some SELF entries are only added locally, while others are only added via WINS. name status needs to have both, combined. a sync will only occur when an ANN_LocalMasterAnnouncement is received, NOT an ANN_HostAnnouncement or an ANN_DomainAnnouncement. when samba is a member of a workgroup, it looks for (using a wins server) and announces to its domain master. NAME_QUERY_ANNOUNCE_HOST - yet another 'state' - has been created to do this: do the name query on the wins server and send the announce host to the answer to this query. jeremy @ vantive wrote the original code to do this, which used the name_query() function. i'm trying to avoid name_query: it times out and generally messes things up, but using queue_netbios_packet() and queue_netbios_pkt_wins() is... not intuitive? lkcl with help from jra (This used to be commit 6e932e4bae8b46e7ff4a55a75484bad78308336a)
Diffstat (limited to 'source3/nameservreply.c')
-rw-r--r--source3/nameservreply.c103
1 files changed, 60 insertions, 43 deletions
diff --git a/source3/nameservreply.c b/source3/nameservreply.c
index 84b9277d60..5b45e88c5e 100644
--- a/source3/nameservreply.c
+++ b/source3/nameservreply.c
@@ -294,7 +294,8 @@ void reply_name_reg(struct packet_struct *p)
/* initiate some enquiries to the current owner. */
queue_netbios_packet(d,ClientNMB,NMB_QUERY,
NAME_REGISTER_CHALLENGE,
- reply_name->name,reply_name->name_type,nb_flags,0,
+ reply_name->name,reply_name->name_type,
+ nb_flags,0,0,NULL,NULL,
False, False, n->ip, p->ip);
}
else
@@ -311,8 +312,11 @@ void reply_name_reg(struct packet_struct *p)
/****************************************************************************
-reply to a name status query
-****************************************************************************/
+ reply to a name status query
+
+ combine the list of the local interface on which the query was made with
+ the names registered via wins.
+ ****************************************************************************/
void reply_name_status(struct packet_struct *p)
{
struct nmb_packet *nmb = &p->packet.nmb;
@@ -323,7 +327,7 @@ void reply_name_status(struct packet_struct *p)
int names_added;
struct name_record *n;
struct subnet_record *d = NULL;
- int search = FIND_SELF;
+ int search = FIND_SELF | FIND_WINS;
BOOL bcast = nmb->header.nm_flags.bcast;
@@ -338,8 +342,6 @@ void reply_name_status(struct packet_struct *p)
namestr(&nmb->question.question_name), inet_ntoa(p->ip)));
if (bcast)
- search |= FIND_WINS;
- else
search |= FIND_LOCAL;
n = find_name_search(&d, &nmb->question.question_name,
@@ -353,38 +355,55 @@ void reply_name_status(struct packet_struct *p)
buf += 1;
names_added = 0;
-
- for (n = d->namelist ; n && buf < bufend; n = n->next)
+
+ n = d->namelist;
+
+ while (buf < bufend)
+ {
+ if (n->source == SELF)
{
int name_type = n->name.name_type;
- if (n->source != SELF) continue;
-
- /* start with first bit of putting info in buffer: the name */
-
- bzero(buf,18);
- sprintf(buf,"%-15.15s",n->name.name);
- strupper(buf);
-
- /* now check if we want to exclude other workgroup names
- from the response. if we don't exclude them, windows clients
- get confused and will respond with an error for NET VIEW */
-
- if (name_type >= 0x1b && name_type <= 0x20 &&
- ques_type >= 0x1b && ques_type <= 0x20)
- {
- if (!strequal(qname, n->name.name)) continue;
- }
-
- /* carry on putting name info in buffer */
+ /* check if we want to exclude other workgroup names
+ from the response. if we don't exclude them, windows clients
+ get confused and will respond with an error for NET VIEW */
- buf[15] = name_type;
- buf[16] = n->nb_flags;
+ if (name_type < 0x1b || name_type > 0x20 ||
+ ques_type < 0x1b || ques_type > 0x20 ||
+ strequal(qname, n->name.name))
+ {
+ /* start with first bit of putting info in buffer: the name */
+ bzero(buf,18);
+ sprintf(buf,"%-15.15s",n->name.name);
+ strupper(buf);
+
+ /* put name type and netbios flags in buffer */
+ buf[15] = name_type;
+ buf[16] = n->nb_flags;
+
+ buf += 18;
- buf += 18;
-
- names_added++;
+ names_added++;
+ }
}
+
+ n = n->next;
+
+ if (!n)
+ {
+ /* end of this name list: add wins names too? */
+ struct subnet_record *w_d;
+
+ if (!(w_d = find_subnet(ipgrp))) break;
+
+ if (w_d != d)
+ {
+ d = w_d;
+ n = d->namelist; /* start on the wins name list */
+ }
+ }
+ if (!n) break;
+ }
SCVAL(countptr,0,names_added);
@@ -396,9 +415,7 @@ void reply_name_status(struct packet_struct *p)
SIVAL(buf,24,num_good_receives);
}
- SIVAL(buf,46,0xFFB8E5); /* undocumented - used by NT */
-
- buf += 64;
+ buf += 46;
/* Send a POSITIVE NAME STATUS RESPONSE */
reply_netbios_packet(p,nmb->header.name_trn_id,
@@ -451,14 +468,13 @@ void reply_name_query(struct packet_struct *p)
struct name_record *n;
/* directed queries are for WINS server: broadcasts are local SELF queries.
- the exception is PDC names. */
+ the exception is Domain Master names. */
int search = bcast ? FIND_LOCAL | FIND_SELF : FIND_WINS;
- if (name_type == 0x1b)
+ if (name_type == 0x1b || name_type == 0x0 || name_type == 0x20)
{
- /* even if it's a broadcast, we don't ignore queries for PDC names */
- search = FIND_WINS;
+ search |= FIND_WINS;
}
if (search | FIND_LOCAL)
@@ -500,10 +516,11 @@ void reply_name_query(struct packet_struct *p)
}
}
- /* name is directed query, or it's self, or it's a PDC type name, or
- we're replying on behalf of a caller because they are on a different
- subnet and cannot hear the broadcast. XXXX lp_wins_proxy should be
- switched off in environments where broadcasts are forwarded */
+ /* name is directed query, or it's self, or it's a Domain Master type
+ name, or we're replying on behalf of a caller because they are on a
+ different subnet and cannot hear the broadcast. XXXX lp_wins_proxy
+ should be switched off in environments where broadcasts are forwarded
+ */
/* XXXX note: for proxy servers, we should forward the query on to
another WINS server if the name is not in our database, or we are