summaryrefslogtreecommitdiff
path: root/source3/namedbwork.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/namedbwork.c')
-rw-r--r--source3/namedbwork.c120
1 files changed, 56 insertions, 64 deletions
diff --git a/source3/namedbwork.c b/source3/namedbwork.c
index 04f2103254..172a93860c 100644
--- a/source3/namedbwork.c
+++ b/source3/namedbwork.c
@@ -26,6 +26,9 @@
04 jul 96: lkcl@pires.co.uk
created module namedbwork containing workgroup database functions
+ 30 July 96: David.Chappell@mail.trincoll.edu
+ Expanded multiple workgroup domain master browser support.
+
*/
#include "includes.h"
@@ -40,9 +43,7 @@ extern struct subnet_record *subnetlist;
extern struct in_addr ipgrp;
-int workgroup_count = 0; /* unique index key: one for each workgroup */
-
-
+extern pstring myname;
/****************************************************************************
add a workgroup into the domain list
@@ -75,11 +76,17 @@ static void add_workgroup(struct work_record *work, struct subnet_record *d)
static struct work_record *make_workgroup(char *name)
{
struct work_record *work;
- struct subnet_record *d;
int t = -1;
if (!name || !name[0]) return NULL;
+ /* conf_workgroup_name_to_token() gets or creates a unique index for the workgroup name */
+ if ((t = conf_workgroup_name_to_token(name, myname)) == -1)
+ {
+ DEBUG(3, ("work_record(\"%s\"): conf_workgroup_name_to_token() refuses to allow workgroup\n", name));
+ return (struct work_record *)NULL;
+ }
+
work = (struct work_record *)malloc(sizeof(*work));
if (!work) return(NULL);
@@ -92,34 +99,16 @@ static struct work_record *make_workgroup(char *name)
work->needelection = False;
work->needannounce = True;
work->state = MST_NONE;
-
- /* make sure all token representations of workgroups are unique */
-
- for (d = subnetlist; d && t == -1; d = d->next)
- {
- struct work_record *w;
- for (w = d->workgrouplist; w && t == -1; w = w->next)
- {
- if (strequal(w->work_group, work->work_group)) t = w->token;
- }
- }
-
- if (t == -1)
- {
- work->token = ++workgroup_count;
- }
- else
- {
- work->token = t;
- }
-
+ work->token = t;
/* WfWg uses 01040b01 */
/* Win95 uses 01041501 */
/* NTAS uses ???????? */
work->ElectionCriterion = (MAINTAIN_LIST<<1)|(ELECTION_VERSION<<8);
work->ElectionCriterion |= (lp_os_level() << 24);
- if (lp_domain_master()) {
+
+ if (conf_should_domain_master(work->token))
+ {
work->ElectionCriterion |= 0x80;
}
@@ -131,8 +120,8 @@ static struct work_record *make_workgroup(char *name)
remove workgroups
******************************************************************/
struct work_record *remove_workgroup(struct subnet_record *d,
- struct work_record *work,
- BOOL remove_all_servers)
+ struct work_record *work,
+ BOOL remove_all_servers)
{
struct work_record *ret_work = NULL;
@@ -165,7 +154,7 @@ struct work_record *remove_workgroup(struct subnet_record *d,
lmhosts file to be added.
**************************************************************************/
struct work_record *find_workgroupstruct(struct subnet_record *d,
- fstring name, BOOL add)
+ fstring name, BOOL add)
{
struct work_record *ret, *work;
@@ -174,23 +163,26 @@ struct work_record *find_workgroupstruct(struct subnet_record *d,
DEBUG(4, ("workgroup search for %s: ", name));
if (strequal(name, "*"))
- {
+ {
DEBUG(2,("add any workgroups: initiating browser search on %s\n",
- inet_ntoa(d->bcast_ip)));
+ inet_ntoa(d->bcast_ip)));
queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY, NAME_QUERY_FIND_MST,
- MSBROWSE,0x1,0,0,0,NULL,NULL,
- True,False, d->bcast_ip, d->bcast_ip);
+ -1,MSBROWSE,0x1,0,0,0,NULL,NULL,
+ True,False, d->bcast_ip, d->bcast_ip);
return NULL;
- }
+ }
- for (ret = d->workgrouplist; ret; ret = ret->next) {
- if (!strcmp(ret->work_group,name)) {
+ for (ret = d->workgrouplist; ret; ret = ret->next)
+ {
+ if (!strcmp(ret->work_group,name))
+ {
DEBUG(4, ("found\n"));
return(ret);
}
}
- if (!add) {
+ if (!add)
+ {
DEBUG(4, ("not found\n"));
return NULL;
}
@@ -200,13 +192,13 @@ struct work_record *find_workgroupstruct(struct subnet_record *d,
if ((work = make_workgroup(name)))
{
if (!ip_equal(d->bcast_ip, ipgrp) &&
- lp_preferred_master() &&
- strequal(lp_workgroup(), name))
- {
- DEBUG(3, ("preferred master startup for %s\n", work->work_group));
- work->needelection = True;
- work->ElectionCriterion |= (1<<3);
- }
+ lp_preferred_master() &&
+ conf_should_local_master(work->token))
+ {
+ DEBUG(3, ("preferred master startup for %s\n", work->work_group));
+ work->needelection = True;
+ work->ElectionCriterion |= (1<<3);
+ }
add_workgroup(work, d);
return(work);
}
@@ -224,25 +216,25 @@ void dump_workgroups(void)
for (d = subnetlist; d; d = d->next)
{
if (d->workgrouplist)
- {
- struct work_record *work;
-
- DEBUG(4,("dump domain bcast=%15s: ", inet_ntoa(d->bcast_ip)));
- DEBUG(4,(" netmask=%15s:\n", inet_ntoa(d->mask_ip)));
-
- for (work = d->workgrouplist; work; work = work->next)
- {
- DEBUG(4,("\t%s(%d)\n", work->work_group, work->token));
- if (work->serverlist)
- {
- struct server_record *s;
- for (s = work->serverlist; s; s = s->next)
- {
- DEBUG(4,("\t\t%s %8x (%s)\n",
- s->serv.name, s->serv.type, s->serv.comment));
- }
- }
- }
- }
+ {
+ struct work_record *work;
+
+ DEBUG(4,("dump domain bcast=%15s: ", inet_ntoa(d->bcast_ip)));
+ DEBUG(4,(" netmask=%15s:\n", inet_ntoa(d->mask_ip)));
+
+ for (work = d->workgrouplist; work; work = work->next)
+ {
+ DEBUG(4,("\t%s(%d)\n", work->work_group, work->token));
+ if (work->serverlist)
+ {
+ struct server_record *s;
+ for (s = work->serverlist; s; s = s->next)
+ {
+ DEBUG(4,("\t\t%s %8x (%s)\n",
+ s->serv.name, s->serv.type, s->serv.comment));
+ }
+ }
+ }
+ }
}
}