#include "includes.h"
#include "smb.h"
#include "loadparm.h"
-#include "localnet.h"
+
+extern int ClientNMB;
+extern int ClientDGRAM;
extern int DEBUGLEVEL;
extern time_t StartupTime;
extern pstring myname;
extern pstring scope;
-extern struct in_addr bcast_ip;
+
+extern struct in_addr ipgrp;
/* this is our browse master/backup cache database */
struct browse_cache_record *browserlist = NULL;
SV_TYPE_TIME_SOURCE | SV_TYPE_SERVER_UNIX | \
SV_TYPE_PRINTQ_SERVER | SV_TYPE_POTENTIAL_BROWSER)
-/* here are my election parameters */
-#define MSBROWSE "\001\002__MSBROWSE__\002"
-
/****************************************************************************
add a workgroup into the domain list
that it get created/added anyway. this allows us to force entries in
lmhosts file to be added.
**************************************************************************/
-struct work_record *find_workgroupstruct(struct domain_record *d, fstring name, BOOL add)
+struct work_record *find_workgroupstruct(struct domain_record *d,
+ fstring name, BOOL add)
{
struct work_record *ret, *work;
return NULL;
}
- for (ret = d->workgrouplist; ret; ret = ret->next)
- {
- if (!strcmp(ret->work_group,name))
- {
- DEBUG(4, ("found\n"));
- return(ret);
- }
+ for (ret = d->workgrouplist; ret; ret = ret->next) {
+ if (!strcmp(ret->work_group,name)) {
+ DEBUG(4, ("found\n"));
+ return(ret);
}
-
- DEBUG(4, ("not found: creating\n"));
+ }
+
+ if (!add) {
+ DEBUG(4, ("not found\n"));
+ return NULL;
+ }
+
+ DEBUG(4,("not found: creating\n"));
if ((work = make_workgroup(name)))
{
if (lp_preferred_master() &&
strequal(lp_workgroup(), name) &&
- ip_equal(d->bcast_ip, bcast_ip))
+ ismybcast(d->bcast_ip))
{
DEBUG(3, ("preferred master startup for %s\n", work->work_group));
work->needelection = True;
work->ElectionCriterion |= (1<<3);
}
- if (!ip_equal(bcast_ip, d->bcast_ip))
+ if (!ismybcast(d->bcast_ip))
{
work->needelection = False;
}
/****************************************************************************
dump a copy of the workgroup/domain database
**************************************************************************/
-static void dump_workgroups(void)
+void dump_workgroups(void)
{
struct domain_record *d;
struct domain_record *d;
struct in_addr ip;
- ip = *interpret_addr2("255.255.255.255");
+ ip = ipgrp;
- if (zero_ip(source_ip)) source_ip = bcast_ip;
+ if (zero_ip(source_ip))
+ source_ip = *iface_bcast(source_ip);
/* add the domain into our domain database */
if ((d = find_domain(source_ip)) ||
{
struct work_record *w = find_workgroupstruct(d, name, add);
+ if (!w) return NULL;
+
/* add WORKGROUP(1e) and WORKGROUP(00) entries into name database
or register with WINS server, if it's our workgroup */
if (strequal(lp_workgroup(), name))
b->ip = ip;
b->type = type;
- if (newentry || ttl < b->sync_time) b->sync_time = ttl;
+ if (newentry || ttl < b->sync_time)
+ b->sync_time = ttl;
if (newentry)
{
bzero((char *)s,sizeof(*s));
}
- if (ip_equal(bcast_ip, d->bcast_ip) &&
+ if (ismybcast(d->bcast_ip) &&
strequal(lp_workgroup(),work->work_group))
{
- servertype |= SV_TYPE_LOCAL_LIST_ONLY;
+ if (servertype)
+ servertype |= SV_TYPE_LOCAL_LIST_ONLY;
}
else
{
strupper(s->serv.name);
s->serv.type = servertype;
s->death_time = ttl?time(NULL)+ttl*3:0;
+
+ if (servertype == 0)
+ s->death_time = time(NULL)-1;
/* for a domain entry, the comment field refers to the server name */