diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-02-13 16:27:22 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2014-05-26 03:31:27 +0200 |
commit | 374c5c4109facbcf3e9a20d1b116d369f14164c0 (patch) | |
tree | d58461c9ba5a5f254e3d21dfe519fb2856979b15 /source4/librpc | |
parent | 4c11fa68d48caa06d6f9c9db462a2d2e6a0bc3d3 (diff) | |
download | samba-374c5c4109facbcf3e9a20d1b116d369f14164c0.tar.gz |
s4:librpc/rpc: return the local/remote ip from dcerpc_pipe_open_tcp_recv()
It's important that the caller can remember the ips,
so that a secondary connection can use the same addresses
in order to get association group binding to work.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/rpc/dcerpc_connect.c | 2 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_secondary.c | 4 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_sock.c | 29 |
3 files changed, 29 insertions, 6 deletions
diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c index da452e682d8..39ff941e771 100644 --- a/source4/librpc/rpc/dcerpc_connect.c +++ b/source4/librpc/rpc/dcerpc_connect.c @@ -346,7 +346,7 @@ static void continue_pipe_open_ncacn_ip_tcp(struct composite_context *ctx) struct composite_context); /* receive result of named pipe open request on tcp/ip */ - c->status = dcerpc_pipe_open_tcp_recv(ctx); + c->status = dcerpc_pipe_open_tcp_recv(ctx, NULL, NULL, NULL); if (!composite_is_ok(c)) return; composite_done(c); diff --git a/source4/librpc/rpc/dcerpc_secondary.c b/source4/librpc/rpc/dcerpc_secondary.c index fbad46c55ad..8fc159867b3 100644 --- a/source4/librpc/rpc/dcerpc_secondary.c +++ b/source4/librpc/rpc/dcerpc_secondary.c @@ -180,8 +180,8 @@ static void continue_open_tcp(struct composite_context *ctx) { struct composite_context *c = talloc_get_type(ctx->async.private_data, struct composite_context); - - c->status = dcerpc_pipe_open_tcp_recv(ctx); + + c->status = dcerpc_pipe_open_tcp_recv(ctx, NULL, NULL, NULL); if (!composite_is_ok(c)) return; continue_pipe_open(c); diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c index fc2ce132b14..de86e9802c4 100644 --- a/source4/librpc/rpc/dcerpc_sock.c +++ b/source4/librpc/rpc/dcerpc_sock.c @@ -213,6 +213,8 @@ struct pipe_tcp_state { struct socket_address *srvaddr; struct resolve_context *resolve_ctx; struct dcecli_connection *conn; + char *local_address; + char *remote_address; }; @@ -253,9 +255,10 @@ static void continue_ip_open_socket(struct composite_context *ctx) ctx->async.private_data, struct composite_context); struct pipe_tcp_state *s = talloc_get_type_abort( c->private_data, struct pipe_tcp_state); - + struct socket_address *localaddr = NULL; + /* receive result socket open request */ - c->status = dcerpc_pipe_open_socket_recv(ctx, NULL, NULL); + c->status = dcerpc_pipe_open_socket_recv(ctx, s, &localaddr); if (!NT_STATUS_IS_OK(c->status)) { /* something went wrong... */ DEBUG(0, ("Failed to connect host %s (%s) on port %d - %s.\n", @@ -282,6 +285,11 @@ static void continue_ip_open_socket(struct composite_context *ctx) } } + s->local_address = talloc_strdup(s, localaddr->addr); + if (composite_nomem(s->local_address, c)) return; + s->remote_address = talloc_strdup(s, s->addresses[s->index - 1]); + if (composite_nomem(s->remote_address, c)) return; + composite_done(c); } @@ -335,11 +343,26 @@ struct composite_context* dcerpc_pipe_open_tcp_send(struct dcecli_connection *co /* Receive result of pipe open request on tcp/ip */ -NTSTATUS dcerpc_pipe_open_tcp_recv(struct composite_context *c) +NTSTATUS dcerpc_pipe_open_tcp_recv(struct composite_context *c, + TALLOC_CTX *mem_ctx, + char **localaddr, + char **remoteaddr) { NTSTATUS status; status = composite_wait(c); + if (NT_STATUS_IS_OK(status)) { + struct pipe_tcp_state *s = talloc_get_type_abort( + c->private_data, struct pipe_tcp_state); + + if (localaddr != NULL) { + *localaddr = talloc_move(mem_ctx, &s->local_address); + } + if (remoteaddr != NULL) { + *remoteaddr = talloc_move(mem_ctx, &s->remote_address); + } + } + talloc_free(c); return status; } |