summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorChristopher R. Hertel <crh@samba.org>1998-06-09 01:56:18 +0000
committerChristopher R. Hertel <crh@samba.org>1998-06-09 01:56:18 +0000
commit96bc4042779570e6239b2626888ea0ca9be17391 (patch)
treea09e276a5dda748eda4af3e97d46149da6d92c6e /source3
parentae260b9688676afc712fec0890b3cd79dfb53331 (diff)
downloadsamba-96bc4042779570e6239b2626888ea0ca9be17391.tar.gz
samba-96bc4042779570e6239b2626888ea0ca9be17391.tar.bz2
samba-96bc4042779570e6239b2626888ea0ca9be17391.zip
This is a first step toward moving long namelists into a database. I
split the name_record structure into pieces. The goal is that the key (the name) be separate from the data associated with the key. Databases such as gdbm store information in [key,content] pairs. There is no functional change in with this update. It's just a step in the direction that Jeremy and I have been discussing. Chris -)----- (This used to be commit e420a4bd7d368a0e910893400fb7b46ab8694a08)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/nameserv.h41
-rw-r--r--source3/nmbd/nmbd_become_lmb.c2
-rw-r--r--source3/nmbd/nmbd_incomingrequests.c76
-rw-r--r--source3/nmbd/nmbd_lmhosts.c2
-rw-r--r--source3/nmbd/nmbd_mynames.c16
-rw-r--r--source3/nmbd/nmbd_namelistdb.c231
-rw-r--r--source3/nmbd/nmbd_namequery.c20
-rw-r--r--source3/nmbd/nmbd_nameregister.c10
-rw-r--r--source3/nmbd/nmbd_namerelease.c20
-rw-r--r--source3/nmbd/nmbd_packets.c2
-rw-r--r--source3/nmbd/nmbd_winsproxy.c14
-rw-r--r--source3/nmbd/nmbd_winsserver.c121
12 files changed, 314 insertions, 241 deletions
diff --git a/source3/include/nameserv.h b/source3/include/nameserv.h
index 7faad9aff4..f1707115ca 100644
--- a/source3/include/nameserv.h
+++ b/source3/include/nameserv.h
@@ -85,16 +85,16 @@ enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
#define NB_FLGMSK 0xE0
/* NetBIOS flag identifier. */
-#define NAME_GROUP(p) ((p)->nb_flags & NB_GROUP)
-#define NAME_BFLAG(p) (((p)->nb_flags & NB_NODETYPEMASK) == NB_BFLAG)
-#define NAME_PFLAG(p) (((p)->nb_flags & NB_NODETYPEMASK) == NB_PFLAG)
-#define NAME_MFLAG(p) (((p)->nb_flags & NB_NODETYPEMASK) == NB_MFLAG)
-#define NAME_HFLAG(p) (((p)->nb_flags & NB_NODETYPEMASK) == NB_HFLAG)
+#define NAME_GROUP(p) ((p)->data.nb_flags & NB_GROUP)
+#define NAME_BFLAG(p) (((p)->data.nb_flags & NB_NODETYPEMASK) == NB_BFLAG)
+#define NAME_PFLAG(p) (((p)->data.nb_flags & NB_NODETYPEMASK) == NB_PFLAG)
+#define NAME_MFLAG(p) (((p)->data.nb_flags & NB_NODETYPEMASK) == NB_MFLAG)
+#define NAME_HFLAG(p) (((p)->data.nb_flags & NB_NODETYPEMASK) == NB_HFLAG)
/* Samba name state for a name in a namelist. */
-#define NAME_IS_ACTIVE(p) ((p)->nb_flags & NB_ACTIVE)
-#define NAME_IN_CONFLICT(p) ((p)->nb_flags & NB_CONFL)
-#define NAME_IS_DEREGISTERING(p) ((p)->nb_flags & NB_DEREG)
+#define NAME_IS_ACTIVE(p) ((p)->data.nb_flags & NB_ACTIVE)
+#define NAME_IN_CONFLICT(p) ((p)->data.nb_flags & NB_CONFL)
+#define NAME_IS_DEREGISTERING(p) ((p)->data.nb_flags & NB_DEREG)
/* Error codes for NetBIOS requests. */
#define FMT_ERR 0x1 /* Packet format error. */
@@ -168,22 +168,17 @@ enum logon_state
LOGON_SRV
};
+struct subnet_record;
+
/* A netbios name structure. */
struct nmb_name {
- char name[17];
- char scope[64];
+ char name[17];
+ char scope[64];
unsigned int name_type;
};
-/* This is the structure used for the local netbios name list. */
-struct name_record
+struct nmb_data
{
- struct name_record *next;
- struct name_record *prev;
-
- struct subnet_record *subnet;
-
- struct nmb_name name; /* The netbios name. */
uint16 nb_flags; /* Netbios flags. */
int num_ips; /* Number of ip entries. */
struct in_addr *ip; /* The ip list for this name. */
@@ -194,7 +189,15 @@ struct name_record
time_t refresh_time; /* The time the record should be refreshed. */
};
-struct subnet_record;
+/* This is the structure used for the local netbios name list. */
+struct name_record
+{
+ struct name_record *next;
+ struct name_record *prev;
+ struct subnet_record *subnet;
+ struct nmb_name name; /* The netbios name. */
+ struct nmb_data data; /* The netbios data. */
+};
/* Browser cache for synchronising browse lists. */
struct browse_cache_record
diff --git a/source3/nmbd/nmbd_become_lmb.c b/source3/nmbd/nmbd_become_lmb.c
index ffa3b38cba..b97da7d8b4 100644
--- a/source3/nmbd/nmbd_become_lmb.c
+++ b/source3/nmbd/nmbd_become_lmb.c
@@ -67,7 +67,7 @@ static void remove_permanent_name_from_unicast( struct subnet_record *subrec,
{
/* Remove this broadcast subnet IP address from the name. */
remove_ip_from_name_record( namerec, subrec->myip);
- if(namerec->num_ips == 0)
+ if(namerec->data.num_ips == 0)
remove_name_from_namelist( unicast_subnet, namerec);
}
}
diff --git a/source3/nmbd/nmbd_incomingrequests.c b/source3/nmbd/nmbd_incomingrequests.c
index 02b511a363..d05036b3ee 100644
--- a/source3/nmbd/nmbd_incomingrequests.c
+++ b/source3/nmbd/nmbd_incomingrequests.c
@@ -114,7 +114,9 @@ group release name %s from IP %s on subnet %s with no group bit set.\n",
namerec = find_name_on_subnet(subrec, &nmb->question.question_name, FIND_ANY_NAME);
/* We only care about someone trying to release one of our names. */
- if (namerec && ((namerec->source == SELF_NAME) || (namerec->source == PERMANENT_NAME)))
+ if( namerec
+ && ( (namerec->data.source == SELF_NAME)
+ || (namerec->data.source == PERMANENT_NAME) ) )
{
rcode = ACT_ERR;
DEBUG(0, ("process_name_release_request: Attempt to release name %s from IP %s \
@@ -236,7 +238,7 @@ IP %s on subnet %s\n", namestr(question), inet_ntoa(from_ip), subrec->subnet_nam
* later to queries.
*/
- if((namerec != NULL) && (namerec->source == WINS_PROXY_NAME))
+ if((namerec != NULL) && (namerec->data.source == WINS_PROXY_NAME))
{
remove_name_from_namelist( subrec, namerec );
namerec = NULL;
@@ -246,10 +248,10 @@ IP %s on subnet %s\n", namestr(question), inet_ntoa(from_ip), subrec->subnet_nam
{
/* Unique name. */
- if ((namerec != NULL) &&
- ((namerec->source == SELF_NAME) || (namerec->source == PERMANENT_NAME) ||
- NAME_GROUP(namerec))
- )
+ if( (namerec != NULL)
+ && ( (namerec->data.source == SELF_NAME)
+ || (namerec->data.source == PERMANENT_NAME)
+ || NAME_GROUP(namerec) ) )
{
/* No-one can register one of Samba's names, nor can they
register a name that's a group name as a unique name */
@@ -260,7 +262,7 @@ IP %s on subnet %s\n", namestr(question), inet_ntoa(from_ip), subrec->subnet_nam
else if(namerec != NULL)
{
/* Update the namelist record with the new information. */
- namerec->ip[0] = from_ip;
+ namerec->data.ip[0] = from_ip;
update_name_ttl(namerec, ttl);
DEBUG(3,("process_name_registration_request: Updated name record %s \
@@ -272,9 +274,10 @@ with IP %s on subnet %s\n",namestr(&namerec->name),inet_ntoa(from_ip), subrec->s
{
/* Group name. */
- if((namerec != NULL) && !NAME_GROUP(namerec) &&
- ((namerec->source == SELF_NAME) || (namerec->source == PERMANENT_NAME))
- )
+ if( (namerec != NULL)
+ && !NAME_GROUP(namerec)
+ && ( (namerec->data.source == SELF_NAME)
+ || (namerec->data.source == PERMANENT_NAME) ) )
{
/* Disallow group names when we have a unique name. */
send_name_registration_response(ACT_ERR, 0, p);
@@ -350,7 +353,8 @@ subnet %s - name not found.\n", namestr(&nmb->question.question_name),
while (buf < bufend)
{
- if ((namerec->source == SELF_NAME) || (namerec->source == PERMANENT_NAME))
+ if( (namerec->data.source == SELF_NAME)
+ || (namerec->data.source == PERMANENT_NAME) )
{
int name_type = namerec->name.name_type;
@@ -367,19 +371,19 @@ subnet %s - name not found.\n", namestr(&nmb->question.question_name),
/* Put the name type and netbios flags in the buffer. */
buf[15] = name_type;
- set_nb_flags(&buf[16],namerec->nb_flags);
+ set_nb_flags( &buf[16],namerec->data.nb_flags );
buf[16] |= NB_ACTIVE; /* all our names are active */
buf += 18;
-
+
names_added++;
}
}
/* Remove duplicate names. */
- qsort(buf0,names_added,18,QSORT_CAST status_compare);
+ qsort( buf0, names_added, 18, QSORT_CAST status_compare );
- for (i=1;i<names_added;i++)
+ for( i=1; i < names_added ; i++ )
{
if (memcmp(buf0 + 18*i,buf0 + 18*(i-1),16) == 0)
{
@@ -470,7 +474,9 @@ void process_name_query_request(struct subnet_record *subrec, struct packet_stru
/* Check if it is a name that expired */
- if (namerec && ((namerec->death_time != PERMANENT_TTL) && (namerec->death_time < p->timestamp)))
+ if( namerec
+ && ( (namerec->data.death_time != PERMANENT_TTL)
+ && (namerec->data.death_time < p->timestamp) ) )
{
DEBUG(5,("process_name_query_request: expired name %s\n", namestr(&namerec->name)));
namerec = NULL;
@@ -487,11 +493,17 @@ void process_name_query_request(struct subnet_record *subrec, struct packet_stru
* into the namelist if we were configured as a WINS proxy.
*/
- if (!bcast ||
- (bcast && ((name_type == 0x1b) || (namerec->source == SELF_NAME) ||
- (namerec->source == PERMANENT_NAME) ||
- ((namerec->source == WINS_PROXY_NAME) && ((name_type == 0) || (name_type == 0x20)))))
- )
+ if( !bcast
+ || ( bcast
+ && ( (name_type == 0x1b)
+ || (namerec->data.source == SELF_NAME)
+ || (namerec->data.source == PERMANENT_NAME)
+ || ( (namerec->data.source == WINS_PROXY_NAME)
+ && ( (name_type == 0) || (name_type == 0x20) )
+ )
+ )
+ )
+ )
{
/* The requested name is a directed query, or it's SELF or PERMANENT or WINS_PROXY,
@@ -505,11 +517,11 @@ void process_name_query_request(struct subnet_record *subrec, struct packet_stru
* replies to a broadcast query.
*/
- if(namerec->source == WINS_PROXY_NAME)
+ if( namerec->data.source == WINS_PROXY_NAME )
{
- for( i = 0; i < namerec->num_ips; i++)
+ for( i = 0; i < namerec->data.num_ips; i++)
{
- if(same_net( namerec->ip[i], subrec->myip, subrec->mask_ip ))
+ if(same_net( namerec->data.ip[i], subrec->myip, subrec->mask_ip ))
{
DEBUG(5,("process_name_query_request: name %s is a WINS proxy name and is also \
on the same subnet (%s) as the requestor. Not replying.\n",
@@ -519,30 +531,30 @@ on the same subnet (%s) as the requestor. Not replying.\n",
}
}
- ttl = (namerec->death_time != PERMANENT_TTL) ?
- namerec->death_time - p->timestamp : lp_max_ttl();
+ ttl = (namerec->data.death_time != PERMANENT_TTL) ?
+ namerec->data.death_time - p->timestamp : lp_max_ttl();
/* Copy all known ip addresses into the return data. */
/* Optimise for the common case of one IP address so
we don't need a malloc. */
- if(namerec->num_ips == 1 )
+ if( namerec->data.num_ips == 1 )
prdata = rdata;
else
{
- if((prdata = (char *)malloc( namerec->num_ips * 6 )) == NULL)
+ if((prdata = (char *)malloc( namerec->data.num_ips * 6 )) == NULL)
{
DEBUG(0,("process_name_query_request: malloc fail !\n"));
return;
}
}
- for( i = 0; i < namerec->num_ips; i++)
+ for( i = 0; i < namerec->data.num_ips; i++ )
{
- set_nb_flags(&prdata[i*6],namerec->nb_flags);
- putip((char *)&prdata[2+(i*6)], &namerec->ip[i]);
+ set_nb_flags(&prdata[i*6],namerec->data.nb_flags);
+ putip((char *)&prdata[2+(i*6)], &namerec->data.ip[i]);
}
- reply_data_len = namerec->num_ips * 6;
+ reply_data_len = namerec->data.num_ips * 6;
success = True;
}
}
diff --git a/source3/nmbd/nmbd_lmhosts.c b/source3/nmbd/nmbd_lmhosts.c
index 206c2367b1..f4d520b1cf 100644
--- a/source3/nmbd/nmbd_lmhosts.c
+++ b/source3/nmbd/nmbd_lmhosts.c
@@ -93,7 +93,7 @@ BOOL find_name_in_lmhosts(struct nmb_name *nmbname, struct name_record **namerec
FIND_ANY_NAME))==NULL)
return False;
- if(!NAME_IS_ACTIVE(namerec) || (namerec->source != LMHOSTS_NAME))
+ if(!NAME_IS_ACTIVE(namerec) || (namerec->data.source != LMHOSTS_NAME))
return False;
*namerecp = namerec;
diff --git a/source3/nmbd/nmbd_mynames.c b/source3/nmbd/nmbd_mynames.c
index 2bb8f775d0..f0330c00b7 100644
--- a/source3/nmbd/nmbd_mynames.c
+++ b/source3/nmbd/nmbd_mynames.c
@@ -158,7 +158,8 @@ void release_my_names(void)
for (namerec = subrec->namelist; namerec; namerec = nextnamerec)
{
nextnamerec = namerec->next;
- if ((namerec->source == SELF_NAME) && !NAME_IS_DEREGISTERING(namerec))
+ if( (namerec->data.source == SELF_NAME)
+ && !NAME_IS_DEREGISTERING(namerec) )
release_name(subrec, namerec, standard_success_release,
NULL, NULL);
}
@@ -180,18 +181,19 @@ void refresh_my_names(time_t t)
for (namerec = subrec->namelist; namerec; namerec = namerec->next)
{
/* Each SELF name has an individual time to be refreshed. */
- if ((namerec->source == SELF_NAME) && (namerec->refresh_time < t) &&
- (namerec->death_time != PERMANENT_TTL))
+ if( (namerec->data.source == SELF_NAME)
+ && (namerec->data.refresh_time < t)
+ && ( namerec->data.death_time != PERMANENT_TTL) )
{
/* We cheat here and pretend the refresh is going to be
successful & update the refresh times. This stops
multiple refresh calls being done. We actually
deal with refresh failure in the fail_fn.
*/
- if(!is_refresh_already_queued( subrec, namerec))
- refresh_name(subrec, namerec, NULL, NULL, NULL);
- namerec->death_time += lp_max_ttl();
- namerec->refresh_time += lp_max_ttl();
+ if( !is_refresh_already_queued( subrec, namerec) )
+ refresh_name( subrec, namerec, NULL, NULL, NULL );
+ namerec->data.death_time += lp_max_ttl();
+ namerec->data.refresh_time += lp_max_ttl();
}
}
}
diff --git a/source3/nmbd/nmbd_namelistdb.c b/source3/nmbd/nmbd_namelistdb.c
index 897505ca2b..6375dad4a2 100644
--- a/source3/nmbd/nmbd_namelistdb.c
+++ b/source3/nmbd/nmbd_namelistdb.c
@@ -38,7 +38,7 @@ uint16 samba_nb_type = 0; /* samba's NetBIOS name type */
void set_samba_nb_type(void)
{
- if (lp_wins_support() || (*lp_wins_server()))
+ if( lp_wins_support() || (*lp_wins_server()) )
samba_nb_type = NB_MFLAG; /* samba is a 'hybrid' node type */
else
samba_nb_type = NB_BFLAG; /* samba is broadcast-only node type */
@@ -54,9 +54,9 @@ void set_samba_nb_type(void)
**************************************************************************/
-BOOL ms_browser_name(char *name, int type)
+BOOL ms_browser_name( char *name, int type )
{
- return (strequal(name,MSBROWSE) && (type == 0x01));
+ return( strequal( name, MSBROWSE ) && (type == 0x01) );
}
/****************************************************************************
@@ -76,7 +76,7 @@ static void add_name_to_namelist(struct subnet_record *subrec,
return;
}
- for (namerec2 = subrec->namelist; namerec2->next; namerec2 = namerec2->next)
+ for( namerec2 = subrec->namelist; namerec2->next; namerec2 = namerec2->next )
;
namerec2->next = namerec;
@@ -91,8 +91,8 @@ static void add_name_to_namelist(struct subnet_record *subrec,
Remove a name from the namelist.
**************************************************************************/
-void remove_name_from_namelist(struct subnet_record *subrec,
- struct name_record *namerec)
+void remove_name_from_namelist( struct subnet_record *subrec,
+ struct name_record *namerec )
{
if (namerec->next)
namerec->next->prev = namerec->prev;
@@ -102,8 +102,8 @@ void remove_name_from_namelist(struct subnet_record *subrec,
if(namerec == subrec->namelist)
subrec->namelist = namerec->next;
- if(namerec->ip != NULL)
- free((char *)namerec->ip);
+ if(namerec->data.ip != NULL)
+ free((char *)namerec->data.ip);
free((char *)namerec);
subrec->namelist_changed = True;
@@ -125,13 +125,13 @@ struct name_record *find_name_on_subnet(struct subnet_record *subrec,
if (nmb_name_equal(&name_ret->name, nmbname))
{
/* Self names only - these include permanent names. */
- if (self_only && (name_ret->source != SELF_NAME) &&
- (name_ret->source != PERMANENT_NAME) )
+ if (self_only && (name_ret->data.source != SELF_NAME) &&
+ (name_ret->data.source != PERMANENT_NAME) )
{
continue;
}
DEBUG(9,("find_name_on_subnet: on subnet %s - found name %s source=%d\n",
- subrec->subnet_name, namestr(nmbname), name_ret->source));
+ subrec->subnet_name, namestr(nmbname), name_ret->data.source));
return name_ret;
}
}
@@ -144,15 +144,18 @@ struct name_record *find_name_on_subnet(struct subnet_record *subrec,
Find a name over all known broadcast subnets.
**************************************************************************/
-struct name_record *find_name_for_remote_broadcast_subnet( struct nmb_name *nmbname,
- BOOL self_only)
+struct name_record
+ *find_name_for_remote_broadcast_subnet( struct nmb_name *nmbname,
+ BOOL self_only )
{
struct subnet_record *subrec;
struct name_record *namerec = NULL;
- for( subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
+ for( subrec = FIRST_SUBNET;
+ subrec;
+ subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec) )
{
- if((namerec = find_name_on_subnet(subrec, nmbname, self_only))!= NULL)
+ if( NULL != (namerec = find_name_on_subnet(subrec, nmbname, self_only)) )
break;
}
@@ -163,14 +166,14 @@ struct name_record *find_name_for_remote_broadcast_subnet( struct nmb_name *nmbn
Update the ttl of an entry in a subnet name list.
****************************************************************************/
-void update_name_ttl(struct name_record *namerec, int ttl)
+void update_name_ttl( struct name_record *namerec, int ttl )
{
time_t time_now = time(NULL);
- if(namerec->death_time != PERMANENT_TTL)
- namerec->death_time = time_now + ttl;
+ if(namerec->data.death_time != PERMANENT_TTL)
+ namerec->data.death_time = time_now + ttl;
- namerec->refresh_time = time_now + (ttl/2);
+ namerec->data.refresh_time = time_now + (ttl/2);
namerec->subnet->namelist_changed = True;
}
@@ -196,43 +199,49 @@ struct name_record *add_name_to_subnet(struct subnet_record *subrec,
namerec->subnet = subrec;
- namerec->num_ips = num_ips;
- namerec->ip = (struct in_addr *)malloc(sizeof(struct in_addr) * namerec->num_ips);
- if (!namerec->ip)
+ namerec->data.num_ips = num_ips;
+ namerec->data.ip = (struct in_addr *)malloc( sizeof(struct in_addr)
+ * namerec->data.num_ips );
+ if (!namerec->data.ip)
{
DEBUG(0,("add_name_to_subnet: malloc fail when creating ip_flgs.\n"));
free((char *)namerec);
return NULL;
}
- bzero((char *)namerec->ip, sizeof(struct in_addr) * namerec->num_ips);
+ bzero( (char *)namerec->data.ip,
+ sizeof(struct in_addr) * namerec->data.num_ips );
- memcpy(&namerec->ip[0], iplist, num_ips * sizeof(struct in_addr));
+ memcpy( &namerec->data.ip[0], iplist, num_ips * sizeof(struct in_addr) );
- make_nmb_name(&namerec->name,name,type,scope);
+ make_nmb_name( &namerec->name, name, type, scope );
/* Setup the death_time and refresh_time. */
if(ttl == PERMANENT_TTL)
- namerec->death_time = PERMANENT_TTL;
+ namerec->data.death_time = PERMANENT_TTL;
else
- namerec->death_time = time_now + ttl;
+ namerec->data.death_time = time_now + ttl;
- namerec->refresh_time = time_now + (ttl/2);
+ namerec->data.refresh_time = time_now + (ttl/2);
/* Enter the name as active. */
- namerec->nb_flags = nb_flags | NB_ACTIVE;
+ namerec->data.nb_flags = nb_flags | NB_ACTIVE;
/* If it's our primary name, flag it as so. */
if(strequal(my_netbios_names[0],name))
- namerec->nb_flags |= NB_PERM;
+ namerec->data.nb_flags |= NB_PERM;
- namerec->source = source;
+ namerec->data.source = source;
add_name_to_namelist(subrec,namerec);
- DEBUG(3,("add_name_to_subnet: Added netbios name %s with first IP %s ttl=%d nb_flags=%2x to subnet %s\n",
- namestr(&namerec->name),inet_ntoa(*iplist),ttl,(unsigned int)nb_flags,
- subrec->subnet_name));
+ DEBUG( 3, ( "add_name_to_subnet: Added netbios name %s with first IP %s \
+ttl=%d nb_flags=%2x to subnet %s\n",
+ namestr(&namerec->name),
+ inet_ntoa(*iplist),
+ ttl,
+ (unsigned int)nb_flags,
+ subrec->subnet_name) );
subrec->namelist_changed = True;
@@ -250,13 +259,14 @@ void standard_success_register(struct subnet_record *subrec,
struct nmb_name *nmbname, uint16 nb_flags, int ttl,
struct in_addr registered_ip)
{
- struct name_record *namerec = find_name_on_subnet(subrec, nmbname, FIND_SELF_NAME);
+ struct name_record *namerec;
- if(namerec == NULL)
- add_name_to_subnet(subrec, nmbname->name, nmbname->name_type,
- nb_flags, ttl, SELF_NAME, 1, &registered_ip);
+ namerec = find_name_on_subnet( subrec, nmbname, FIND_SELF_NAME );
+ if( NULL == namerec )
+ add_name_to_subnet( subrec, nmbname->name, nmbname->name_type,
+ nb_flags, ttl, SELF_NAME, 1, &registered_ip );
else
- update_name_ttl(namerec, ttl);
+ update_name_ttl( namerec, ttl );
}
/*******************************************************************
@@ -264,16 +274,20 @@ void standard_success_register(struct subnet_record *subrec,
fails.
******************************************************************/
-void standard_fail_register(struct subnet_record *subrec,
- struct response_record *rrec, struct nmb_name *nmbname)
+void standard_fail_register( struct subnet_record *subrec,
+ struct response_record *rrec,
+ struct nmb_name *nmbname )
{
- struct name_record *namerec = find_name_on_subnet(subrec, nmbname, FIND_SELF_NAME);
+ struct name_record *namerec;
- DEBUG(0,("standard_fail_register: Failed to register/refresh name %s on subnet %s\n",
- namestr(nmbname), subrec->subnet_name));
+ namerec = find_name_on_subnet( subrec, nmbname, FIND_SELF_NAME );
+
+ DEBUG( 0, ( "standard_fail_register: Failed to register/refresh name %s \
+on subnet %s\n",
+ namestr(nmbname), subrec->subnet_name) );
/* Remove the name from the subnet. */
- if(namerec)
+ if( namerec )
remove_name_from_namelist(subrec, namerec);
}
@@ -283,11 +297,12 @@ void standard_fail_register(struct subnet_record *subrec,
static void remove_nth_ip_in_record( struct name_record *namerec, int ind)
{
- if(ind != namerec->num_ips)
- memmove( (char *)(&namerec->ip[ind]), (char *)(&namerec->ip[ind+1]),
- ( namerec->num_ips - ind - 1) * sizeof(struct in_addr));
+ if( ind != namerec->data.num_ips )
+ memmove( (char *)(&namerec->data.ip[ind]),
+ (char *)(&namerec->data.ip[ind+1]),
+ ( namerec->data.num_ips - ind - 1) * sizeof(struct in_addr) );
- namerec->num_ips--;
+ namerec->data.num_ips--;
namerec->subnet->namelist_changed = True;
}
@@ -295,12 +310,12 @@ static void remove_nth_ip_in_record( struct name_record *namerec, int ind)
Utility function to check if an IP address exists in a name record.
******************************************************************/
-BOOL find_ip_in_name_record(struct name_record *namerec, struct in_addr ip)
+BOOL find_ip_in_name_record( struct name_record *namerec, struct in_addr ip )
{
int i;
- for(i = 0; i < namerec->num_ips; i++)
- if(ip_equal( namerec->ip[i], ip))
+ for(i = 0; i < namerec->data.num_ips; i++)
+ if(ip_equal( namerec->data.ip[i], ip))
return True;
return False;
@@ -318,18 +333,22 @@ void add_ip_to_name_record(struct name_record *namerec, struct in_addr new_ip)
if(find_ip_in_name_record( namerec, new_ip))
return;
- if((new_list = (struct in_addr *)malloc( (namerec->num_ips + 1)*sizeof(struct in_addr)) )== NULL)
+ new_list = (struct in_addr *)malloc( (namerec->data.num_ips + 1)
+ * sizeof(struct in_addr) );
+ if( NULL == new_list )
{
DEBUG(0,("add_ip_to_name_record: Malloc fail !\n"));
return;
}
- memcpy((char *)new_list, (char *)namerec->ip, namerec->num_ips *sizeof(struct in_addr));
- new_list[namerec->num_ips] = new_ip;
+ memcpy( (char *)new_list,
+ (char *)namerec->data.ip,
+ namerec->data.num_ips * sizeof(struct in_addr) );
+ new_list[namerec->data.num_ips] = new_ip;
- free((char *)namerec->ip);
- namerec->ip = new_list;
- namerec->num_ips += 1;
+ free((char *)namerec->data.ip);
+ namerec->data.ip = new_list;
+ namerec->data.num_ips += 1;
namerec->subnet->namelist_changed = True;
}
@@ -338,14 +357,15 @@ void add_ip_to_name_record(struct name_record *namerec, struct in_addr new_ip)
Utility function to remove an IP address from a name record.
******************************************************************/
-void remove_ip_from_name_record( struct name_record *namerec, struct in_addr remove_ip)
+void remove_ip_from_name_record( struct name_record *namerec,
+ struct in_addr remove_ip )
{
/* Try and find the requested ip address - remove it. */
int i;
- int orig_num = namerec->num_ips;
+ int orig_num = namerec->data.num_ips;
for(i = 0; i < orig_num; i++)
- if( ip_equal( remove_ip, namerec->ip[i]) )
+ if( ip_equal( remove_ip, namerec->data.ip[i]) )
{
remove_nth_ip_in_record( namerec, i);
break;
@@ -358,31 +378,40 @@ void remove_ip_from_name_record( struct name_record *namerec, struct in_addr rem
duplication of success_function code.
******************************************************************/
-void standard_success_release(struct subnet_record *subrec,
- struct userdata_struct *userdata,
- struct nmb_name *nmbname, struct in_addr released_ip)
+void standard_success_release( struct subnet_record *subrec,
+ struct userdata_struct *userdata,
+ struct nmb_name *nmbname,
+ struct in_addr released_ip )
{
- struct name_record *namerec = find_name_on_subnet(subrec, nmbname, FIND_ANY_NAME);
+ struct name_record *namerec;
+
+ namerec = find_name_on_subnet( subrec, nmbname, FIND_ANY_NAME );
- if(namerec == NULL)
+ if( namerec == NULL )
{
- DEBUG(0,("standard_success_release: Name release for name %s IP %s on subnet %s. Name \
-was not found on subnet.\n", namestr(nmbname), inet_ntoa(released_ip), subrec->subnet_name));
+ DEBUG( 0, ( "standard_success_release: Name release for name %s IP %s \
+on subnet %s. Name was not found on subnet.\n",
+ namestr(nmbname),
+ inet_ntoa(released_ip),
+ subrec->subnet_name) );
return;
}
else
{
- int orig_num = namerec->num_ips;
+ int orig_num = namerec->data.num_ips;
- remove_ip_from_name_record( namerec, released_ip);
+ remove_ip_from_name_record( namerec, released_ip );
- if(namerec->num_ips == orig_num)
- DEBUG(0,("standard_success_release: Name release for name %s IP %s on subnet %s. This ip \
-is not known for this name.\n", namestr(nmbname), inet_ntoa(released_ip), subrec->subnet_name ));
+ if( namerec->data.num_ips == orig_num )
+ DEBUG( 0, ( "standard_success_release: Name release for name %s IP %s \
+on subnet %s. This ip is not known for this name.\n",
+ namestr(nmbname),
+ inet_ntoa(released_ip),
+ subrec->subnet_name ) );
}
- if (namerec->num_ips == 0)
- remove_name_from_namelist(subrec, namerec);
+ if( namerec->data.num_ips == 0 )
+ remove_name_from_namelist( subrec, namerec );
}
/*******************************************************************
@@ -397,17 +426,19 @@ void expire_names_on_subnet(struct subnet_record *subrec, time_t t)
for (namerec = subrec->namelist; namerec; namerec = next_namerec)
{
next_namerec = namerec->next;
- if ((namerec->death_time != PERMANENT_TTL) && (namerec->death_time < t))
+ if( (namerec->data.death_time != PERMANENT_TTL)
+ && (namerec->data.death_time < t) )
{
- if (namerec->source == SELF_NAME)
+ if (namerec->data.source == SELF_NAME)
{
- DEBUG(3,("expire_names_on_subnet: Subnet %s not expiring SELF name %s\n",
- subrec->subnet_name, namestr(&namerec->name)));
- namerec->death_time += 300;
+ DEBUG( 3, ( "expire_names_on_subnet: Subnet %s not expiring SELF \
+name %s\n",
+ subrec->subnet_name, namestr(&namerec->name) ) );
+ namerec->data.death_time += 300;
namerec->subnet->namelist_changed = True;
continue;
}
- DEBUG(3,("expire_names_on_subnet: Subnet %s - removing expired name %s\n",
+ DEBUG(3,("expire_names_on_subnet: Subnet %s - removing expired name %s\n",
subrec->subnet_name, namestr(&namerec->name)));
remove_name_from_namelist(subrec, namerec);
@@ -423,9 +454,11 @@ void expire_names(time_t t)
{
struct subnet_record *subrec;
- for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
+ for( subrec = FIRST_SUBNET;
+ subrec;
+ subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec) )
{
- expire_names_on_subnet(subrec, t);
+ expire_names_on_subnet( subrec, t );
}
}
@@ -437,7 +470,7 @@ void expire_names(time_t t)
all broadcast subnet IP addresses.
**************************************************************************/
-void add_samba_names_to_subnet(struct subnet_record *subrec)
+void add_samba_names_to_subnet( struct subnet_record *subrec )
{
struct in_addr *iplist = &subrec->myip;
int num_ips = 1;
@@ -453,14 +486,16 @@ void add_samba_names_to_subnet(struct subnet_record *subrec)
/* Create an IP list containing all our known subnets. */
num_ips = iface_count();
- if((iplist = (struct in_addr *)malloc( num_ips * sizeof(struct in_addr) )) == NULL)
+ iplist = (struct in_addr *)malloc( num_ips * sizeof(struct in_addr) );
+ if( NULL == iplist )
{
DEBUG(0,("add_samba_names_to_subnet: Malloc fail !\n"));
return;
}
- for(bcast_subrecs = FIRST_SUBNET, i = 0; bcast_subrecs;
- bcast_subrecs = NEXT_SUBNET_EXCLUDING_UNICAST(bcast_subrecs), i++)
+ for( bcast_subrecs = FIRST_SUBNET, i = 0;
+ bcast_subrecs;
+ bcast_subrecs = NEXT_SUBNET_EXCLUDING_UNICAST(bcast_subrecs), i++ )
iplist[i] = bcast_subrecs->myip;
}
@@ -494,7 +529,7 @@ static void dump_subnet_namelist( struct subnet_record *subrec, FILE *fp)
for (namerec = subrec->namelist; namerec; namerec = namerec->next)
{
fprintf(fp,"\tName = %s\t", namestr(&namerec->name));
- switch(namerec->source)
+ switch(namerec->data.source)
{
case LMHOSTS_NAME:
src_type = "LMHOSTS_NAME";
@@ -521,27 +556,27 @@ static void dump_subnet_namelist( struct subnet_record *subrec, FILE *fp)
src_type = "unknown!";
break;
}
- fprintf(fp, "Source = %s\nb_flags = %x\t", src_type, namerec->nb_flags);
+ fprintf(fp,"Source = %s\nb_flags = %x\t", src_type, namerec->data.nb_flags);
- if(namerec->death_time != PERMANENT_TTL)
+ if(namerec->data.death_time != PERMANENT_TTL)
{
- tm = LocalTime(&namerec->death_time);
+ tm = LocalTime(&namerec->data.death_time);
fprintf(fp, "death_time = %s\t", asctime(tm));
}
else
fprintf(fp, "death_time = PERMANENT\t");
- if(namerec->refresh_time != PERMANENT_TTL)
+ if(namerec->data.refresh_time != PERMANENT_TTL)
{
- tm = LocalTime(&namerec->refresh_time);
+ tm = LocalTime(&namerec->data.refresh_time);
fprintf(fp, "refresh_time = %s\n", asctime(tm));
}
else
fprintf(fp, "refresh_time = PERMANENT\n");
- fprintf(fp, "\t\tnumber of IPS = %d", namerec->num_ips);
- for(i = 0; i < namerec->num_ips; i++)
- fprintf(fp, "\t%s", inet_ntoa(namerec->ip[i]));
+ fprintf(fp, "\t\tnumber of IPS = %d", namerec->data.num_ips);
+ for(i = 0; i < namerec->data.num_ips; i++)
+ fprintf(fp, "\t%s", inet_ntoa(namerec->data.ip[i]));
fprintf(fp, "\n\n");
}
@@ -572,7 +607,9 @@ void dump_all_namelists(void)
return;
}
- for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
+ for( subrec = FIRST_SUBNET;
+ subrec;
+ subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec) )
dump_subnet_namelist( subrec, fp);
if(!we_are_a_wins_client())
diff --git a/source3/nmbd/nmbd_namequery.c b/source3/nmbd/nmbd_namequery.c
index 509b3b3107..7c2b0d4d76 100644
--- a/source3/nmbd/nmbd_namequery.c
+++ b/source3/nmbd/nmbd_namequery.c
@@ -37,7 +37,8 @@ static void query_name_response(struct subnet_record *subrec,
{
struct nmb_packet *nmb = &p->packet.nmb;
BOOL success = False;
- struct nmb_name *question_name = &rrec->packet->packet.nmb.question.question_name;
+ struct nmb_name *question_name =
+ &rrec->packet->packet.nmb.question.question_name;
struct in_addr answer_ip;
/* Ensure we don't retry the query but leave the response record cleanup
@@ -157,8 +158,9 @@ static BOOL query_local_namelists(struct subnet_record *subrec, struct nmb_name
if((namerec = find_name_on_subnet(subrec, nmbname, FIND_ANY_NAME))==NULL)
return False;
- if(NAME_IS_ACTIVE(namerec) && ((namerec->source == SELF_NAME) ||
- (namerec->source == LMHOSTS_NAME)) )
+ if( NAME_IS_ACTIVE(namerec)
+ && ( (namerec->data.source == SELF_NAME)
+ || (namerec->data.source == LMHOSTS_NAME) ) )
{
*namerecp = namerec;
return True;
@@ -198,23 +200,23 @@ BOOL query_name(struct subnet_record *subrec, char *name, int type,
rrec.rr_type = RR_TYPE_NB;
rrec.rr_class = RR_CLASS_IN;
rrec.ttl = PERMANENT_TTL;
- rrec.rdlength = namerec->num_ips * 6;
+ rrec.rdlength = namerec->data.num_ips * 6;
if(rrec.rdlength > MAX_DGRAM_SIZE)
{
DEBUG(0,("query_name: nmbd internal error - there are %d ip addresses for name %s.\n",
- namerec->num_ips, namestr(&nmbname) ));
+ namerec->data.num_ips, namestr(&nmbname) ));
return False;
}
- for( i = 0; i < namerec->num_ips; i++)
+ for( i = 0; i < namerec->data.num_ips; i++)
{
- set_nb_flags( &rrec.rdata[i*6], namerec->nb_flags );
- putip( &rrec.rdata[(i*6) + 2], (char *)&namerec->ip[i]);
+ set_nb_flags( &rrec.rdata[i*6], namerec->data.nb_flags );
+ putip( &rrec.rdata[(i*6) + 2], (char *)&namerec->data.ip[i]);
}
/* Call the success function directly. */
if(success_fn)
- (*success_fn)(subrec, userdata, &nmbname, namerec->ip[0], &rrec);
+ (*success_fn)(subrec, userdata, &nmbname, namerec->data.ip[0], &rrec);
return False;
}
diff --git a/source3/nmbd/nmbd_nameregister.c b/source3/nmbd/nmbd_nameregister.c
index 8eae5e0f1c..a4b8d4d65a 100644
--- a/source3/nmbd/nmbd_nameregister.c
+++ b/source3/nmbd/nmbd_nameregister.c
@@ -372,16 +372,16 @@ BOOL refresh_name(struct subnet_record *subrec, struct name_record *namerec,
* only be done once).
*/
- for( i = 0; i < namerec->num_ips; i++)
+ for( i = 0; i < namerec->data.num_ips; i++)
{
if(queue_refresh_name( subrec,
register_name_response,
register_name_timeout_response,
- (i == (namerec->num_ips - 1)) ? success_fn : NULL,
- (i == (namerec->num_ips - 1)) ? fail_fn : NULL,
- (i == (namerec->num_ips - 1)) ? userdata : NULL,
+ (i == (namerec->data.num_ips - 1)) ? success_fn : NULL,
+ (i == (namerec->data.num_ips - 1)) ? fail_fn : NULL,
+ (i == (namerec->data.num_ips - 1)) ? userdata : NULL,
namerec,
- namerec->ip[i]) == NULL)
+ namerec->data.ip[i]) == NULL)
{
DEBUG(0,("refresh_name: Failed to send packet trying to refresh name %s\n",
namestr(&namerec->name)));
diff --git a/source3/nmbd/nmbd_namerelease.c b/source3/nmbd/nmbd_namerelease.c
index f72de8c20e..b58bab3a1d 100644
--- a/source3/nmbd/nmbd_namerelease.c
+++ b/source3/nmbd/nmbd_namerelease.c
@@ -201,15 +201,15 @@ BOOL release_name(struct subnet_record *subrec, struct name_record *namerec,
int i;
/* Ensure it's a SELF name, and in the ACTIVE state. */
- if((namerec->source != SELF_NAME) || !NAME_IS_ACTIVE(namerec))
+ if((namerec->data.source != SELF_NAME) || !NAME_IS_ACTIVE(namerec))
{
DEBUG(0,("release_name: Cannot release name %s from subnet %s. Source was %d \n",
- namestr(&namerec->name), subrec->subnet_name, namerec->source));
+ namestr(&namerec->name), subrec->subnet_name, namerec->data.source));
return True;
}
/* Set the name into the deregistering state. */
- namerec->nb_flags |= NB_DEREG;
+ namerec->data.nb_flags |= NB_DEREG;
/*
* Go through and release the name for all known ip addresses.
@@ -217,20 +217,20 @@ BOOL release_name(struct subnet_record *subrec, struct name_record *namerec,
* only be done once).
*/
- for( i = 0; i < namerec->num_ips; i++)
+ for( i = 0; i < namerec->data.num_ips; i++)
{
if(queue_release_name( subrec,
release_name_response,
release_name_timeout_response,
- (i == (namerec->num_ips - 1)) ? success_fn : NULL,
- (i == (namerec->num_ips - 1)) ? fail_fn : NULL,
- (i == (namerec->num_ips - 1)) ? userdata : NULL,
+ (i == (namerec->data.num_ips - 1)) ? success_fn : NULL,
+ (i == (namerec->data.num_ips - 1)) ? fail_fn : NULL,
+ (i == (namerec->data.num_ips - 1)) ? userdata : NULL,
&namerec->name,
- namerec->nb_flags,
- namerec->ip[i]) == NULL)
+ namerec->data.nb_flags,
+ namerec->data.ip[i]) == NULL)
{
DEBUG(0,("release_name: Failed to send packet trying to release name %s IP %s\n",
- namestr(&namerec->name), inet_ntoa(namerec->ip[i]) ));
+ namestr(&namerec->name), inet_ntoa(namerec->data.ip[i]) ));
return True;
}
}
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index b62f0aff62..e07391fb48 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -629,7 +629,7 @@ struct response_record *queue_refresh_name( struct subnet_record *subrec,
subrec->bcast_ip)) == NULL)
return NULL;
- if(initiate_name_refresh_packet( p, namerec->nb_flags, &refresh_ip) == False)
+ if( !initiate_name_refresh_packet( p, namerec->data.nb_flags, &refresh_ip ) )
{
p->locked = False;
free_packet(p);
diff --git a/source3/nmbd/nmbd_winsproxy.c b/source3/nmbd/nmbd_winsproxy.c
index ded37ebf30..97caef7f82 100644
--- a/source3/nmbd/nmbd_winsproxy.c
+++ b/source3/nmbd/nmbd_winsproxy.c
@@ -94,13 +94,17 @@ returned for name %s.\n", namestr(nmbname) ));
if(namerec && original_packet->packet.nmb.header.nm_flags.bcast)
{
- for( i = 0; i < namerec->num_ips; i++)
+ for( i = 0; i < namerec->data.num_ips; i++)
{
- if(same_net( namerec->ip[i], orig_broadcast_subnet->myip, orig_broadcast_subnet->mask_ip ))
+ if( same_net( namerec->data.ip[i],
+ orig_broadcast_subnet->myip,
+ orig_broadcast_subnet->mask_ip ) )
{
- DEBUG(5,("wins_proxy_name_query_request_success: name %s is a WINS proxy name and is also \
-on the same subnet (%s) as the requestor. Not replying.\n",
- namestr(&namerec->name), orig_broadcast_subnet->subnet_name ));
+ DEBUG( 5, ( "wins_proxy_name_query_request_success: name %s is a WINS \
+proxy name and is also on the same subnet (%s) as the requestor. \
+Not replying.\n",
+ namestr(&namerec->name),
+ orig_broadcast_subnet->subnet_name ) );
return;
}
}
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index e1f0fbae8f..89e602606b 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -529,8 +529,9 @@ static void wins_register_query_fail(struct subnet_record *subrec,
namerec = find_name_on_subnet(subrec, question_name, FIND_ANY_NAME);
- if((namerec != NULL) && (namerec->source == REGISTER_NAME) &&
- ip_equal(rrec->packet->ip, *namerec->ip) )
+ if( (namerec != NULL)
+ && (namerec->data.source == REGISTER_NAME)
+ && ip_equal(rrec->packet->ip, *namerec->data.ip) )
{
remove_name_from_namelist( subrec, namerec);
namerec = NULL;
@@ -646,11 +647,13 @@ IP %s\n", registering_group_name ? "Group" : "Unique", namestr(question), inet_n
* name.
*/
- if((namerec != NULL) && ((namerec->source == DNS_NAME) || (namerec->source == DNSFAIL_NAME)))
+ if( (namerec != NULL)
+ && ( (namerec->data.source == DNS_NAME)
+ || (namerec->data.source == DNSFAIL_NAME) ) )
{
- DEBUG(5,("wins_process_name_registration_request: Name (%s) in WINS was a dns lookup \
-- removing it.\n", namestr(question) ));
- remove_name_from_namelist( subrec, namerec);
+ DEBUG(5,("wins_process_name_registration_request: Name (%s) in WINS was \
+a dns lookup - removing it.\n", namestr(question) ));
+ remove_name_from_namelist( subrec, namerec );
namerec = NULL;
}
@@ -659,10 +662,11 @@ IP %s\n", registering_group_name ? "Group" : "Unique", namestr(question), inet_n
* (ie. Don't allow any static names to be overwritten.
*/
- if((namerec != NULL) && (namerec->source != REGISTER_NAME))
+ if((namerec != NULL) && (namerec->data.source != REGISTER_NAME))
{
- DEBUG(3,("wins_process_name_registration_request: Attempt to register name %s. Name \
-already exists in WINS with source type %d.\n", namestr(question), namerec->source ));
+ DEBUG( 3, ( "wins_process_name_registration_request: Attempt \
+to register name %s. Name already exists in WINS with source type %d.\n",
+ namestr(question), namerec->data.source ));
send_wins_name_registration_response(RFS_ERR, 0, p);
return;
}
@@ -768,11 +772,13 @@ is one of our (WINS server) names. Denying registration.\n", namestr(question) )
* is the same as the the (single) already registered IP then just update the ttl.
*/
- if(!registering_group_name && (namerec != NULL) && (namerec->num_ips == 1) &&
- ip_equal(namerec->ip[0], from_ip))
+ if( !registering_group_name
+ && (namerec != NULL)
+ && (namerec->data.num_ips == 1)
+ && ip_equal( namerec->data.ip[0], from_ip ) )
{
- update_name_ttl(namerec, ttl);
- send_wins_name_registration_response(0, ttl, p);
+ update_name_ttl( namerec, ttl );
+ send_wins_name_registration_response( 0, ttl, p );
return;
}
@@ -781,7 +787,7 @@ is one of our (WINS server) names. Denying registration.\n", namestr(question) )
* to see if they still claim to have the name.
*/
- if(namerec != NULL)
+ if( namerec != NULL )
{
char ud[sizeof(struct userdata_struct) + sizeof(struct packet_struct *)];
struct userdata_struct *userdata = (struct userdata_struct *)ud;
@@ -815,10 +821,12 @@ is one of our (WINS server) names. Denying registration.\n", namestr(question) )
* code. JRA.
*/
- query_name_from_wins_server( *namerec->ip, question->name, question->name_type,
- wins_register_query_success,
- wins_register_query_fail,
- userdata);
+ query_name_from_wins_server( *namerec->data.ip,
+ question->name,
+ question->name_type,
+ wins_register_query_success,
+ wins_register_query_fail,
+ userdata );
return;
}
@@ -870,7 +878,7 @@ static void wins_multihomed_register_query_success(struct subnet_record *subrec,
namerec = find_name_on_subnet(subrec, question_name, FIND_ANY_NAME);
- if( (namerec == NULL) || (namerec->source != REGISTER_NAME) )
+ if( (namerec == NULL) || (namerec->data.source != REGISTER_NAME) )
{
DEBUG(3,("wins_multihomed_register_query_success: name %s is not in the correct state to add \
a subsequent IP addess.\n", namestr(question_name) ));
@@ -981,7 +989,9 @@ to register name %s from IP %s.", namestr(question), inet_ntoa(p->ip) ));
* name.
*/
- if((namerec != NULL) && ((namerec->source == DNS_NAME) || (namerec->source == DNSFAIL_NAME)))
+ if( (namerec != NULL)
+ && ( (namerec->data.source == DNS_NAME)
+ || (namerec->data.source == DNSFAIL_NAME) ) )
{
DEBUG(5,("wins_process_multihomed_name_registration_request: Name (%s) in WINS was a dns lookup \
- removing it.\n", namestr(question) ));
@@ -994,10 +1004,11 @@ to register name %s from IP %s.", namestr(question), inet_ntoa(p->ip) ));
* (ie. Don't allow any static names to be overwritten.
*/
- if((namerec != NULL) && (namerec->source != REGISTER_NAME))
+ if( (namerec != NULL) && (namerec->data.source != REGISTER_NAME) )
{
- DEBUG(3,("wins_process_multihomed_name_registration_request: Attempt to register name %s. Name \
-already exists in WINS with source type %d.\n", namestr(question), namerec->source ));
+ DEBUG( 3, ( "wins_process_multihomed_name_registration_request: Attempt \
+to register name %s. Name already exists in WINS with source type %d.\n",
+ namestr(question), namerec->data.source ));
send_wins_name_registration_response(RFS_ERR, 0, p);
return;
}
@@ -1139,7 +1150,7 @@ static void process_wins_dmb_query_request(struct subnet_record *subrec,
for(namerec = subrec->namelist; namerec; namerec = namerec->next)
{
if(namerec->name.name_type == 0x1b)
- num_ips += namerec->num_ips;
+ num_ips += namerec->data.num_ips;
}
if(num_ips == 0)
@@ -1169,10 +1180,10 @@ static void process_wins_dmb_query_request(struct subnet_record *subrec,
if(namerec->name.name_type == 0x1b)
{
int i;
- for(i = 0; i < namerec->num_ips; i++)
+ for(i = 0; i < namerec->data.num_ips; i++)
{
- set_nb_flags(&prdata[num_ips * 6],namerec->nb_flags);
- putip((char *)&prdata[(num_ips * 6) + 2], &namerec->ip[i]);
+ set_nb_flags(&prdata[num_ips * 6],namerec->data.nb_flags);
+ putip((char *)&prdata[(num_ips * 6) + 2], &namerec->data.ip[i]);
num_ips++;
}
}
@@ -1213,18 +1224,18 @@ void send_wins_name_query_response(int rcode, struct packet_struct *p,
{
int same_net_index = -1;
- ttl = (namerec->death_time != PERMANENT_TTL) ?
- namerec->death_time - p->timestamp : lp_max_wins_ttl();
+ ttl = (namerec->data.death_time != PERMANENT_TTL) ?
+ namerec->data.death_time - p->timestamp : lp_max_wins_ttl();
/* Copy all known ip addresses into the return data. */
/* Optimise for the common case of one IP address so
we don't need a malloc. */
- if(namerec->num_ips == 1 )
+ if( namerec->data.num_ips == 1 )
prdata = rdata;
else
{
- if((prdata = (char *)malloc( namerec->num_ips * 6 )) == NULL)
+ if((prdata = (char *)malloc( namerec->data.num_ips * 6 )) == NULL)
{
DEBUG(0,("send_wins_name_query_response: malloc fail !\n"));
return;
@@ -1244,12 +1255,12 @@ void send_wins_name_query_response(int rcode, struct packet_struct *p,
{
struct in_addr *n_mask = iface_nmask(p->ip);
- for( j = 0; j < namerec->num_ips; j++)
+ for( j = 0; j < namerec->data.num_ips; j++)
{
- if(same_net( namerec->ip[j], p->ip, *n_mask))
+ if(same_net( namerec->data.ip[j], p->ip, *n_mask))
{
- set_nb_flags(&prdata[0],namerec->nb_flags);
- putip((char *)&prdata[2], &namerec->ip[j]);
+ set_nb_flags(&prdata[0],namerec->data.nb_flags);
+ putip((char *)&prdata[2], &namerec->data.ip[j]);
same_net_index = j;
i = 1;
}
@@ -1257,15 +1268,15 @@ void send_wins_name_query_response(int rcode, struct packet_struct *p,
}
}
- for(j = 0; j < namerec->num_ips; j++)
+ for(j = 0; j < namerec->data.num_ips; j++)
{
if(j == same_net_index)
continue;
- set_nb_flags(&prdata[i*6],namerec->nb_flags);
- putip((char *)&prdata[2+(i*6)], &namerec->ip[j]);
+ set_nb_flags(&prdata[i*6],namerec->data.nb_flags);
+ putip((char *)&prdata[2+(i*6)], &namerec->data.ip[j]);
i++;
}
- reply_data_len = namerec->num_ips * 6;
+ reply_data_len = namerec->data.num_ips * 6;
}
@@ -1316,7 +1327,7 @@ void wins_process_name_query_request(struct subnet_record *subrec,
* If it's a DNSFAIL_NAME then reply name not found.
*/
- if(namerec->source == DNSFAIL_NAME)
+ if( namerec->data.source == DNSFAIL_NAME )
{
DEBUG(3,("wins_process_name_query: name query for name %s returning DNS fail.\n",
namestr(question) ));
@@ -1328,7 +1339,8 @@ void wins_process_name_query_request(struct subnet_record *subrec,
* If the name has expired then reply name not found.
*/
- if((namerec->death_time != PERMANENT_TTL) && (namerec->death_time < p->timestamp))
+ if( (namerec->data.death_time != PERMANENT_TTL)
+ && (namerec->data.death_time < p->timestamp) )
{
DEBUG(3,("wins_process_name_query: name query for name %s - name expired. Returning fail.\n",
namestr(question) ));
@@ -1337,7 +1349,7 @@ void wins_process_name_query_request(struct subnet_record *subrec,
}
DEBUG(3,("wins_process_name_query: name query for name %s returning first IP %s.\n",
- namestr(question), inet_ntoa(namerec->ip[0]) ));
+ namestr(question), inet_ntoa(namerec->data.ip[0]) ));
send_wins_name_query_response(0, p, namerec);
return;
@@ -1437,7 +1449,8 @@ to release name %s from IP %s.", namestr(question), inet_ntoa(p->ip) ));
namerec = find_name_on_subnet(subrec, question, FIND_ANY_NAME);
- if((namerec == NULL) || ((namerec != NULL) && (namerec->source != REGISTER_NAME)) )
+ if( (namerec == NULL)
+ || ((namerec != NULL) && (namerec->data.source != REGISTER_NAME)) )
{
send_wins_name_release_response(NAM_ERR, p);
return;
@@ -1479,7 +1492,7 @@ release name %s as IP %s is not one of the known IP's for this name.\n",
/*
* Remove the name entirely if no IP addresses left.
*/
- if (namerec->num_ips == 0)
+ if (namerec->data.num_ips == 0)
remove_name_from_namelist(subrec, namerec);
}
@@ -1544,27 +1557,27 @@ void wins_write_database(void)
DEBUG(4,("%-19s ", namestr(&namerec->name) ));
- if(namerec->death_time != PERMANENT_TTL)
+ if( namerec->data.death_time != PERMANENT_TTL )
{
- tm = LocalTime(&namerec->death_time);
+ tm = LocalTime(&namerec->data.death_time);
DEBUG(4,("TTL = %s", asctime(tm) ));
}
else
DEBUG(4,("TTL = PERMANENT\t"));
- for (i = 0; i < namerec->num_ips; i++)
- DEBUG(4,("%15s ", inet_ntoa(namerec->ip[i]) ));
- DEBUG(4,("%2x\n", namerec->nb_flags ));
+ for (i = 0; i < namerec->data.num_ips; i++)
+ DEBUG(4,("%15s ", inet_ntoa(namerec->data.ip[i]) ));
+ DEBUG(4,("%2x\n", namerec->data.nb_flags ));
- if (namerec->source == REGISTER_NAME)
+ if( namerec->data.source == REGISTER_NAME )
{
fprintf(fp, "\"%s#%02x\" %d ",
namerec->name.name,namerec->name.name_type, /* Ignore scope. */
- (int)namerec->death_time);
+ (int)namerec->data.death_time);
- for (i = 0; i < namerec->num_ips; i++)
- fprintf(fp, "%s ", inet_ntoa(namerec->ip[i]));
- fprintf(fp, "%2xR\n", namerec->nb_flags);
+ for (i = 0; i < namerec->data.num_ips; i++)
+ fprintf( fp, "%s ", inet_ntoa( namerec->data.ip[i] ) );
+ fprintf( fp, "%2xR\n", namerec->data.nb_flags );
}
}