summaryrefslogtreecommitdiff
path: root/source4/libcli/resolve/nbtlist.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-12-13 20:50:36 +0100
committerStefan Metzmacher <metze@samba.org>2008-12-17 20:26:38 +0100
commit7d0e78a52cfed797100696725611655227cf01ac (patch)
tree27a53cf8c534b559290720533e8984b278a2c988 /source4/libcli/resolve/nbtlist.c
parent937fdb8a7e348103708adbdafcff28b05cc1fda3 (diff)
downloadsamba-7d0e78a52cfed797100696725611655227cf01ac.tar.gz
samba-7d0e78a52cfed797100696725611655227cf01ac.tar.bz2
samba-7d0e78a52cfed797100696725611655227cf01ac.zip
s4:libcli/resolve: optionally return the name that belongs to the returned address
E.g. this helps for DNS CNAME and SRV results. metze
Diffstat (limited to 'source4/libcli/resolve/nbtlist.c')
-rw-r--r--source4/libcli/resolve/nbtlist.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c
index 962dd420ab..8d6a5a7a7e 100644
--- a/source4/libcli/resolve/nbtlist.c
+++ b/source4/libcli/resolve/nbtlist.c
@@ -41,6 +41,7 @@ struct nbtlist_state {
struct nbt_name_request **queries;
struct nbt_name_query *io_queries;
struct socket_address **addrs;
+ char **names;
struct interface *ifaces;
};
@@ -82,14 +83,21 @@ static void nbtlist_handler(struct nbt_name_request *req)
q->out.num_addrs + 1);
if (composite_nomem(state->addrs, c)) return;
+ state->names = talloc_array(state, char *, q->out.num_addrs + 1);
+ if (composite_nomem(state->names, c)) return;
+
for (i=0;i<q->out.num_addrs;i++) {
state->addrs[i] = socket_address_from_strings(state->addrs,
"ipv4",
q->out.reply_addrs[i],
0);
if (composite_nomem(state->addrs[i], c)) return;
+
+ state->names[i] = talloc_strdup(state->names, state->name.name);
+ if (composite_nomem(state->names[i], c)) return;
}
state->addrs[i] = NULL;
+ state->names[i] = NULL;
composite_done(c);
}
@@ -184,7 +192,8 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
*/
NTSTATUS resolve_name_nbtlist_recv(struct composite_context *c,
TALLOC_CTX *mem_ctx,
- struct socket_address ***addrs)
+ struct socket_address ***addrs,
+ char ***names)
{
NTSTATUS status;
@@ -193,6 +202,9 @@ NTSTATUS resolve_name_nbtlist_recv(struct composite_context *c,
if (NT_STATUS_IS_OK(status)) {
struct nbtlist_state *state = talloc_get_type(c->private_data, struct nbtlist_state);
*addrs = talloc_steal(mem_ctx, state->addrs);
+ if (names) {
+ *names = talloc_steal(mem_ctx, state->names);
+ }
}
talloc_free(c);