diff options
author | Stefan Metzmacher <metze@samba.org> | 2008-12-17 17:25:40 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-12-17 20:28:40 +0100 |
commit | 116fbd6b5a82a2e9f2440aae4ad56cf8a457c85b (patch) | |
tree | 713fd94f73e03ab088206a6af1b9b81ad32832a9 /source4 | |
parent | 7d0e78a52cfed797100696725611655227cf01ac (diff) | |
download | samba-116fbd6b5a82a2e9f2440aae4ad56cf8a457c85b.tar.gz samba-116fbd6b5a82a2e9f2440aae4ad56cf8a457c85b.tar.bz2 samba-116fbd6b5a82a2e9f2440aae4ad56cf8a457c85b.zip |
s4:libcli/resolve: specify the port for the resulting socket_addresses
metze
Diffstat (limited to 'source4')
-rw-r--r-- | source4/libcli/resolve/bcast.c | 3 | ||||
-rw-r--r-- | source4/libcli/resolve/dns_ex.c | 11 | ||||
-rw-r--r-- | source4/libcli/resolve/host.c | 3 | ||||
-rw-r--r-- | source4/libcli/resolve/nbtlist.c | 5 | ||||
-rw-r--r-- | source4/libcli/resolve/resolve.c | 6 | ||||
-rw-r--r-- | source4/libcli/resolve/resolve.h | 1 | ||||
-rw-r--r-- | source4/libcli/resolve/testsuite.c | 2 | ||||
-rw-r--r-- | source4/libcli/resolve/wins.c | 3 |
8 files changed, 25 insertions, 9 deletions
diff --git a/source4/libcli/resolve/bcast.c b/source4/libcli/resolve/bcast.c index 23c8e0ca56..866ce7a152 100644 --- a/source4/libcli/resolve/bcast.c +++ b/source4/libcli/resolve/bcast.c @@ -38,6 +38,7 @@ struct resolve_bcast_data { struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, void *userdata, uint32_t flags, + uint16_t port, struct nbt_name *name) { int num_interfaces; @@ -63,7 +64,7 @@ struct composite_context *resolve_name_bcast_send(TALLOC_CTX *mem_ctx, } address_list[count] = NULL; - c = resolve_name_nbtlist_send(mem_ctx, event_ctx, flags, name, + c = resolve_name_nbtlist_send(mem_ctx, event_ctx, flags, port, name, address_list, data->ifaces, data->nbt_port, data->nbt_timeout, true, false); talloc_free(address_list); diff --git a/source4/libcli/resolve/dns_ex.c b/source4/libcli/resolve/dns_ex.c index cfe4531654..5f08201978 100644 --- a/source4/libcli/resolve/dns_ex.c +++ b/source4/libcli/resolve/dns_ex.c @@ -44,6 +44,7 @@ struct dns_ex_state { bool do_fallback; bool do_srv; uint32_t flags; + uint16_t port; struct nbt_name name; struct socket_address **addrs; char **names; @@ -235,7 +236,7 @@ static void run_child_dns_lookup(struct dns_ex_state *state, int fd) addrs = talloc_asprintf_append_buffer(addrs, "%s%s:%u/%s", first?"":",", inet_ntoa(*addrs_rr[i]->u.a), - srv_rr[i]?srv_rr[i]->u.srv->port:0, + state->port, addrs_rr[i]->domain); if (!addrs) { goto done; @@ -294,7 +295,8 @@ static void run_child_getaddrinfo(struct dns_ex_state *state, int fd) addrs = talloc_asprintf_append_buffer(addrs, "%s%s:%u/%s", first?"":",", inet_ntoa(in->sin_addr), - 0, state->name.name); + state->port, + state->name.name); if (!addrs) { goto done; } @@ -400,7 +402,8 @@ static void pipe_handler(struct event_context *ev, struct fd_event *fde, } port = strtoul(p, NULL, 10); if (port > UINT16_MAX) { - port = 0; + composite_error(c, NT_STATUS_OBJECT_NAME_NOT_FOUND); + return; } state->addrs[i] = socket_address_from_strings(state->addrs, "ipv4", @@ -424,6 +427,7 @@ struct composite_context *resolve_name_dns_ex_send(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, void *privdata, uint32_t flags, + uint16_t port, struct nbt_name *name, bool do_getaddrinfo, bool do_fallback, @@ -457,6 +461,7 @@ struct composite_context *resolve_name_dns_ex_send(TALLOC_CTX *mem_ctx, state->do_fallback = do_fallback; state->do_srv = do_srv; state->flags = flags; + state->port = port; state->child_fd = fd[0]; state->event_ctx = c->event_ctx; diff --git a/source4/libcli/resolve/host.c b/source4/libcli/resolve/host.c index d85c63b5d3..908d173d86 100644 --- a/source4/libcli/resolve/host.c +++ b/source4/libcli/resolve/host.c @@ -35,10 +35,11 @@ struct composite_context *resolve_name_host_send(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, void *privdata, uint32_t flags, + uint16_t port, struct nbt_name *name) { return resolve_name_dns_ex_send(mem_ctx, event_ctx, NULL, flags, - name, true, true, false); + port, name, true, true, false); } /* diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c index 8d6a5a7a7e..2c128e2560 100644 --- a/source4/libcli/resolve/nbtlist.c +++ b/source4/libcli/resolve/nbtlist.c @@ -35,6 +35,7 @@ struct nbtlist_state { uint16_t flags; + uint16_t port; struct nbt_name name; struct nbt_name_socket *nbtsock; int num_queries; @@ -90,7 +91,7 @@ static void nbtlist_handler(struct nbt_name_request *req) state->addrs[i] = socket_address_from_strings(state->addrs, "ipv4", q->out.reply_addrs[i], - 0); + state->port); if (composite_nomem(state->addrs[i], c)) return; state->names[i] = talloc_strdup(state->names, state->name.name); @@ -108,6 +109,7 @@ static void nbtlist_handler(struct nbt_name_request *req) struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, uint32_t flags, + uint16_t port, struct nbt_name *name, const char **address_list, struct interface *ifaces, @@ -130,6 +132,7 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx, c->private_data = state; state->flags = flags; + state->port = port; c->status = nbt_name_dup(state, name, &state->name); if (!composite_is_ok(c)) return c; diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c index b688dc7a76..752678abb8 100644 --- a/source4/libcli/resolve/resolve.c +++ b/source4/libcli/resolve/resolve.c @@ -32,6 +32,7 @@ struct resolve_state { struct resolve_context *ctx; struct resolve_method *method; uint32_t flags; + uint16_t port; struct nbt_name name; struct composite_context *creq; struct socket_address **addrs; @@ -116,6 +117,7 @@ static struct composite_context *setup_next_method(struct composite_context *c) creq = state->method->send_fn(c, c->event_ctx, state->method->privdata, state->flags, + state->port, &state->name); } if (creq == NULL && state->method) state->method = state->method->next; @@ -135,6 +137,7 @@ static struct composite_context *setup_next_method(struct composite_context *c) */ struct composite_context *resolve_name_all_send(struct resolve_context *ctx, uint32_t flags, + uint16_t port, struct nbt_name *name, struct event_context *event_ctx) { @@ -155,6 +158,7 @@ struct composite_context *resolve_name_all_send(struct resolve_context *ctx, c->private_data = state; state->flags = flags; + state->port = port; c->status = nbt_name_dup(state, name, &state->name); if (!composite_is_ok(c)) return c; @@ -220,7 +224,7 @@ struct composite_context *resolve_name_send(struct resolve_context *ctx, struct nbt_name *name, struct event_context *event_ctx) { - return resolve_name_all_send(ctx, 0, name, event_ctx); + return resolve_name_all_send(ctx, 0, 0, name, event_ctx); } NTSTATUS resolve_name_recv(struct composite_context *c, diff --git a/source4/libcli/resolve/resolve.h b/source4/libcli/resolve/resolve.h index 344307febb..072a8a112d 100644 --- a/source4/libcli/resolve/resolve.h +++ b/source4/libcli/resolve/resolve.h @@ -30,6 +30,7 @@ typedef struct composite_context *(*resolve_name_send_fn)(TALLOC_CTX *mem_ctx, struct event_context *, void *privdata, uint32_t flags, + uint16_t port, struct nbt_name *); typedef NTSTATUS (*resolve_name_recv_fn)(struct composite_context *creq, TALLOC_CTX *mem_ctx, diff --git a/source4/libcli/resolve/testsuite.c b/source4/libcli/resolve/testsuite.c index ded1d1c9c1..f1d1fbc85c 100644 --- a/source4/libcli/resolve/testsuite.c +++ b/source4/libcli/resolve/testsuite.c @@ -44,7 +44,7 @@ static bool test_async_resolve(struct torture_context *tctx) host, timelimit); while (timeval_elapsed(&tv) < timelimit) { struct socket_address **s; - struct composite_context *c = resolve_name_host_send(mem_ctx, ev, NULL, 0, &n); + struct composite_context *c = resolve_name_host_send(mem_ctx, ev, NULL, 0, 0, &n); torture_assert(tctx, c != NULL, "resolve_name_host_send"); torture_assert_ntstatus_ok(tctx, resolve_name_host_recv(c, mem_ctx, &s, NULL), "async resolve failed"); diff --git a/source4/libcli/resolve/wins.c b/source4/libcli/resolve/wins.c index c560d94a8d..1940688ecb 100644 --- a/source4/libcli/resolve/wins.c +++ b/source4/libcli/resolve/wins.c @@ -41,11 +41,12 @@ struct composite_context *resolve_name_wins_send( struct event_context *event_ctx, void *userdata, uint32_t flags, + uint16_t port, struct nbt_name *name) { struct resolve_wins_data *wins_data = talloc_get_type(userdata, struct resolve_wins_data); if (wins_data->address_list == NULL) return NULL; - return resolve_name_nbtlist_send(mem_ctx, event_ctx, flags, name, + return resolve_name_nbtlist_send(mem_ctx, event_ctx, flags, port, name, wins_data->address_list, wins_data->ifaces, wins_data->nbt_port, wins_data->nbt_timeout, false, true); |