summaryrefslogtreecommitdiffstats
path: root/source/namedbwork.c
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1996-08-24 01:41:46 +0000
committerSamba Release Account <samba-bugs@samba.org>1996-08-24 01:41:46 +0000
commit8b7fe224bce64803d55ae279fa61ef3ebbbb0241 (patch)
treef48865be5063d823f7bedf49e32077a55c8b0a82 /source/namedbwork.c
parent050f941e21aeb57ab47ac9d29fb4acfceab45087 (diff)
downloadsamba-8b7fe224bce64803d55ae279fa61ef3ebbbb0241.tar.gz
samba-8b7fe224bce64803d55ae279fa61ef3ebbbb0241.tar.xz
samba-8b7fe224bce64803d55ae279fa61ef3ebbbb0241.zip
removed all of lukes recent changes. I need to do a p2 release but
can't test the multi group changes. I also found that some of lukes changes wiped out some recent bug fixes. Is your CVS tree ok luke?
Diffstat (limited to 'source/namedbwork.c')
-rw-r--r--source/namedbwork.c120
1 files changed, 64 insertions, 56 deletions
diff --git a/source/namedbwork.c b/source/namedbwork.c
index 172a93860c2..04f2103254b 100644
--- a/source/namedbwork.c
+++ b/source/namedbwork.c
@@ -26,9 +26,6 @@
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"
@@ -43,7 +40,9 @@ extern struct subnet_record *subnetlist;
extern struct in_addr ipgrp;
-extern pstring myname;
+int workgroup_count = 0; /* unique index key: one for each workgroup */
+
+
/****************************************************************************
add a workgroup into the domain list
@@ -76,17 +75,11 @@ 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);
@@ -99,16 +92,34 @@ static struct work_record *make_workgroup(char *name)
work->needelection = False;
work->needannounce = True;
work->state = MST_NONE;
- work->token = t;
+
+ /* 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;
+ }
+
/* WfWg uses 01040b01 */
/* Win95 uses 01041501 */
/* NTAS uses ???????? */
work->ElectionCriterion = (MAINTAIN_LIST<<1)|(ELECTION_VERSION<<8);
work->ElectionCriterion |= (lp_os_level() << 24);
-
- if (conf_should_domain_master(work->token))
- {
+ if (lp_domain_master()) {
work->ElectionCriterion |= 0x80;
}
@@ -120,8 +131,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;
@@ -154,7 +165,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;
@@ -163,26 +174,23 @@ 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,
- -1,MSBROWSE,0x1,0,0,0,NULL,NULL,
- True,False, d->bcast_ip, d->bcast_ip);
+ 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;
}
@@ -192,13 +200,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() &&
- conf_should_local_master(work->token))
- {
- DEBUG(3, ("preferred master startup for %s\n", work->work_group));
- work->needelection = True;
- work->ElectionCriterion |= (1<<3);
- }
+ 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);
+ }
add_workgroup(work, d);
return(work);
}
@@ -216,25 +224,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));
+ }
+ }
+ }
+ }
}
}