diff options
author | Samba Release Account <samba-bugs@samba.org> | 1996-06-29 18:49:20 +0000 |
---|---|---|
committer | Samba Release Account <samba-bugs@samba.org> | 1996-06-29 18:49:20 +0000 |
commit | 7e8c60cfe54060860e5ce20b1c3b8ec6aa5c54da (patch) | |
tree | 8015d1bd6233a588ea491f44673d726d7d32f7f1 /source/nameelect.c | |
parent | 6d81d56f929e763bcf6b1f7a61aabaf884c4aad4 (diff) | |
download | samba-7e8c60cfe54060860e5ce20b1c3b8ec6aa5c54da.tar.gz samba-7e8c60cfe54060860e5ce20b1c3b8ec6aa5c54da.tar.xz samba-7e8c60cfe54060860e5ce20b1c3b8ec6aa5c54da.zip |
luke's first attempt at using cvs
accidentally updated the Makefile
updated the name database structure (again!). this time, there is one
name database per local interface. there is also a pseudo-interface on
ip 255.255.255.255. its purpose is to store WINS name entries. all the
local interface name databases store SELF names only. the WINS name
database stores non-special browser names.
added wins.dat file: records WINS entries in ascii format. this is reloaded
when nmbd restarts.
added repeating code for response packets. timer is in seconds only at the
moment.
updated the response queue code to deal with samba registering with a
WINS server a bit better (added more cases when a response isn't received).
tidied up the response packet processing code and expire_response_queue()
code. added cross references between response received and await-response
expired code.
added over-zealous code that checks all machines that register with samba
as a WINS server (every 10 minutes i think): to see whether they are still
alive or not (see rfc1001.txt)
bug reported by terry@ren.pc.athabascau.ca: DNSFAILed names _stay_ as
DNSFAIL, even though the machine may come back up and REGISTER.
removed update_from_reg() function. it's not necessary, and it does too much.
added code that announces on each local interface samba's ttl as zero and
servertype as zero when nmbd is kill -TERMed
first attempt at putting the first functionality of samba browsing back in
(remote subnets should have samba appear in a workgroup specified through
the lmhosts file)
lots of other miscellaneous tidying up / chopping about.
Diffstat (limited to 'source/nameelect.c')
-rw-r--r-- | source/nameelect.c | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/source/nameelect.c b/source/nameelect.c index 1832240a116..c841d9b7a60 100644 --- a/source/nameelect.c +++ b/source/nameelect.c @@ -42,8 +42,6 @@ extern pstring ServerComment; extern time_t StartupTime; -#define AM_MASTER(work) (work->ServerType & SV_TYPE_MASTER_BROWSER) - #define BROWSE_MAILSLOT "\\MAILSLOT\\BROWSE" extern struct subnet_record *subnetlist; @@ -61,7 +59,6 @@ void check_master_browser(void) if (!lastrun) lastrun = t; if (t < lastrun + CHECK_TIME_MST_BROWSE * 60) return; - lastrun = t; dump_workgroups(); @@ -77,8 +74,8 @@ void check_master_browser(void) if (!AM_MASTER(work)) { - queue_netbios_packet(ClientNMB,NMB_QUERY,CHECK_MASTER, - work->work_group,0x1d,0, + queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_MST_CHK, + work->work_group,0x1d,0,0, True,False,d->bcast_ip); } } @@ -91,13 +88,13 @@ void check_master_browser(void) ******************************************************************/ void browser_gone(char *work_name, struct in_addr ip) { - struct subnet_record *d = find_domain(ip); + struct subnet_record *d = find_subnet(ip); struct work_record *work = find_workgroupstruct(d, work_name, False); if (!work || !d) return; if (strequal(work->work_group, lp_workgroup()) && - d->my_interface) + ismybcast(d->bcast_ip)) { DEBUG(2,("Forcing election on %s %s\n", @@ -121,6 +118,7 @@ void browser_gone(char *work_name, struct in_addr ip) } } + /**************************************************************************** send an election packet **************************************************************************/ @@ -169,15 +167,16 @@ static void become_master(struct subnet_record *d, struct work_record *work) work->ElectionCriterion |= 0x5; /* add browse, master and general names to database or register with WINS */ - add_name_entry(MSBROWSE ,0x01,NB_ACTIVE|NB_GROUP); - add_name_entry(work->work_group,0x1d,NB_ACTIVE ); + add_my_name_entry(d,MSBROWSE ,0x01,NB_ACTIVE|NB_GROUP); + add_my_name_entry(d,work->work_group,0x1d,NB_ACTIVE ); if (lp_domain_master()) { DEBUG(4,("Domain master: adding names...\n")); /* add domain master and domain member names or register with WINS */ - add_name_entry(work->work_group,0x1b,NB_ACTIVE); + add_my_name_entry(d,work->work_group,0x1b,NB_ACTIVE ); + work->ServerType |= SV_TYPE_DOMAIN_MASTER; if (lp_domain_logons()) @@ -200,21 +199,44 @@ static void become_master(struct subnet_record *d, struct work_record *work) /******************************************************************* - unbecome the master browser + unbecome the master browser. initates removal of necessary netbios + names, and tells the world that we are no longer a master browser. ******************************************************************/ -void become_nonmaster(struct subnet_record *d, struct work_record *work) +void become_nonmaster(struct subnet_record *d, struct work_record *work, + int remove_type) { + int new_server_type = work->ServerType; + DEBUG(2,("Becoming non-master for %s\n",work->work_group)); - work->ServerType &= ~SV_TYPE_MASTER_BROWSER; - work->ServerType &= ~SV_TYPE_DOMAIN_MASTER; - work->ServerType |= SV_TYPE_POTENTIAL_BROWSER; + /* can only remove master or domain types with this function */ + remove_type &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_DOMAIN_MASTER); + + /* unbecome a master browser; unbecome a domain master, too :-( */ + if (remove_type & SV_TYPE_MASTER_BROWSER) + remove_type |= SV_TYPE_DOMAIN_MASTER; + new_server_type &= ~remove_type; + + if (!(new_server_type & (SV_TYPE_MASTER_BROWSER|SV_TYPE_DOMAIN_MASTER))) + { + /* no longer a master browser of any sort */ + + work->ServerType |= SV_TYPE_POTENTIAL_BROWSER; work->ElectionCriterion &= ~0x4; - remove_name_entry(work->work_group,0x1b); - remove_name_entry(work->work_group,0x1d); - remove_name_entry(MSBROWSE ,0x01); + /* announce ourselves as no longer active as a master browser. */ + announce_server(d, work, work->work_group, myname, 0, 0); + remove_name_entry(d,MSBROWSE ,0x01); + } + + work->ServerType = new_server_type; + + if (!(work->ServerType & SV_TYPE_DOMAIN_MASTER)) + remove_name_entry(d,work->work_group,0x1b); + + if (!(work->ServerType & SV_TYPE_DOMAIN_MASTER)) + remove_name_entry(d,work->work_group,0x1d); } @@ -292,7 +314,7 @@ void process_election(struct packet_struct *p,char *buf) { struct dgram_packet *dgram = &p->packet.dgram; struct in_addr ip = dgram->header.source_ip; - struct subnet_record *d = find_domain(ip); + struct subnet_record *d = find_subnet(ip); int version = CVAL(buf,0); uint32 criterion = IVAL(buf,1); int timeup = IVAL(buf,5)/1000; @@ -335,7 +357,8 @@ void process_election(struct packet_struct *p,char *buf) /* if we are the master then remove our masterly names */ if (AM_MASTER(work)) { - become_nonmaster(d, work); + become_nonmaster(d, work, + SV_TYPE_MASTER_BROWSER|SV_TYPE_DOMAIN_MASTER); } } } @@ -355,10 +378,6 @@ BOOL check_elections(void) for (d = subnetlist; d; d = d->next) { struct work_record *work; - - /* we only want to run elections on our own interfaces */ - if (!d->my_interface) continue; - for (work = d->workgrouplist; work; work = work->next) { run_any_election |= work->RunningElection; |