From b9ae225b28f4707609e6436dad4be7ebdd7e181f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jun 1996 11:43:09 +0000 Subject: - added interface.c and removed all the references to myip, bcast_ip and Netmask, instead replacing them with calls to routines in interface.c - got rid of old MAXINT define - added code to ensure we only return one entry for each name in the ipc enum routines - added new_only option to add_netbios_entry() to prevent overwriting of important names - minor time handling fixup (This used to be commit 7ed71b73ae745da099072eee36fc2700d1d91407) --- source3/namedb.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'source3/namedb.c') diff --git a/source3/namedb.c b/source3/namedb.c index 402617ffbd..2e942587be 100644 --- a/source3/namedb.c +++ b/source3/namedb.c @@ -28,14 +28,15 @@ #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; /* this is our browse master/backup cache database */ struct browse_cache_record *browserlist = NULL; @@ -305,7 +306,8 @@ void expire_browse_cache(time_t t) 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; @@ -323,28 +325,31 @@ struct work_record *find_workgroupstruct(struct domain_record *d, fstring name, 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; } @@ -446,7 +451,8 @@ struct domain_record *add_domain_entry(struct in_addr source_ip, ip = *interpret_addr2("255.255.255.255"); - 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)) || @@ -516,7 +522,8 @@ struct browse_cache_record *add_browser_entry(char *name, int type, char *wg, 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) { @@ -576,7 +583,7 @@ struct server_record *add_server_entry(struct domain_record *d, 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; -- cgit