summaryrefslogtreecommitdiff
path: root/source3/nmbd
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-08-30 08:45:23 +0000
committerAndrew Tridgell <tridge@samba.org>1998-08-30 08:45:23 +0000
commit179e8c66f121e01b5e69ad8b1c39f8a1a1e45814 (patch)
treee404f029fbf2641365d5f618217d741cffae462c /source3/nmbd
parent3debe642bd299e1aed8578df342f4bfecf5d8b3b (diff)
downloadsamba-179e8c66f121e01b5e69ad8b1c39f8a1a1e45814.tar.gz
samba-179e8c66f121e01b5e69ad8b1c39f8a1a1e45814.tar.bz2
samba-179e8c66f121e01b5e69ad8b1c39f8a1a1e45814.zip
changed the way that name query records are sorted in replies. They
are now sorted by the number of common leading bits in the IP address with the address of the querying host. (This used to be commit 4460a1bc6aa7666d1c71d32ba73855d6ed32320a)
Diffstat (limited to 'source3/nmbd')
-rw-r--r--source3/nmbd/nmbd_incomingrequests.c3
-rw-r--r--source3/nmbd/nmbd_winsserver.c42
2 files changed, 9 insertions, 36 deletions
diff --git a/source3/nmbd/nmbd_incomingrequests.c b/source3/nmbd/nmbd_incomingrequests.c
index c2b8be212f..97d223b291 100644
--- a/source3/nmbd/nmbd_incomingrequests.c
+++ b/source3/nmbd/nmbd_incomingrequests.c
@@ -555,6 +555,9 @@ on the same subnet (%s) as the requestor. Not replying.\n",
set_nb_flags(&prdata[i*6],namerec->data.nb_flags);
putip((char *)&prdata[2+(i*6)], &namerec->data.ip[i]);
}
+
+ sort_query_replies(prdata, i, p->ip);
+
reply_data_len = namerec->data.num_ips * 6;
success = True;
}
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index e7c6d69cd6..d891124d06 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -1261,15 +1261,12 @@ void send_wins_name_query_response(int rcode, struct packet_struct *p,
char *prdata = rdata;
int reply_data_len = 0;
int ttl = 0;
- int i = 0;
- int j;
+ int i;
bzero(rdata,6);
if(rcode == 0)
{
- int same_net_index = -1;
-
ttl = (namerec->data.death_time != PERMANENT_TTL) ?
namerec->data.death_time - p->timestamp : lp_max_wins_ttl();
@@ -1286,44 +1283,17 @@ void send_wins_name_query_response(int rcode, struct packet_struct *p,
DEBUG(0,("send_wins_name_query_response: malloc fail !\n"));
return;
}
-
- /*
- * Look over the known IP addresses and see if one of them
- * is on the same (local) net as the requesting IP address. If so then
- * put that IP address into the packet as the first IP.
- * We can only do this for local nets as they're the only
- * ones we know the netmask for.
- */
-
- i = 0;
-
- if(is_local_net(p->ip))
- {
- struct in_addr *n_mask = iface_nmask(p->ip);
-
- for( j = 0; j < namerec->data.num_ips; j++)
- {
- if(same_net( namerec->data.ip[j], p->ip, *n_mask))
- {
- set_nb_flags(&prdata[0],namerec->data.nb_flags);
- putip((char *)&prdata[2], &namerec->data.ip[j]);
- same_net_index = j;
- i = 1;
- }
- }
- }
}
- for(j = 0; j < namerec->data.num_ips; j++)
+ for(i = 0; i < namerec->data.num_ips; i++)
{
- if(j == same_net_index)
- continue;
set_nb_flags(&prdata[i*6],namerec->data.nb_flags);
- putip((char *)&prdata[2+(i*6)], &namerec->data.ip[j]);
- i++;
+ putip((char *)&prdata[2+(i*6)], &namerec->data.ip[i]);
}
- reply_data_len = namerec->data.num_ips * 6;
+ sort_query_replies(prdata, i, p->ip);
+
+ reply_data_len = namerec->data.num_ips * 6;
}
reply_netbios_packet(p, /* Packet to reply to. */