summaryrefslogtreecommitdiff
path: root/source4/rpc_server
diff options
context:
space:
mode:
Diffstat (limited to 'source4/rpc_server')
-rw-r--r--source4/rpc_server/dcerpc_server.c35
-rw-r--r--source4/rpc_server/dcerpc_server.h9
-rw-r--r--source4/rpc_server/dcerpc_sock.c43
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c2
4 files changed, 75 insertions, 14 deletions
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index da0bc8fd6f..f4780eaf38 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -289,7 +289,7 @@ static int dcesrv_endpoint_destructor(void *ptr)
NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
TALLOC_CTX *mem_ctx,
const struct dcesrv_endpoint *ep,
- struct stream_connection *srv_conn,
+ struct event_context *event_ctx,
uint32_t state_flags,
struct dcesrv_connection **_p)
{
@@ -309,9 +309,10 @@ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
p->auth_state.gensec_security = NULL;
p->auth_state.session_info = NULL;
p->auth_state.session_key = dcesrv_generic_session_key;
- p->srv_conn = srv_conn;
+ p->event_ctx = event_ctx;
p->processing = False;
p->state_flags = state_flags;
+ ZERO_STRUCT(p->transport);
talloc_set_destructor(p, dcesrv_endpoint_destructor);
@@ -326,7 +327,7 @@ NTSTATUS dcesrv_endpoint_search_connect(struct dcesrv_context *dce_ctx,
TALLOC_CTX *mem_ctx,
const struct dcerpc_binding *ep_description,
struct auth_session_info *session_info,
- struct stream_connection *srv_conn,
+ struct event_context *event_ctx,
uint32_t state_flags,
struct dcesrv_connection **dce_conn_p)
{
@@ -339,7 +340,7 @@ NTSTATUS dcesrv_endpoint_search_connect(struct dcesrv_context *dce_ctx,
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
- status = dcesrv_endpoint_connect(dce_ctx, mem_ctx, ep, srv_conn, state_flags, dce_conn_p);
+ status = dcesrv_endpoint_connect(dce_ctx, mem_ctx, ep, event_ctx, state_flags, dce_conn_p);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -750,7 +751,7 @@ static NTSTATUS dcesrv_request(struct dcesrv_call_state *call)
pull->flags |= LIBNDR_FLAG_REF_ALLOC;
call->context = context;
- call->event_ctx = context->conn->srv_conn->event.ctx;
+ call->event_ctx = context->conn->event_ctx;
call->ndr_pull = pull;
if (call->pkt.pfc_flags & DCERPC_PFC_FLAG_ORPC) {
@@ -879,15 +880,31 @@ NTSTATUS dcesrv_reply(struct dcesrv_call_state *call)
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
if (call->conn->call_list && call->conn->call_list->replies) {
- if (call->conn->srv_conn &&
- call->conn->srv_conn->event.fde) {
- EVENT_FD_WRITEABLE(call->conn->srv_conn->event.fde);
+ if (call->conn->transport.report_output_data) {
+ call->conn->transport.report_output_data(call->conn);
}
}
return NT_STATUS_OK;
}
+struct socket_address *dcesrv_connection_get_my_addr(struct dcesrv_connection *conn, TALLOC_CTX *mem_ctx)
+{
+ if (!conn->transport.get_my_addr) {
+ return NULL;
+ }
+
+ return conn->transport.get_my_addr(conn, mem_ctx);
+}
+
+struct socket_address *dcesrv_connection_get_peer_addr(struct dcesrv_connection *conn, TALLOC_CTX *mem_ctx)
+{
+ if (!conn->transport.get_peer_addr) {
+ return NULL;
+ }
+
+ return conn->transport.get_peer_addr(conn, mem_ctx);
+}
/*
work out if we have a full packet yet
@@ -939,7 +956,7 @@ NTSTATUS dcesrv_input_process(struct dcesrv_connection *dce_conn)
call->conn = dce_conn;
call->replies = NULL;
call->context = NULL;
- call->event_ctx = dce_conn->srv_conn->event.ctx;
+ call->event_ctx = dce_conn->event_ctx;
blob = dce_conn->partial_input;
blob.length = dcerpc_get_frag_length(&blob);
diff --git a/source4/rpc_server/dcerpc_server.h b/source4/rpc_server/dcerpc_server.h
index 13e9b897fd..9ee553b928 100644
--- a/source4/rpc_server/dcerpc_server.h
+++ b/source4/rpc_server/dcerpc_server.h
@@ -176,7 +176,8 @@ struct dcesrv_connection {
/* the current authentication state */
struct dcesrv_auth auth_state;
- struct stream_connection *srv_conn;
+ /* the event_context that will be used for this connection */
+ struct event_context *event_ctx;
/* the transport level session key */
DATA_BLOB transport_session_key;
@@ -186,6 +187,12 @@ struct dcesrv_connection {
/* this is the default state_flags for dcesrv_call_state structs */
uint32_t state_flags;
+ struct {
+ void *private_data;
+ void (*report_output_data)(struct dcesrv_connection *);
+ struct socket_address *(*get_my_addr)(struct dcesrv_connection *, TALLOC_CTX *mem_ctx);
+ struct socket_address *(*get_peer_addr)(struct dcesrv_connection *, TALLOC_CTX *mem_ctx);
+ } transport;
};
diff --git a/source4/rpc_server/dcerpc_sock.c b/source4/rpc_server/dcerpc_sock.c
index 2cfce5303b..79cf1113eb 100644
--- a/source4/rpc_server/dcerpc_sock.c
+++ b/source4/rpc_server/dcerpc_sock.c
@@ -34,7 +34,7 @@
struct dcesrv_socket_context {
const struct dcesrv_endpoint *endpoint;
- struct dcesrv_context *dcesrv_ctx;
+ struct dcesrv_context *dcesrv_ctx;
};
/*
@@ -55,9 +55,41 @@ static NTSTATUS dcerpc_write_fn(void *private_data, DATA_BLOB *out, size_t *nwri
static void dcesrv_terminate_connection(struct dcesrv_connection *dce_conn, const char *reason)
{
- stream_terminate_connection(dce_conn->srv_conn, reason);
+ struct stream_connection *srv_conn;
+ srv_conn = talloc_get_type(dce_conn->transport.private_data,
+ struct stream_connection);
+
+ stream_terminate_connection(srv_conn, reason);
+}
+
+static void dcesrv_sock_report_output_data(struct dcesrv_connection *dcesrv_conn)
+{
+ struct stream_connection *srv_conn;
+ srv_conn = talloc_get_type(dcesrv_conn->transport.private_data,
+ struct stream_connection);
+
+ if (srv_conn && srv_conn->event.fde) {
+ EVENT_FD_WRITEABLE(srv_conn->event.fde);
+ }
}
+static struct socket_address *dcesrv_sock_get_my_addr(struct dcesrv_connection *dcesrv_conn, TALLOC_CTX *mem_ctx)
+{
+ struct stream_connection *srv_conn;
+ srv_conn = talloc_get_type(dcesrv_conn->transport.private_data,
+ struct stream_connection);
+
+ return socket_get_my_addr(srv_conn->socket, mem_ctx);
+}
+
+static struct socket_address *dcesrv_sock_get_peer_addr(struct dcesrv_connection *dcesrv_conn, TALLOC_CTX *mem_ctx)
+{
+ struct stream_connection *srv_conn;
+ srv_conn = talloc_get_type(dcesrv_conn->transport.private_data,
+ struct stream_connection);
+
+ return socket_get_peer_addr(srv_conn->socket, mem_ctx);
+}
static void dcesrv_sock_accept(struct stream_connection *srv_conn)
{
@@ -69,7 +101,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
status = dcesrv_endpoint_connect(dcesrv_sock->dcesrv_ctx,
srv_conn,
dcesrv_sock->endpoint,
- srv_conn,
+ srv_conn->event.ctx,
DCESRV_CALL_STATE_FLAG_MAY_ASYNC,
&dcesrv_conn);
if (!NT_STATUS_IS_OK(status)) {
@@ -79,6 +111,11 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
return;
}
+ dcesrv_conn->transport.private_data = srv_conn;
+ dcesrv_conn->transport.report_output_data = dcesrv_sock_report_output_data;
+ dcesrv_conn->transport.get_my_addr = dcesrv_sock_get_my_addr;
+ dcesrv_conn->transport.get_peer_addr = dcesrv_sock_get_peer_addr;
+
srv_conn->private = dcesrv_conn;
irpc_add_name(srv_conn->msg_ctx, "rpc_server");
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index e5bcc35081..c8c0594612 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -185,7 +185,7 @@ static WERROR spoolss_check_server_name(struct dcesrv_call_state *dce_call,
if (ret) return WERR_OK;
}
- myaddr = socket_get_my_addr(dce_call->conn->srv_conn->socket, mem_ctx);
+ myaddr = dcesrv_connection_get_my_addr(dce_call->conn, mem_ctx);
W_ERROR_HAVE_NO_MEMORY(myaddr);
ret = strequal(myaddr->addr, server_name);