summaryrefslogtreecommitdiff
path: root/source3/namedbsubnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/namedbsubnet.c')
-rw-r--r--source3/namedbsubnet.c151
1 files changed, 83 insertions, 68 deletions
diff --git a/source3/namedbsubnet.c b/source3/namedbsubnet.c
index 0bad79246a..94decb7f0b 100644
--- a/source3/namedbsubnet.c
+++ b/source3/namedbsubnet.c
@@ -26,6 +26,9 @@
04 jul 96: lkcl@pires.co.uk
created module namedbsubnet containing subnet database functions
+ 30 July 96: David.Chappell@mail.trincoll.edu
+ Expanded multiple workgroup domain master browser support.
+
*/
#include "includes.h"
@@ -90,16 +93,16 @@ struct subnet_record *find_subnet(struct in_addr bcast_ip)
for (d = subnetlist; d; d = d->next)
{
if (ip_equal(bcast_ip, wins_ip))
- {
+ {
if (ip_equal(bcast_ip, d->bcast_ip))
{
return d;
}
}
else if (same_net(bcast_ip, d->bcast_ip, d->mask_ip))
- {
- return(d);
- }
+ {
+ return(d);
+ }
}
return (NULL);
@@ -154,24 +157,24 @@ static struct subnet_record *make_subnet(struct in_addr bcast_ip, struct in_addr
****************************************************************************/
void add_subnet_interfaces(void)
{
- struct interface *i;
-
- /* loop on all local interfaces */
- for (i = local_interfaces; i; i = i->next)
- {
- /* add the interface into our subnet database */
- if (!find_subnet(i->bcast))
- {
- make_subnet(i->bcast,i->nmask);
- }
- }
-
- /* add the pseudo-ip interface for WINS: 255.255.255.255 */
- if (lp_wins_support() || (*lp_wins_server()))
+ struct interface *i;
+
+ /* loop on all local interfaces */
+ for (i = local_interfaces; i; i = i->next)
{
- struct in_addr wins_bcast = ipgrp;
- struct in_addr wins_nmask = ipzero;
- make_subnet(wins_bcast, wins_nmask);
+ /* add the interface into our subnet database */
+ if (!find_subnet(i->bcast))
+ {
+ make_subnet(i->bcast,i->nmask);
+ }
+ }
+
+ /* add the pseudo-ip interface for WINS: 255.255.255.255 */
+ if (lp_wins_support() || (*lp_wins_server()))
+ {
+ struct in_addr wins_bcast = ipgrp;
+ struct in_addr wins_nmask = ipzero;
+ make_subnet(wins_bcast, wins_nmask);
}
}
@@ -188,7 +191,7 @@ void add_my_subnets(char *group)
if (*group == '*') return;
- /* the coding choice is up to you, andrew: i can see why you don't want
+ /* the coding choice is up to you, andrew: i can see why you don't want
global access to the local_interfaces structure: so it can't get
messed up! */
for (i = local_interfaces; i; i = i->next)
@@ -203,8 +206,8 @@ void add_my_subnets(char *group)
to the named a workgroup.
****************************************************************************/
struct subnet_record *add_subnet_entry(struct in_addr bcast_ip,
- struct in_addr mask_ip,
- char *name, BOOL add, BOOL lmhosts)
+ struct in_addr mask_ip,
+ char *name, BOOL add, BOOL lmhosts)
{
struct subnet_record *d;
@@ -222,29 +225,41 @@ struct subnet_record *add_subnet_entry(struct in_addr bcast_ip,
/* add the domain into our domain database */
if ((d = find_subnet(bcast_ip)) ||
(d = make_subnet(bcast_ip, mask_ip)))
- {
- struct work_record *w = find_workgroupstruct(d, name, add);
+ {
+ struct work_record *work = 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))
- {
- add_my_name_entry(d,name,0x1e,nb_type|NB_ACTIVE|NB_GROUP);
- add_my_name_entry(d,name,0x0 ,nb_type|NB_ACTIVE|NB_GROUP);
- }
- /* add samba server name to workgroup list. don't add
- lmhosts server entries to local interfaces */
- if (strequal(lp_workgroup(), name))
- {
- add_server_entry(d,w,myname,w->ServerType,0,lp_serverstring(),True);
+ if (!work) return NULL;
+
+ if (conf_should_workgroup_member(work->token))
+ {
+ /* add samba server name to workgroup list. don't add
+ lmhosts server entries to local interfaces */
+
+ pstring comment;
+ char *my_name = conf_browsing_alias (work->token);
+ char *my_comment = conf_browsing_alias_comment(work->token);
+
+ my_name = my_name ? my_name : myname;
+ my_comment = my_comment ? my_comment : lp_server_comment();
+
+ StrnCpy(comment, my_comment, 43);
+
+ add_server_entry(d,work,my_name,
+ work->ServerType | SV_TYPE_LOCAL_LIST_ONLY,
+ 0,comment,True);
+
DEBUG(3,("Added server name entry %s at %s\n",
name,inet_ntoa(bcast_ip)));
- }
-
- return d;
+
+ /* add WORKGROUP(1e) and WORKGROUP(00) entries into name database
+ or register with WINS server, if it's our workgroup */
+ add_my_name_entry(d,work->token,name,0x1e,nb_type|NB_ACTIVE|NB_GROUP);
+ add_my_name_entry(d,work->token,name,0x0 ,nb_type|NB_ACTIVE|NB_GROUP);
}
+
+ return d;
+ }
+
return NULL;
}
@@ -290,31 +305,31 @@ void write_browse_list(void)
{
struct work_record *work;
for (work = d->workgrouplist; work ; work = work->next)
- {
- struct server_record *s;
- for (s = work->serverlist; s ; s = s->next)
- {
- fstring tmp;
-
- /* don't list domains I don't have a master for */
- if ((s->serv.type & SV_TYPE_DOMAIN_ENUM) && !s->serv.comment[0])
- {
- continue;
- }
-
- /* output server details, plus what workgroup/domain
- they're in. without the domain information, the
- combined list of all servers in all workgroups gets
- sent to anyone asking about any workgroup! */
-
- sprintf(tmp, "\"%s\"", s->serv.name);
- fprintf(f, "%-25s ", tmp);
- fprintf(f, "%08x ", s->serv.type);
- sprintf(tmp, "\"%s\" ", s->serv.comment);
- fprintf(f, "%-30s", tmp);
- fprintf(f, "\"%s\"\n", work->work_group);
- }
- }
+ {
+ struct server_record *s;
+ for (s = work->serverlist; s ; s = s->next)
+ {
+ fstring tmp;
+
+ /* don't list domains I don't have a master for */
+ if ((s->serv.type & SV_TYPE_DOMAIN_ENUM) && !s->serv.comment[0])
+ {
+ continue;
+ }
+
+ /* output server details, plus what workgroup/domain
+ they're in. without the domain information, the
+ combined list of all servers in all workgroups gets
+ sent to anyone asking about any workgroup! */
+
+ sprintf(tmp, "\"%s\"", s->serv.name);
+ fprintf(f, "%-25s ", tmp);
+ fprintf(f, "%08x ", s->serv.type);
+ sprintf(tmp, "\"%s\" ", s->serv.comment);
+ fprintf(f, "%-30s", tmp);
+ fprintf(f, "\"%s\"\n", work->work_group);
+ }
+ }
}
fclose(f);