From 363b9a2739e9e39d1f69625e6647c6c9047a901a Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Thu, 31 Jul 1997 18:47:26 +0000 Subject: loadparm.c: Added new netbios aliases parameter (code from Cisco) nameannounce.c: Code to announce aliases as well as our own names. namedbsubnet.c: Code to add the aliases to the server list. nameserv.c: Code to defend our aliases on the namelist. namework.c: Code to check it's one of our aliases. nmbd.c: Code to initialise the aliases. proto.h: Fixup protos. util.c: Code to check it's one of our aliases. All above code based on code for 1.9.16p11 donated by Cisco from Ben Woodard Jeremy (jallison@whistle.com) (This used to be commit a2ce1c0cb1331551ff728dcfe3260fab4cd827e5) --- source3/nmbd/nmbd.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 4 deletions(-) (limited to 'source3/nmbd') diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 10701c24d4..925f975ffe 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -41,6 +41,7 @@ extern pstring myhostname; static pstring host_file; extern pstring myname; extern fstring myworkgroup; +extern char **my_netbios_names; /* are we running as a daemon ? */ static BOOL is_daemon = False; @@ -363,7 +364,11 @@ static BOOL open_sockets(BOOL isdaemon, int port) static BOOL init_structs() { extern fstring local_machine; - char *p; + char *p, *ptr; + int namecount; + int n; + int nodup; + pstring nbname; if (! *myname) { strcpy(myname,myhostname); @@ -372,12 +377,62 @@ static BOOL init_structs() } strupper(myname); + /* Add any NETBIOS name aliases. Ensure that the first entry + is equal to myname. */ + /* Work out the max number of netbios aliases that we have */ + ptr=lp_netbios_aliases(); + for (namecount=0; next_token(&ptr,nbname,NULL); namecount++) + ; + if (*myname) + namecount++; + + /* Allocate space for the netbios aliases */ + if((my_netbios_names=(char **)malloc(sizeof(char *)*(namecount+1))) == NULL) + { + DEBUG(0,("init_structs: malloc fail.\n")); + return False; + } + + /* Use the myname string first */ + namecount=0; + if (*myname) + my_netbios_names[namecount++] = myname; + + ptr=lp_netbios_aliases(); + while (next_token(&ptr,nbname,NULL)) { + strupper(nbname); + /* Look for duplicates */ + nodup=1; + for(n=0; n