summaryrefslogtreecommitdiff
path: root/source4/nbt_server/interfaces.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-07 11:49:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:35 -0500
commitd09311baa72c0ffa6768a379053dc0bfd38ecbdb (patch)
tree5d55bec4fc1dc3afe1c4a20ef2119d185d850070 /source4/nbt_server/interfaces.c
parentf0b403f27a59306b0b463e48f02a5d705fe37d26 (diff)
downloadsamba-d09311baa72c0ffa6768a379053dc0bfd38ecbdb.tar.gz
samba-d09311baa72c0ffa6768a379053dc0bfd38ecbdb.tar.bz2
samba-d09311baa72c0ffa6768a379053dc0bfd38ecbdb.zip
r5259: make sure we give the ip of the interface that a name query comes in
on as the first IP in a multi-homed reply (This used to be commit a9128f6544d56a637e28430cbd2907acbb978281)
Diffstat (limited to 'source4/nbt_server/interfaces.c')
-rw-r--r--source4/nbt_server/interfaces.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c
index b99c17089c..a75275dec7 100644
--- a/source4/nbt_server/interfaces.c
+++ b/source4/nbt_server/interfaces.c
@@ -234,18 +234,35 @@ NTSTATUS nbtd_startup_interfaces(struct nbtd_server *nbtsrv)
/*
form a list of addresses that we should use in name query replies
+ we always place the IP in the given interface first
*/
-const char **nbtd_address_list(struct nbtd_server *nbtsrv, TALLOC_CTX *mem_ctx)
+const char **nbtd_address_list(struct nbtd_interface *iface, TALLOC_CTX *mem_ctx)
{
+ struct nbtd_server *nbtsrv = iface->nbtsrv;
const char **ret = NULL;
- struct nbtd_interface *iface;
- int count = 0;
+ struct nbtd_interface *iface2;
+ int count;
+
+ ret = talloc_array(mem_ctx, const char *, 2);
+ if (ret == NULL) goto failed;
+
+ ret[0] = talloc_strdup(ret, iface->ip_address);
+ if (ret[0] == NULL) goto failed;
+ ret[1] = NULL;
+
+ count = 1;
+
+ for (iface2=nbtsrv->interfaces;iface2;iface2=iface2->next) {
+ const char **ret2;
+
+ if (strcmp(iface2->ip_address, iface->ip_address) == 0) {
+ continue;
+ }
- for (iface=nbtsrv->interfaces;iface;iface=iface->next) {
- const char **ret2 = talloc_realloc(mem_ctx, ret, const char *, count+2);
+ ret2 = talloc_realloc(mem_ctx, ret, const char *, count+2);
if (ret2 == NULL) goto failed;
ret = ret2;
- ret[count] = talloc_strdup(ret, iface->ip_address);
+ ret[count] = talloc_strdup(ret, iface2->ip_address);
if (ret[count] == NULL) goto failed;
count++;
}