summaryrefslogtreecommitdiffstats
path: root/source/nameannounce.c
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1997-05-08 01:14:17 +0000
committerSamba Release Account <samba-bugs@samba.org>1997-05-08 01:14:17 +0000
commitcf23a155a1315f50d488794a2caf88402bf3e3e6 (patch)
tree7066d72c0f3a330f0cdcfe275ba3584a93e49606 /source/nameannounce.c
parent285769003af6366167f80019c6845bfe3b6a8da4 (diff)
downloadsamba-cf23a155a1315f50d488794a2caf88402bf3e3e6.tar.gz
samba-cf23a155a1315f50d488794a2caf88402bf3e3e6.tar.xz
samba-cf23a155a1315f50d488794a2caf88402bf3e3e6.zip
'The mother of all checkins' :-). Jeremy Allison (jallison@whistle.com)
Wed May 7 1997: Update for 1.9.17alpha1 release - 'browsefix release' designed to make browsing across subnets work. byteorder.h: Updated copyright to 1997. charcnv.c: Updated copyright to 1997. charset.c Updated copyright to 1997. charset.h Updated copyright to 1997. client.c Updated copyright to 1997. clientutil.c Updated copyright to 1997. dir.c Updated copyright to 1997. fault.c Updated copyright to 1997. includes.h Updated copyright to 1997. interface.c Updated copyright to 1997. ipc.c Updated copyright to 1997. kanji.c Updated copyright to 1997. kanji.h Updated copyright to 1997. loadparm.c Updated copyright to 1997. locking.c Updated copyright to 1997. mangle.c Updated copyright to 1997. message.c Updated copyright to 1997. nameannounce.c Made use of WINS subnet explicit. Added reset_announce_timer() so announcement can be made immediately when we become a master. Expanded code to do sync with dmb. namebrowse.c Removed redundent checks for AM_MASTER in sync code. Made use of WINS subnet explicit. namedbname.c Made use of WINS subnet explicit. namedbresp.c Made use of WINS subnet explicit. namedbserver.c Made use of WINS subnet explicit. namedbsubnet.c Explicitly add workgroup to WINS subnet when we become a dmb. Made use of WINS subnet explicit. namedbwork.c Made use of WINS subnet explicit. Removed redundent check_work_servertype() function. nameelect.c Explicitly add workgroup to WINS subnet when we become a master browser. Made use of WINS subnet explicit. namelogon.c Updated copyright to 1997. namepacket.c Updated copyright to 1997. namequery.c Updated copyright to 1997. nameresp.c Made use of WINS subnet explicit. Made nmbd fail if configured as master browser and one exists already. nameserv.c Made use of WINS subnet explicit. Remove redundent logon server and domain master code. nameserv.h Add emumerate subnet macros. nameservreply.c Made use of WINS subnet explicit. nameservresp.c Updated copyright to 1997. namework.c Made use of WINS subnet explicit. Updated code to add sync browser entries to add subnet parameter. nmbd.c Added sanity check for misconfigured nmbd. nmblib.c Updated copyright to 1997. nmblookup.c Updated copyright to 1997. nmbsync.c Removed redundent AM_ANY_MASTER check. params.c Updated copyright to 1997. password.c Updated copyright to 1997. pipes.c Updated copyright to 1997. predict.c Updated copyright to 1997. printing.c Updated copyright to 1997. proto.h Changed protos for new nmbd code. quotas.c Updated copyright to 1997. replace.c Updated copyright to 1997. reply.c Updated copyright to 1997. server.c Updated copyright to 1997. shmem.c Updated copyright to 1997. smb.h Updated copyright to 1997. smbencrypt.c Updated copyright to 1997. smbpasswd.c Updated copyright to 1997. smbrun.c Updated copyright to 1997. status.c Updated copyright to 1997. system.c Updated copyright to 1997. testparm.c Updated copyright to 1997. testprns.c Updated copyright to 1997. time.c Updated copyright to 1997. trans2.c Updated copyright to 1997. trans2.h Updated copyright to 1997. uid.c Updated copyright to 1997. username.c Updated copyright to 1997. util.c Updated copyright to 1997. version.h Changed to 1.9.17alpha1.
Diffstat (limited to 'source/nameannounce.c')
-rw-r--r--source/nameannounce.c190
1 files changed, 119 insertions, 71 deletions
diff --git a/source/nameannounce.c b/source/nameannounce.c
index 8f2005a73d7..b46436168c3 100644
--- a/source/nameannounce.c
+++ b/source/nameannounce.c
@@ -2,7 +2,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
NBT netbios routines and daemon - version 2
- Copyright (C) Andrew Tridgell 1994-1995
+ Copyright (C) Andrew Tridgell 1994-1997
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ extern int workgroup_count;
extern struct in_addr wins_ip;
-
+extern pstring scope;
/****************************************************************************
send a announce request to the local net
@@ -119,12 +119,13 @@ void do_announce_request(char *info, char *to_name, int announce_type,
**************************************************************************/
void sync_server(enum state_type state, char *serv_name, char *work_name,
int name_type,
+ struct subnet_record *d,
struct in_addr ip)
{
/* with a domain master we can get the whole list (not local only list) */
BOOL local_only = (state != NAME_STATUS_DOM_SRV_CHK);
- add_browser_entry(serv_name, name_type, work_name, 0, ip, local_only);
+ add_browser_entry(serv_name, name_type, work_name, 0, d, ip, local_only);
if (state == NAME_STATUS_DOM_SRV_CHK)
{
@@ -189,7 +190,7 @@ void do_announce_host(int command,
void remove_my_servers(void)
{
struct subnet_record *d;
- for (d = subnetlist; d; d = d->next)
+ for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_EXCLUDING_WINS(d))
{
struct work_record *work;
for (work = d->workgrouplist; work; work = work->next)
@@ -228,7 +229,7 @@ void announce_server(struct subnet_record *d, struct work_record *work,
if (!lp_wins_support() && *lp_wins_server())
{
/* look up the domain master with the WINS server */
- queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY,
+ queue_netbios_pkt_wins(ClientNMB,NMB_QUERY,
NAME_QUERY_ANNOUNCE_HOST,
work->work_group,0x1b,0,ttl*1000,
server_type,name,comment,
@@ -305,12 +306,10 @@ void announce_host(time_t t)
my_name = *myname ? myname : "NoName";
- for (d = subnetlist; d; d = d->next)
+ for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_EXCLUDING_WINS(d))
{
struct work_record *work;
- if (ip_equal(d->bcast_ip, wins_ip)) continue;
-
for (work = d->workgrouplist; work; work = work->next)
{
uint32 stype = work->ServerType;
@@ -362,6 +361,19 @@ void announce_host(time_t t)
}
}
+/* Announce timer. Moved into global static so it can be reset
+ when a machine becomes a master browser. */
+static time_t announce_timer_last=0;
+
+/****************************************************************************
+ Reset the announce_timer so that a master browser announce will be done
+ immediately.
+ ****************************************************************************/
+
+void reset_announce_timer()
+{
+ announce_timer_last = 0;
+}
/****************************************************************************
announce myself as a master to all other domain master browsers.
@@ -373,16 +385,26 @@ void announce_host(time_t t)
void announce_master(time_t t)
{
struct subnet_record *d;
- static time_t last=0;
+ struct work_record *work;
BOOL am_master = False; /* are we a master of some sort? :-) */
- if (!last) last = t;
- if (t-last < CHECK_TIME_MST_ANNOUNCE * 60)
- return;
+ 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;
+ }
+
+ if(wins_subnet == 0)
+ {
+ DEBUG(10,("announce_master: no wins subnet, ignoring.\n"));
+ return;
+ }
- last = t;
+ announce_timer_last = t;
- for (d = subnetlist; d; d = d->next)
+ for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_EXCLUDING_WINS(d))
{
struct work_record *work;
for (work = d->workgrouplist; work; work = work->next)
@@ -398,69 +420,95 @@ void announce_master(time_t t)
if (!am_master) return; /* only proceed if we are a master browser */
- /* Note that we don't do this if we are domain master browser. */
+ /* Note that we don't do this if we are domain master browser
+ and that we *only* do this on the WINS subnet. */
+
+ /* Try and find our workgroup on the WINS subnet */
+ work = find_workgroupstruct(wins_subnet, lp_workgroup(), False);
- for (d = subnetlist; d; d = d->next)
+ if (work)
{
- /* Try and find our workgroup on this subnet */
- struct work_record *work = find_workgroupstruct(d, lp_workgroup(), False);
+ char *name;
+ int type;
- if (work)
+ if (*lp_domain_controller())
{
- char *name;
- int type;
-
- if (*lp_domain_controller())
- {
- /* the domain controller option is used to manually specify
- the domain master browser to sync with
- */
-
- /* XXXX i'm not sure we should be using the domain controller
- option for this purpose.
- */
-
- name = lp_domain_controller();
- type = 0x20;
- }
- else
- {
- /* 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
+ /* the domain controller option is used to manually specify
+ the domain master browser to sync with
*/
- if (!lp_wins_support() && *lp_wins_server() &&
- ip_equal(d->bcast_ip, wins_ip))
- {
- DEBUG(4, ("Local Announce: find %s<%02x> from WINS server %s\n",
- name, type, lp_wins_server()));
-
- queue_netbios_pkt_wins(d,ClientNMB,
- NMB_QUERY,NAME_QUERY_DOM_SRV_CHK,
- name, type, 0,0,0,
- work->work_group,NULL,
- False, False, ipzero, ipzero);
- }
- else
- {
- DEBUG(4, ("Local Announce: find %s<%02x> on %s\n",
- name, type, inet_ntoa(d->bcast_ip)));
-
- queue_netbios_packet(d,ClientNMB,
- NMB_QUERY,NAME_QUERY_DOM_SRV_CHK,
- name, type, 0,0,0,
- work->work_group,NULL,
- True, False, d->bcast_ip, d->bcast_ip);
- }
- }
+ /* XXXX i'm not sure we should be using the domain controller
+ option for this purpose.
+ */
+
+ name = lp_domain_controller();
+ type = 0x20;
+ }
+ else
+ {
+ /* 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,
+ False, False, ipzero, ipzero);
+ }
+ else if(lp_wins_support())
+ {
+ /* We are the WINS server - query ourselves for the dmb name. */
+
+ struct nmb_name netb_name;
+ struct subnet_record *d = 0;
+ struct name_record *nr = 0;
+
+ 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 \
+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))
+ {
+ 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;
+ }
+
+ /* 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 \
+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);
+ }
+
}
}