From 1aedda6160e0748d82a68bcd64f661ea1b80af9d Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Sat, 17 Aug 1996 15:14:24 +0000 Subject: - fixed wins.dat reloading (it wasn't happening!) - made nb_flags an unsigned 16 bit int in nameserv.h - nmbd was calling add_my_subnets() with an uninitialised parameter group. removed it. lkcl (This used to be commit 3d55e541569e7ab887bddc284bddcafdf86c4d22) --- source3/namedbname.c | 80 +++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 38 deletions(-) (limited to 'source3/namedbname.c') diff --git a/source3/namedbname.c b/source3/namedbname.c index 188e46ff75..081c20e45b 100644 --- a/source3/namedbname.c +++ b/source3/namedbname.c @@ -230,8 +230,8 @@ void dump_names(void) { int i; - DEBUG(3,("%15s ", inet_ntoa(d->bcast_ip))); - DEBUG(3,("%15s ", inet_ntoa(d->mask_ip))); + DEBUG(3,("%15s ", inet_ntoa(d->bcast_ip))); + DEBUG(3,("%15s ", inet_ntoa(d->mask_ip))); DEBUG(3,("%-19s TTL=%ld ", namestr(&n->name), n->death_time?n->death_time-t:0)); @@ -243,29 +243,30 @@ void dump_names(void) n->ip_flgs[i].nb_flags)); } - DEBUG(3,("\n")); + DEBUG(3,("\n")); 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 :-) */ - fprintf(f,"%s#%02x %ld", - n->name.name,n->name.name_type, /* XXXX ignore scope for now */ - n->death_time); + sprintf(data, "%s#%02x %ld ", + n->name.name,n->name.name_type, /* XXXX ignore scope for now */ + n->death_time); + fprintf(f, "%s", data); + for (i = 0; i < n->num_ips; i++) { - DEBUG(3,("%15s NB=%2x ", - inet_ntoa(n->ip_flgs[i].ip), - n->ip_flgs[i].nb_flags)); - - fprintf(f, "%s %2x ", - inet_ntoa(n->ip_flgs[i].ip), - n->ip_flgs[i].nb_flags); + sprintf(data, "%s %2x ", + inet_ntoa(n->ip_flgs[i].ip), + n->ip_flgs[i].nb_flags); + fprintf(f, "%s", data); } - DEBUG(3,("\n")); - fprintf(f, "\n"); + fprintf(f, "\n"); } + } fclose(f); @@ -310,33 +311,36 @@ void load_netbios_names(void) pstring name; int type = 0; - int nb_flags; + unsigned int nb_flags; time_t ttd; - struct in_addr ipaddr; - enum name_source source; + struct in_addr ipaddr; + + enum name_source source; + char *ptr; - int count = 0; + int count = 0; + char *p; if (!fgets_slash(line,sizeof(pstring),f)) continue; if (*line == '#') continue; - ptr = line; + ptr = line; - if (next_token(&ptr,name_str ,NULL)) ++count; - if (next_token(&ptr,ttd_str ,NULL)) ++count; - if (next_token(&ptr,ip_str ,NULL)) ++count; - if (next_token(&ptr,nb_flags_str,NULL)) ++count; + if (next_token(&ptr,name_str ,NULL)) ++count; + if (next_token(&ptr,ttd_str ,NULL)) ++count; + if (next_token(&ptr,ip_str ,NULL)) ++count; + if (next_token(&ptr,nb_flags_str,NULL)) ++count; - if (count <= 0) continue; + if (count <= 0) continue; + + if (count != 4) { + DEBUG(0,("Ill formed wins line")); + DEBUG(0,("[%s]: name#type abs_time ip nb_flags\n",line)); + 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); @@ -348,10 +352,10 @@ void load_netbios_names(void) } /* decode the netbios flags (hex) and the time-to-die (seconds) */ - sscanf(nb_flags_str,"%x",&nb_flags); - sscanf(ttd_str,"%ld",&ttd); + sscanf(nb_flags_str,"%x",&nb_flags); + sscanf(ttd_str,"%ld",&ttd); - ipaddr = *interpret_addr2(ip_str); + ipaddr = *interpret_addr2(ip_str); if (ip_equal(ipaddr,ipzero)) { source = SELF; @@ -361,11 +365,11 @@ void load_netbios_names(void) source = REGISTER; } - DEBUG(4, ("add WINS line: %s#%02x %s %ld %2x\n", - name,type, inet_ntoa(ipaddr), ttd, nb_flags)); + DEBUG(4, ("add WINS line: %s#%02x %ld %s %2x\n", + name,type, ttd, inet_ntoa(ipaddr), nb_flags)); /* add all entries that have 60 seconds or more to live */ - if (ttd - 60 < time(NULL) || ttd == 0) + if (ttd - 60 > time(NULL) || ttd == 0) { time_t t = (ttd?ttd-time(NULL):0) / 3; @@ -536,7 +540,7 @@ struct name_record *search_for_name(struct subnet_record **d, if (!n) { struct in_addr dns_ip; - uint32 a; + unsigned long a; /* only do DNS lookups if the query is for type 0x20 or type 0x0 */ if (!dns_type && name_type != 0x1b) -- cgit