summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_incomingdgrams.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1997-12-24 08:49:44 +0000
committerJeremy Allison <jra@samba.org>1997-12-24 08:49:44 +0000
commit5cdb60bd93fcf97fa9ee1c42642237eb7d4c2083 (patch)
treea25a261c11d94aac922f4ba0c6346e7215e95010 /source3/nmbd/nmbd_incomingdgrams.c
parent0c0777400fd4a2e0586761514345153c9ee218ed (diff)
downloadsamba-5cdb60bd93fcf97fa9ee1c42642237eb7d4c2083.tar.gz
samba-5cdb60bd93fcf97fa9ee1c42642237eb7d4c2083.tar.bz2
samba-5cdb60bd93fcf97fa9ee1c42642237eb7d4c2083.zip
nmbd_elections.c: Added new parameter to dump_workgroups call.
nmbd_incomingdgrams.c: Deal with announcements with servertype == 0 - these are announcements that a machine is shutting down and must be treated differently. nmbd_serverlistdb.c: Exposed remove_server_from_workgroup as external. Added code to dump out workgroups on signal correctly. nmbd_workgroupdb.c: Added new parameter to dump_workgroups call. Jeremy. (This used to be commit f7591109b968c66012af5e9fe818bba8e6f1cf23)
Diffstat (limited to 'source3/nmbd/nmbd_incomingdgrams.c')
-rw-r--r--source3/nmbd/nmbd_incomingdgrams.c139
1 files changed, 97 insertions, 42 deletions
diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c
index 7133d5ebfb..2396c847a3 100644
--- a/source3/nmbd/nmbd_incomingdgrams.c
+++ b/source3/nmbd/nmbd_incomingdgrams.c
@@ -153,28 +153,45 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
* announce instead ? JRA.
*/
- if ((work = find_workgroup_on_subnet(subrec, work_name))==NULL)
+ work = find_workgroup_on_subnet(subrec, work_name);
+
+ if(servertype != 0)
{
- /* We have no record of this workgroup. Add it. */
- if((work = create_workgroup_on_subnet(subrec, work_name, ttl))==NULL)
- return;
- }
+ if (work ==NULL )
+ {
+ /* We have no record of this workgroup. Add it. */
+ if((work = create_workgroup_on_subnet(subrec, work_name, ttl))==NULL)
+ return;
+ }
- if((servrec = find_server_in_workgroup( work, announce_name))==NULL)
- {
- /* If this server is not already in the workgroup, add it. */
- create_server_on_workgroup(work, announce_name,
- servertype|SV_TYPE_LOCAL_LIST_ONLY,
- ttl, comment);
+ if((servrec = find_server_in_workgroup( work, announce_name))==NULL)
+ {
+ /* If this server is not already in the workgroup, add it. */
+ create_server_on_workgroup(work, announce_name,
+ servertype|SV_TYPE_LOCAL_LIST_ONLY,
+ ttl, comment);
+ }
+ else
+ {
+ /* Update the record. */
+ servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
+ update_server_ttl( servrec, ttl);
+ StrnCpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment)-1);
+ }
}
else
{
- /* Update the record. */
- servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
- update_server_ttl( servrec, ttl);
- StrnCpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment)-1);
+ /*
+ * This server is announcing it is going down. Remove it from the
+ * workgroup.
+ */
+ if(!is_myname(announce_name) && (work != NULL) &&
+ ((servrec = find_server_in_workgroup( work, announce_name))!=NULL)
+ )
+ {
+ remove_server_from_workgroup( work, servrec);
+ }
}
-
subrec->work_changed = True;
}
@@ -272,6 +289,10 @@ void process_local_master_announce(struct subnet_record *subrec, struct packet_s
if ((work = find_workgroup_on_subnet(subrec, work_name))==NULL)
{
+ /* Don't bother adding if it's a local master release announce. */
+ if(servertype == 0)
+ return;
+
/* We have no record of this workgroup. Add it. */
if((work = create_workgroup_on_subnet(subrec, work_name, ttl))==NULL)
return;
@@ -308,23 +329,39 @@ a local master browser for workgroup %s and we think we are master. Forcing elec
/* Find the server record on this workgroup. If it doesn't exist, add it. */
- if((servrec = find_server_in_workgroup( work, server_name))==NULL)
+ if(servertype != 0)
{
- /* If this server is not already in the workgroup, add it. */
- create_server_on_workgroup(work, server_name,
- servertype|SV_TYPE_LOCAL_LIST_ONLY,
- ttl, comment);
+ if((servrec = find_server_in_workgroup( work, server_name))==NULL)
+ {
+ /* If this server is not already in the workgroup, add it. */
+ create_server_on_workgroup(work, server_name,
+ servertype|SV_TYPE_LOCAL_LIST_ONLY,
+ ttl, comment);
+ }
+ else
+ {
+ /* Update the record. */
+ servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
+ update_server_ttl(servrec, ttl);
+ StrnCpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment)-1);
+ }
+
+ set_workgroup_local_master_browser_name( work, server_name );
}
else
{
- /* Update the record. */
- servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
- update_server_ttl(servrec, ttl);
- StrnCpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment)-1);
+ /*
+ * This server is announcing it is going down. Remove it from the
+ * workgroup.
+ */
+ if(!is_myname(server_name) && (work != NULL) &&
+ ((servrec = find_server_in_workgroup( work, server_name))!=NULL)
+ )
+ {
+ remove_server_from_workgroup( work, servrec);
+ }
}
- set_workgroup_local_master_browser_name( work, server_name );
-
subrec->work_changed = True;
}
@@ -454,26 +491,44 @@ void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct
* announce instead ? JRA.
*/
- if ((work = find_workgroup_on_subnet(subrec, work_name))==NULL)
- {
- /* We have no record of this workgroup. Add it. */
- if((work = create_workgroup_on_subnet(subrec, work_name, ttl))==NULL)
- return;
- }
+ work = find_workgroup_on_subnet(subrec, work_name);
- if((servrec = find_server_in_workgroup( work, announce_name))==NULL)
+ if(servertype != 0)
{
- /* If this server is not already in the workgroup, add it. */
- create_server_on_workgroup(work, announce_name,
- servertype|SV_TYPE_LOCAL_LIST_ONLY,
- ttl, comment);
+ if (work == NULL)
+ {
+ /* We have no record of this workgroup. Add it. */
+ if((work = create_workgroup_on_subnet(subrec, work_name, ttl))==NULL)
+ return;
+ }
+
+ if((servrec = find_server_in_workgroup( work, announce_name))==NULL)
+ {
+ /* If this server is not already in the workgroup, add it. */
+ create_server_on_workgroup(work, announce_name,
+ servertype|SV_TYPE_LOCAL_LIST_ONLY,
+ ttl, comment);
+ }
+ else
+ {
+ /* Update the record. */
+ servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
+ update_server_ttl( servrec, ttl);
+ StrnCpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment)-1);
+ }
}
else
{
- /* Update the record. */
- servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
- update_server_ttl( servrec, ttl);
- StrnCpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment)-1);
+ /*
+ * This server is announcing it is going down. Remove it from the
+ * workgroup.
+ */
+ if(!is_myname(announce_name) && (work != NULL) &&
+ ((servrec = find_server_in_workgroup( work, announce_name))!=NULL)
+ )
+ {
+ remove_server_from_workgroup( work, servrec);
+ }
}
subrec->work_changed = True;