summaryrefslogtreecommitdiffstats
path: root/source4/librpc
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2013-12-04 15:51:07 +0100
committerStefan Metzmacher <metze@samba.org>2014-01-07 08:37:46 +0100
commit445913133a4999d8435a477373d40318d2fc4b0c (patch)
tree0a8c72c6c1aa81977cbc34ca503b32c03a37eb53 /source4/librpc
parent9832eb6bbfb73018d1a13425a918c402442526c9 (diff)
downloadsamba-445913133a4999d8435a477373d40318d2fc4b0c.tar.gz
samba-445913133a4999d8435a477373d40318d2fc4b0c.tar.xz
samba-445913133a4999d8435a477373d40318d2fc4b0c.zip
s4:librpc: factor out xxx_send_read() to dcerpc_send_read()
Signed-off-by: Gregor Beck <gbeck@sernet.de> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/rpc/dcerpc.c90
-rw-r--r--source4/librpc/rpc/dcerpc.h3
-rw-r--r--source4/librpc/rpc/dcerpc_smb.c94
-rw-r--r--source4/librpc/rpc/dcerpc_sock.c95
4 files changed, 95 insertions, 187 deletions
diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c
index a55f3d6468..fb39777825 100644
--- a/source4/librpc/rpc/dcerpc.c
+++ b/source4/librpc/rpc/dcerpc.c
@@ -1487,7 +1487,7 @@ static void dcerpc_request_recv_data(struct dcecli_connection *c,
if (!(pkt->pfc_flags & DCERPC_PFC_FLAG_LAST)) {
data_blob_free(raw_packet);
- c->transport.send_read(c);
+ dcerpc_send_read(c);
return;
}
@@ -1695,7 +1695,7 @@ static void dcerpc_ship_next_request(struct dcecli_connection *c)
}
if (last_frag && !do_trans) {
- req->status = p->conn->transport.send_read(p->conn);
+ req->status = dcerpc_send_read(p->conn);
if (!NT_STATUS_IS_OK(req->status)) {
req->state = RPC_REQUEST_DONE;
DLIST_REMOVE(p->conn->pending, req);
@@ -2325,3 +2325,89 @@ static void dcerpc_shutdown_pipe_done(struct tevent_req *subreq)
dcerpc_transport_dead(c, status);
}
+
+
+
+struct dcerpc_send_read_state {
+ struct dcecli_connection *p;
+};
+
+static int dcerpc_send_read_state_destructor(struct dcerpc_send_read_state *state)
+{
+ struct dcecli_connection *p = state->p;
+
+ p->transport.read_subreq = NULL;
+
+ return 0;
+}
+
+static void dcerpc_send_read_done(struct tevent_req *subreq);
+
+NTSTATUS dcerpc_send_read(struct dcecli_connection *p)
+{
+ struct dcerpc_send_read_state *state;
+
+ if (p->transport.read_subreq != NULL) {
+ p->transport.pending_reads++;
+ return NT_STATUS_OK;
+ }
+
+ state = talloc_zero(p, struct dcerpc_send_read_state);
+ if (state == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ state->p = p;
+
+ talloc_set_destructor(state, dcerpc_send_read_state_destructor);
+
+ p->transport.read_subreq = dcerpc_read_ncacn_packet_send(state,
+ p->event_ctx,
+ p->transport.stream);
+ if (p->transport.read_subreq == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ tevent_req_set_callback(p->transport.read_subreq, dcerpc_send_read_done, state);
+
+ return NT_STATUS_OK;
+}
+
+static void dcerpc_send_read_done(struct tevent_req *subreq)
+{
+ struct dcerpc_send_read_state *state =
+ tevent_req_callback_data(subreq,
+ struct dcerpc_send_read_state);
+ struct dcecli_connection *p = state->p;
+ NTSTATUS status;
+ struct ncacn_packet *pkt;
+ DATA_BLOB blob;
+
+ status = dcerpc_read_ncacn_packet_recv(subreq, state,
+ &pkt, &blob);
+ TALLOC_FREE(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(state);
+ dcerpc_transport_dead(p, status);
+ return;
+ }
+
+ /*
+ * here we steal into thet connection context,
+ * but p->transport.recv_data() will steal or free it again
+ */
+ talloc_steal(p, blob.data);
+ TALLOC_FREE(state);
+
+ if (p->transport.pending_reads > 0) {
+ p->transport.pending_reads--;
+
+ status = dcerpc_send_read(p);
+ if (!NT_STATUS_IS_OK(status)) {
+ dcerpc_transport_dead(p, status);
+ return;
+ }
+ }
+
+ if (p->transport.recv_data) {
+ p->transport.recv_data(p, &blob, NT_STATUS_OK);
+ }
+}
diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h
index cb78421cb2..47b81c081a 100644
--- a/source4/librpc/rpc/dcerpc.h
+++ b/source4/librpc/rpc/dcerpc.h
@@ -81,9 +81,6 @@ struct dcecli_connection {
/* send a request to the server */
NTSTATUS (*send_request)(struct dcecli_connection *, DATA_BLOB *, bool trigger_read);
- /* send a read request to the server */
- NTSTATUS (*send_read)(struct dcecli_connection *);
-
/* a callback to the dcerpc code when a full fragment
has been received */
void (*recv_data)(struct dcecli_connection *, DATA_BLOB *, NTSTATUS status);
diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c
index 5e282d65d1..b58817b335 100644
--- a/source4/librpc/rpc/dcerpc_smb.c
+++ b/source4/librpc/rpc/dcerpc_smb.c
@@ -49,95 +49,10 @@ struct smb_private {
/*
Tell the dcerpc layer that the transport is dead.
- This function is declared here because it is going to be private.
+ The following functions are declared here because they are going to be private.
*/
void dcerpc_transport_dead(struct dcecli_connection *c, NTSTATUS status);
-
-struct smb_send_read_state {
- struct dcecli_connection *p;
-};
-
-static int smb_send_read_state_destructor(struct smb_send_read_state *state)
-{
- struct dcecli_connection *p = state->p;
-
- p->transport.read_subreq = NULL;
-
- return 0;
-}
-
-static void smb_send_read_done(struct tevent_req *subreq);
-
-static NTSTATUS smb_send_read(struct dcecli_connection *p)
-{
- struct smb_private *sock = talloc_get_type_abort(
- p->transport.private_data, struct smb_private);
- struct smb_send_read_state *state;
-
- if (p->transport.read_subreq != NULL) {
- p->transport.pending_reads++;
- return NT_STATUS_OK;
- }
-
- state = talloc_zero(sock, struct smb_send_read_state);
- if (state == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- state->p = p;
-
- talloc_set_destructor(state, smb_send_read_state_destructor);
-
- p->transport.read_subreq = dcerpc_read_ncacn_packet_send(state,
- p->event_ctx,
- p->transport.stream);
- if (p->transport.read_subreq == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- tevent_req_set_callback(p->transport.read_subreq, smb_send_read_done, state);
-
- return NT_STATUS_OK;
-}
-
-static void smb_send_read_done(struct tevent_req *subreq)
-{
- struct smb_send_read_state *state =
- tevent_req_callback_data(subreq,
- struct smb_send_read_state);
- struct dcecli_connection *p = state->p;
- NTSTATUS status;
- struct ncacn_packet *pkt;
- DATA_BLOB blob;
-
- status = dcerpc_read_ncacn_packet_recv(subreq, state,
- &pkt, &blob);
- TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(state);
- dcerpc_transport_dead(p, status);
- return;
- }
-
- /*
- * here we steal into thet connection context,
- * but p->transport.recv_data() will steal or free it again
- */
- talloc_steal(p, blob.data);
- TALLOC_FREE(state);
-
- if (p->transport.pending_reads > 0) {
- p->transport.pending_reads--;
-
- status = smb_send_read(p);
- if (!NT_STATUS_IS_OK(status)) {
- dcerpc_transport_dead(p, status);
- return;
- }
- }
-
- if (p->transport.recv_data) {
- p->transport.recv_data(p, &blob, NT_STATUS_OK);
- }
-}
+NTSTATUS dcerpc_send_read(struct dcecli_connection *p);
/*
send an initial pdu in a multi-pdu sequence
@@ -221,7 +136,7 @@ static NTSTATUS smb_send_request(struct dcecli_connection *p, DATA_BLOB *data,
tevent_req_set_callback(subreq, smb_send_request_done, state);
if (trigger_read) {
- smb_send_read(p);
+ dcerpc_send_read(p);
}
return NT_STATUS_OK;
@@ -258,7 +173,7 @@ static void smb_send_request_wait_done(struct tevent_req *subreq)
/* we free subreq after tstream_smbXcli_np_use_trans */
TALLOC_FREE(subreq);
- smb_send_read(p);
+ dcerpc_send_read(p);
}
static void smb_send_request_done(struct tevent_req *subreq)
@@ -400,7 +315,6 @@ static void dcerpc_pipe_open_smb_done(struct tevent_req *subreq)
c->transport.private_data = NULL;
c->transport.send_request = smb_send_request;
- c->transport.send_read = smb_send_read;
c->transport.recv_data = NULL;
/*
diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c
index 87c7ff494a..83f1d1f275 100644
--- a/source4/librpc/rpc/dcerpc_sock.c
+++ b/source4/librpc/rpc/dcerpc_sock.c
@@ -42,98 +42,10 @@ struct sock_private {
/*
Mark the socket dead.
- This function is declared here because it is going to be private.
+ The following functions are declared here because they are going to be private.
*/
void dcerpc_transport_dead(struct dcecli_connection *p, NTSTATUS status);
-
-/*
- initiate a read request - not needed for dcerpc sockets
-*/
-struct sock_send_read_state {
- struct dcecli_connection *p;
-};
-
-static int sock_send_read_state_destructor(struct sock_send_read_state *state)
-{
- struct dcecli_connection *p = state->p;
-
- p->transport.read_subreq = NULL;
-
- return 0;
-}
-
-static void sock_send_read_done(struct tevent_req *subreq);
-
-static NTSTATUS sock_send_read(struct dcecli_connection *p)
-{
- struct sock_private *sock = talloc_get_type_abort(
- p->transport.private_data, struct sock_private);
- struct sock_send_read_state *state;
-
- if (p->transport.read_subreq != NULL) {
- p->transport.pending_reads++;
- return NT_STATUS_OK;
- }
-
- state = talloc_zero(sock, struct sock_send_read_state);
- if (state == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- state->p = p;
-
- talloc_set_destructor(state, sock_send_read_state_destructor);
-
- p->transport.read_subreq = dcerpc_read_ncacn_packet_send(state,
- p->event_ctx,
- p->transport.stream);
- if (p->transport.read_subreq == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- tevent_req_set_callback(p->transport.read_subreq, sock_send_read_done, state);
-
- return NT_STATUS_OK;
-}
-
-static void sock_send_read_done(struct tevent_req *subreq)
-{
- struct sock_send_read_state *state =
- tevent_req_callback_data(subreq,
- struct sock_send_read_state);
- struct dcecli_connection *p = state->p;
- NTSTATUS status;
- struct ncacn_packet *pkt;
- DATA_BLOB blob;
-
- status = dcerpc_read_ncacn_packet_recv(subreq, state,
- &pkt, &blob);
- TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(state);
- dcerpc_transport_dead(p, status);
- return;
- }
-
- /*
- * here we steal into thet connection context,
- * but p->transport.recv_data() will steal or free it again
- */
- talloc_steal(p, blob.data);
- TALLOC_FREE(state);
-
- if (p->transport.pending_reads > 0) {
- p->transport.pending_reads--;
-
- status = sock_send_read(p);
- if (!NT_STATUS_IS_OK(status)) {
- dcerpc_transport_dead(p, status);
- return;
- }
- }
-
- if (p->transport.recv_data) {
- p->transport.recv_data(p, &blob, NT_STATUS_OK);
- }
-}
+NTSTATUS dcerpc_send_read(struct dcecli_connection *p);
/*
send an initial pdu in a multi-pdu sequence
@@ -184,7 +96,7 @@ static NTSTATUS sock_send_request(struct dcecli_connection *p, DATA_BLOB *data,
tevent_req_set_callback(subreq, sock_send_request_done, state);
if (trigger_read) {
- sock_send_read(p);
+ dcerpc_send_read(p);
}
return NT_STATUS_OK;
@@ -264,7 +176,6 @@ static void continue_socket_connect(struct composite_context *ctx)
conn->transport.private_data = NULL;
conn->transport.send_request = sock_send_request;
- conn->transport.send_read = sock_send_read;
conn->transport.recv_data = NULL;
/*