summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorSamuel Cabrero <scabrero@suse.de>2019-08-06 18:21:12 +0200
committerRalph Boehme <slow@samba.org>2019-08-07 14:12:40 +0000
commit959b77988d02731c032b5fcc91f7a62fd9b96340 (patch)
treeaf639dcfe9c39cc9241ca52a6c391ee3dbb0f672 /source4
parent7189eb44d7f8a6514bb48645da89d7f9b148d599 (diff)
downloadsamba-959b77988d02731c032b5fcc91f7a62fd9b96340.tar.gz
s4:librpc/rpc: Use generic roh_connect_channel_send/recv
The HTTP connection code is common to in and out channels. Signed-off-by: Samuel Cabrero <scabrero@suse.de> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed Aug 7 14:12:40 UTC 2019 on sn-devel-184
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/rpc/dcerpc_roh.c35
-rw-r--r--source4/librpc/rpc/dcerpc_roh_channel_in.c101
-rw-r--r--source4/librpc/rpc/dcerpc_roh_channel_out.c101
3 files changed, 18 insertions, 219 deletions
diff --git a/source4/librpc/rpc/dcerpc_roh.c b/source4/librpc/rpc/dcerpc_roh.c
index e614d130652..33baa52c618 100644
--- a/source4/librpc/rpc/dcerpc_roh.c
+++ b/source4/librpc/rpc/dcerpc_roh.c
@@ -349,13 +349,13 @@ static void roh_continue_resolve_name(struct composite_context *ctx)
* always use local proxy. Otherwise, run the proxy use discovery
*/
state->roh->connection_state = ROH_STATE_OPEN_START;
- subreq = roh_connect_channel_in_send(state,
- state->event_ctx,
- state->rpcproxy_addresses[state->rpcproxy_address_index],
- state->rpc_proxy_port,
- state->credentials,
- state->roh, state->tls,
- state->tls_params);
+ subreq = roh_connect_channel_send(state,
+ state->event_ctx,
+ state->rpcproxy_addresses[state->rpcproxy_address_index],
+ state->rpc_proxy_port,
+ state->credentials,
+ state->tls,
+ state->tls_params);
if (tevent_req_nomem(subreq, state->req)) {
return;
}
@@ -372,20 +372,20 @@ static void roh_connect_channel_in_done(struct tevent_req *subreq)
req = tevent_req_callback_data(subreq, struct tevent_req);
state = tevent_req_data(req, struct roh_open_connection_state);
- status = roh_connect_channel_in_recv(subreq);
+ status = roh_connect_channel_recv(subreq, state->roh,
+ &state->roh->default_channel_in);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
}
- subreq = roh_connect_channel_out_send(state,
- state->event_ctx,
- state->rpcproxy_addresses[state->rpcproxy_address_index],
- state->rpc_proxy_port,
- state->credentials,
- state->roh,
- state->tls,
- state->tls_params);
+ subreq = roh_connect_channel_send(state,
+ state->event_ctx,
+ state->rpcproxy_addresses[state->rpcproxy_address_index],
+ state->rpc_proxy_port,
+ state->credentials,
+ state->tls,
+ state->tls_params);
if (tevent_req_nomem(subreq, req)) {
return;
}
@@ -402,7 +402,8 @@ static void roh_connect_channel_out_done(struct tevent_req *subreq)
req = tevent_req_callback_data(subreq, struct tevent_req);
state = tevent_req_data(req, struct roh_open_connection_state);
- status = roh_connect_channel_out_recv(subreq);
+ status = roh_connect_channel_recv(subreq, state->roh,
+ &state->roh->default_channel_out);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
diff --git a/source4/librpc/rpc/dcerpc_roh_channel_in.c b/source4/librpc/rpc/dcerpc_roh_channel_in.c
index bc630f77e42..50104527c3f 100644
--- a/source4/librpc/rpc/dcerpc_roh_channel_in.c
+++ b/source4/librpc/rpc/dcerpc_roh_channel_in.c
@@ -39,107 +39,6 @@
#include "librpc/rpc/dcerpc_proto.h"
#include "libcli/http/http.h"
-struct roh_connect_channel_state {
- struct tevent_context *ev;
- struct cli_credentials *credentials;
- struct roh_connection *roh;
- struct tstream_tls_params *tls_params;
-};
-
-static void roh_connect_channel_in_done(struct tevent_req *);
-struct tevent_req *roh_connect_channel_in_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- const char *rpcproxy_ip_address,
- unsigned int rpcproxy_port,
- struct cli_credentials *credentials,
- struct roh_connection *roh,
- bool tls,
- struct tstream_tls_params *tls_params)
-{
- struct tevent_req *req;
- struct tevent_req *subreq;
- struct roh_connect_channel_state *state;
-
- DEBUG(8, ("%s: Connecting channel in socket, RPC proxy is %s:%d (TLS: %s)\n",
- __func__, rpcproxy_ip_address, rpcproxy_port,
- (tls ? "true" : "false")));
-
- req = tevent_req_create(mem_ctx, &state, struct roh_connect_channel_state);
- if (req == NULL) {
- return NULL;
- }
-
- if (!is_ipaddress(rpcproxy_ip_address)) {
- DEBUG(0, ("%s: Invalid host (%s), needs to be an IP address\n",
- __func__, rpcproxy_ip_address));
- tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return tevent_req_post(req, ev);
- }
-
- state->ev = ev;
- state->credentials = credentials;
- state->roh = roh;
- state->tls_params = tls_params;
-
- /* Initialize channel structure */
- state->roh->default_channel_in = talloc_zero(roh, struct roh_channel);
- if (tevent_req_nomem(state->roh->default_channel_in, req)) {
- return tevent_req_post(req, ev);
- }
-
- state->roh->default_channel_in->channel_cookie = GUID_random();
-
- subreq = http_connect_send(state,
- ev,
- rpcproxy_ip_address,
- rpcproxy_port,
- credentials,
- tls ? tls_params : NULL);
- if (tevent_req_nomem(subreq, req)) {
- return tevent_req_post(req, ev);
- }
- tevent_req_set_callback(subreq, roh_connect_channel_in_done, req);
-
- return req;
-}
-
-static void roh_connect_channel_in_done(struct tevent_req *subreq)
-{
- NTSTATUS status;
- struct tevent_req *req;
- struct roh_connect_channel_state *state;
- int ret;
-
- req = tevent_req_callback_data(subreq, struct tevent_req);
- state = tevent_req_data(req, struct roh_connect_channel_state);
-
- ret = http_connect_recv(subreq,
- state->roh->default_channel_in,
- &state->roh->default_channel_in->http_conn);
- TALLOC_FREE(subreq);
- if (ret != 0) {
- status = map_nt_error_from_unix_common(ret);
- tevent_req_nterror(req, status);
- return;
- }
-
- DBG_DEBUG("HTTP connected\n");
- tevent_req_done(req);
-}
-
-NTSTATUS roh_connect_channel_in_recv(struct tevent_req *req)
-{
- NTSTATUS status;
-
- if (tevent_req_is_nterror(req, &status)) {
- tevent_req_received(req);
- return status;
- }
-
- tevent_req_received(req);
- return NT_STATUS_OK;
-}
-
struct roh_request_state {
struct http_request *request;
struct http_request *response;
diff --git a/source4/librpc/rpc/dcerpc_roh_channel_out.c b/source4/librpc/rpc/dcerpc_roh_channel_out.c
index 4a227823f4a..e431689d419 100644
--- a/source4/librpc/rpc/dcerpc_roh_channel_out.c
+++ b/source4/librpc/rpc/dcerpc_roh_channel_out.c
@@ -39,107 +39,6 @@
#include "librpc/rpc/dcerpc_proto.h"
#include "libcli/http/http.h"
-struct roh_connect_channel_state {
- struct tevent_context *ev;
- struct cli_credentials *credentials;
- struct roh_connection *roh;
- struct tstream_tls_params *tls_params;
-};
-
-static void roh_connect_channel_out_done(struct tevent_req *subreq);
-struct tevent_req *roh_connect_channel_out_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- const char *rpcproxy_ip_address,
- unsigned int rpcproxy_port,
- struct cli_credentials *credentials,
- struct roh_connection *roh,
- bool tls,
- struct tstream_tls_params *tls_params)
-{
- struct tevent_req *req;
- struct tevent_req *subreq;
- struct roh_connect_channel_state *state;
-
- DEBUG(8, ("%s: Connecting channel out socket, RPC proxy is %s:%d (TLS: %s)\n",
- __func__, rpcproxy_ip_address, rpcproxy_port,
- (tls ? "true" : "false")));
-
- req = tevent_req_create(mem_ctx, &state, struct roh_connect_channel_state);
- if (req == NULL) {
- return NULL;
- }
-
- if (!is_ipaddress(rpcproxy_ip_address)) {
- DEBUG(0, ("%s: Invalid host (%s), needs to be an IP address\n",
- __func__, rpcproxy_ip_address));
- tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return tevent_req_post(req, ev);
- }
-
- state->ev = ev;
- state->credentials = credentials;
- state->roh = roh;
- state->tls_params = tls_params;
-
- /* Initialize channel structure */
- state->roh->default_channel_out = talloc_zero(roh, struct roh_channel);
- if (tevent_req_nomem(state->roh->default_channel_out, req)) {
- return tevent_req_post(req, ev);
- }
-
- state->roh->default_channel_out->channel_cookie = GUID_random();
-
- subreq = http_connect_send(state,
- ev,
- rpcproxy_ip_address,
- rpcproxy_port,
- credentials,
- tls ? tls_params : NULL);
- if (tevent_req_nomem(subreq, req)) {
- return tevent_req_post(req, ev);
- }
- tevent_req_set_callback(subreq, roh_connect_channel_out_done, req);
-
- return req;
-}
-
-static void roh_connect_channel_out_done(struct tevent_req *subreq)
-{
- struct tevent_req *req;
- struct roh_connect_channel_state *state;
- NTSTATUS status;
- int ret;
-
- req = tevent_req_callback_data(subreq, struct tevent_req);
- state = tevent_req_data(req, struct roh_connect_channel_state);
-
- ret = http_connect_recv(subreq,
- state->roh->default_channel_out,
- &state->roh->default_channel_out->http_conn);
- TALLOC_FREE(subreq);
- if (ret != 0) {
- status = map_nt_error_from_unix_common(ret);
- tevent_req_nterror(req, status);
- return;
- }
-
- DBG_DEBUG("HTTP connected\n");
- tevent_req_done(req);
-}
-
-NTSTATUS roh_connect_channel_out_recv(struct tevent_req *req)
-{
- NTSTATUS status;
-
- if (tevent_req_is_nterror(req, &status)) {
- tevent_req_received(req);
- return status;
- }
-
- tevent_req_received(req);
- return NT_STATUS_OK;
-}
-
struct roh_request_state {
struct http_request *request;
struct http_request *response;