{
if (f && ip_equal(d->bcast_ip, ipgrp) && n->source == REGISTER)
{
- fstring data;
-
- /* XXXX i have little imagination as to how to output nb_flags as
- anything other than as a hexadecimal number :-) */
-
- sprintf(data, "%s#%02x %s %2x %ld",
- n->name.name,n->name.name_type, /* XXXX ignore scope for now */
- inet_ntoa(n->ip),
- n->nb_flags,
- n->death_time);
- fprintf(f, "%s\n", data);
+ /* XXXX i have little imagination as to how to output nb_flags as
+ anything other than as a hexadecimal number :-) */
+
+ fprintf(f, "%s#%02x %s %2x %ld\n",
+ n->name.name,n->name.name_type, /* XXXX ignore scope for now */
+ inet_ntoa(n->ip),
+ n->nb_flags,
+ n->death_time);
}
DEBUG(3,("%15s ", inet_ntoa(d->bcast_ip)));
int type = 0;
int nb_flags;
time_t ttd;
- struct in_addr ipaddr;
+ struct in_addr ipaddr;
- enum name_source source;
+ enum name_source source;
char *ptr;
- int count = 0;
+ int count = 0;
char *p;
if (*line == '#') continue;
- ptr = line;
-
- if (next_token(&ptr,name_str ,NULL)) ++count;
- if (next_token(&ptr,ip_str ,NULL)) ++count;
- if (next_token(&ptr,ttd_str ,NULL)) ++count;
- if (next_token(&ptr,nb_flags_str,NULL)) ++count;
-
- if (count <= 0) continue;
-
- if (count != 4) {
- DEBUG(0,("Ill formed wins line"));
- DEBUG(0,("[%s]: name#type ip nb_flags abs_time\n",line));
- continue;
- }
+ ptr = line;
+ if (next_token(&ptr,name_str ,NULL)) ++count;
+ if (next_token(&ptr,ip_str ,NULL)) ++count;
+ if (next_token(&ptr,nb_flags_str,NULL)) ++count;
+ if (next_token(&ptr,ttd_str ,NULL)) ++count;
+
+ if (count <= 0) continue;
+
+ if (count != 4) {
+ DEBUG(0,("Ill formed wins line"));
+ DEBUG(0,("[%s]: name#type ip nb_flags abs_time\n",line));
+ continue;
+ }
+
/* netbios name. # divides the name from the type (hex): netbios#xx */
strcpy(name,name_str);
-
+
p = strchr(name,'#');
if (p) {
strcpy(myname,myhostname);
p = strchr(myname,'.');
if (p) *p = 0;
+ strupper(myname);
}
return True;
{
DEBUG(0,("Incorrect program usage - is the command line correct?\n"));
- printf("Usage: %s [-n name] [-B bcast address] [-D] [-p port] [-d debuglevel] [-l log basename]\n",pname);
+ printf("Usage: %s [-n name] [-D] [-p port] [-d debuglevel] [-l log basename]\n",pname);
printf("Version %s\n",VERSION);
printf("\t-D become a daemon\n");
printf("\t-p port listen on the specified port\n");
printf("\t-d debuglevel set the debuglevel\n");
printf("\t-l log basename. Basename for log/debug files\n");
printf("\t-n netbiosname. the netbios name to advertise for this host\n");
- printf("\t-B broadcast address the address to use for broadcasts\n");
- printf("\t-N netmask the netmask to use for subnet determination\n");
printf("\t-H hosts file load a netbios hosts file\n");
- printf("\t-G group name add a group name to be part of\n");
- printf("\t-I ip-address override the IP address\n");
- printf("\t-C comment sets the machine comment that appears in browse lists\n");
printf("\n");
}
extern char *optarg;
fstring group;
- *group = 0;
*host_file = 0;
StartupTime = time(NULL);
case 's':
strcpy(servicesf,optarg);
break;
+ case 'N':
+ case 'B':
+ case 'I':
case 'C':
- strcpy(ServerComment,optarg);
- break;
case 'G':
- strcpy(group,optarg);
+ DEBUG(0,("Obsolete option '%c' used\n",opt));
break;
case 'H':
strcpy(host_file,optarg);
break;
- case 'I':
- iface_set_default(optarg,NULL,NULL);
- break;
- case 'B':
- iface_set_default(NULL,optarg,NULL);
- break;
- case 'N':
- iface_set_default(NULL,NULL,optarg);
- break;
case 'n':
strcpy(myname,optarg);
+ strupper(myname);
break;
case 'l':
sprintf(debugf,"%s.nmb",optarg);
string_sub(ServerComment,"%h",myhostname);
add_my_names();
+
+ if (strequal(lp_workgroup(),"*")) {
+ DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n"));
+ }
+
add_my_subnets(lp_workgroup());
DEBUG(3,("Checked names\n"));
return True;
}
-/* used for server information: client, nameserv and ipc */
struct srv_info_struct
{
fstring name;
uint32 type;
fstring comment;
- fstring domain; /* used ONLY in ipc.c NOT namework.c */
- BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
+ fstring domain;
+ BOOL server_added;
};
-/*******************************************************************
- filter out unwanted server info
- ******************************************************************/
-static BOOL filter_server_info(struct srv_info_struct *server,
- BOOL domains,
- char *domain, uint32 request)
-{
- if (*domain == 0)
- {
- if (strequal(lp_workgroup(), server->domain)) {
- return True;
- }
- else if (domains)
- {
- DEBUG(4,("primary domain:reject %8x %s %s\n",request,server->name,server->domain));
- return False;
- }
- else if ((request & SV_TYPE_DOMAIN_ENUM) &&
- (server->type & SV_TYPE_DOMAIN_ENUM))
- {
- DEBUG(4,("rej:DOM %8x: %s %s\n",server->type,server->name,server->domain));
- return False;
- }
-
- return True;
- }
- else
- {
- if (strequal(domain, server->domain))
- {
- /*
- if (request == SV_TYPE_LOCAL_LIST_ONLY &&
- !(server->type & SV_TYPE_LOCAL_LIST_ONLY))
- {
- DEBUG(4,("rej:LOC %8x: ok %s %s\n",request,server->name,server->domain));
- return False;
- }
- */
- if ((request == (SV_TYPE_LOCAL_LIST_ONLY|SV_TYPE_DOMAIN_ENUM)) &&
- !(server->type&SV_TYPE_DOMAIN_ENUM))
- {
- DEBUG(4,("rej:LOCDOM %8x: ok %s %s\n",request,server->name,server->domain));
- return False;
- }
-
- return True;
- }
- else if (!domains)
- {
- DEBUG(4,("domain:%s %s %s\n",domain,server->name,server->domain));
- return False;
- }
- return True;
- }
-}
/*******************************************************************
get server info lists from the files saved by nmbd. Return the
number of entries
******************************************************************/
static int get_server_info(uint32 servertype,
- struct srv_info_struct **servers, BOOL domains,
+ struct srv_info_struct **servers,
char *domain)
{
FILE *f;
/* request for everything is code for request all servers */
if (servertype == SV_TYPE_ALL) servertype &= ~SV_TYPE_DOMAIN_ENUM;
- DEBUG(4,("Servertype search: %8x domains:%s\n",servertype,BOOLSTR(domains)));
+ DEBUG(4,("Servertype search: %8x\n",servertype));
while (!feof(f))
{
if (!next_token(&ptr,s->comment, NULL)) continue;
if (!next_token(&ptr,s->domain , NULL)) {
/* this allows us to cope with an old nmbd */
- strcpy(s->domain,my_workgroup());
+ strcpy(s->domain,lp_workgroup());
}
if (sscanf(stype,"%X",&s->type) != 1) {
ok = False;
}
- if ((servertype == ~SV_TYPE_DOMAIN_ENUM) &&
+ if ((servertype & SV_TYPE_DOMAIN_ENUM) !=
(s->type & SV_TYPE_DOMAIN_ENUM))
{
- DEBUG(4,("s:all x dom "));
+ DEBUG(4,("s: dom mismatch "));
ok = False;
}
- if (domains && !(domain && *domain && strequal(domain, s->domain)))
+ if (!strequal(domain, s->domain) && !(servertype & SV_TYPE_DOMAIN_ENUM))
{
- if (!(s->type & SV_TYPE_DOMAIN_ENUM))
- {
- DEBUG(4,("r:dom enum "));
- ok = False;
- }
+ ok = False;
}
if (ok)
DEBUG(4,("**SV** %20s %8x %25s %15s\n",
s->name, s->type, s->comment, s->domain));
- s->type |= SV_TYPE_LOCAL_LIST_ONLY;
s->server_added = True;
count++;
}
int counted=0,total=0;
int i;
fstring domain;
- BOOL domains;
BOOL domain_request;
BOOL local_request = servertype & SV_TYPE_LOCAL_LIST_ONLY;
- /*if (servertype == SV_TYPE_ALL) servertype &= ~(SV_TYPE_DOMAIN_ENUM|SV_TYPE_LOCAL_LIST_ONLY);*/
if (servertype == SV_TYPE_ALL) servertype &= ~SV_TYPE_DOMAIN_ENUM;
- domain_request = servertype & SV_TYPE_DOMAIN_ENUM;
+ domain_request = ((servertype & SV_TYPE_DOMAIN_ENUM) != 0);
- domain[0] = 0;
p += 8;
if (!prefix_ok(str1,"WrLehD")) return False;
DEBUG(4, ("domains_req:%s ", BOOLSTR(domain_request)));
DEBUG(4, ("local_only:%s\n", BOOLSTR(local_request)));
- if (strcmp(str1, "WrLehDO") == 0)
- {
- domains = False;
- }
- else if (strcmp(str1, "WrLehDz") == 0)
- {
- domains = True;
+ if (strcmp(str1, "WrLehDz") == 0) {
StrnCpy(domain, p, sizeof(fstring)-1);
+ } else {
+ StrnCpy(domain, lp_workgroup(), sizeof(fstring)-1);
}
if (lp_browse_list())
- {
- total = get_server_info(servertype,&servers,domains,domain);
- }
+ total = get_server_info(servertype,&servers,domain);
data_len = fixed_len = string_len = 0;
for (i=0;i<total;i++)
{
struct srv_info_struct *s = &servers[i];
- if (filter_server_info(s,domains,domain,
- local_request|domain_request))
+ if (lastname && strequal(lastname,s->name)) continue;
+ lastname = s->name;
+ data_len += fill_srv_info(s,uLevel,0,&f_len,0,&s_len,0);
+ DEBUG(4,("fill_srv_info %20s %8x %25s %15s\n",
+ s->name, s->type, s->comment, s->domain));
+
+ if (data_len <= buf_len)
{
- if (lastname && strequal(lastname,s->name)) continue;
- lastname = s->name;
- data_len += fill_srv_info(s,uLevel,0,&f_len,0,&s_len,0);
- DEBUG(4,("fill_srv_info %20s %8x %25s %15s\n",
- s->name, s->type, s->comment, s->domain));
-
- if (data_len <= buf_len)
- {
- counted++;
- fixed_len += f_len;
- string_len += s_len;
- }
+ counted++;
+ fixed_len += f_len;
+ string_len += s_len;
}
}
}
for (i = 0; i < total && count2;i++)
{
struct srv_info_struct *s = &servers[i];
- if (filter_server_info(s,domains,domain,local_request|domain_request))
- {
- if (lastname && strequal(lastname,s->name)) continue;
- lastname = s->name;
- fill_srv_info(s,uLevel,&p,&f_len,&p2,&s_len,*rdata);
- DEBUG(4,("fill_srv_info %20s %8x %25s %15s\n",
- s->name, s->type, s->comment, s->domain));
- count2--;
- }
+ if (lastname && strequal(lastname,s->name)) continue;
+ lastname = s->name;
+ fill_srv_info(s,uLevel,&p,&f_len,&p2,&s_len,*rdata);
+ DEBUG(4,("fill_srv_info %20s %8x %25s %15s\n",
+ s->name, s->type, s->comment, s->domain));
+ count2--;
}
}
strcpy(comment,lp_serverstring());
- if ((count=get_server_info(SV_TYPE_ALL,&servers,False,NULL))>0) {
+ if ((count=get_server_info(SV_TYPE_ALL,&servers,lp_workgroup()))>0) {
for (i=0;i<count;i++)
if (strequal(servers[i].name,local_machine)) {
servertype = servers[i].type;
p += 4;
SIVAL(p,0,PTR_DIFF(p2,*rdata));
- strcpy(p2,my_workgroup());
+ strcpy(p2,lp_workgroup());
p2 = skip_string(p2,1);
p += 4;
p += 2;
SIVAL(p,0,PTR_DIFF(p2,*rdata));
- strcpy(p2,my_workgroup()); /* login domain?? */
+ strcpy(p2,lp_workgroup()); /* login domain?? */
p2 = skip_string(p2,1);
p += 4;
strupper(mypath);
PACKS(&desc,"z",mypath); /* computer */
}
- PACKS(&desc,"z",my_workgroup());/* domain */
+ PACKS(&desc,"z",lp_workgroup());/* domain */
PACKS(&desc,"z",lp_logon_script()); /* script path */
PACKI(&desc,"D",0); /* reserved */
}