summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-03-16 18:46:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:57:32 -0500
commita949db7c6d4bd35df59ba066111e6566172d4814 (patch)
treec7978edc8c96fc63bb8333e4dd8703bc857a0215
parent3948fcac493ed131bc40358138e8dc17a58853f7 (diff)
downloadsamba-a949db7c6d4bd35df59ba066111e6566172d4814.tar.gz
samba-a949db7c6d4bd35df59ba066111e6566172d4814.tar.bz2
samba-a949db7c6d4bd35df59ba066111e6566172d4814.zip
r14486: remove the need of a stream_connection on a dcesrv_connection,
and let the transport set callbacks for getting the own and peer socket_address metze (This used to be commit 56fac3ddbbeecb834e5c7a439df344e11fe12a7b)
-rw-r--r--source4/ntvfs/ipc/vfs_ipc.c25
-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
5 files changed, 99 insertions, 15 deletions
diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c
index 7a572268d4..24ee1451d6 100644
--- a/source4/ntvfs/ipc/vfs_ipc.c
+++ b/source4/ntvfs/ipc/vfs_ipc.c
@@ -32,6 +32,7 @@
#include "libcli/rap/rap.h"
#include "ntvfs/ipc/proto.h"
#include "rpc_server/dcerpc_server.h"
+#include "smbd/service_stream.h"
#define IPC_BASE_FNUM 0x400
@@ -41,6 +42,8 @@
struct ipc_private {
struct idr_context *idtree_fnum;
+ struct stream_connection *stream_conn;
+
struct dcesrv_context *dcesrv;
/* a list of open pipes */
@@ -95,6 +98,8 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs,
private->pipe_list = NULL;
+ private->stream_conn = req->smb_conn->connection;
+
private->idtree_fnum = idr_init(private);
NT_STATUS_HAVE_NO_MEMORY(private->idtree_fnum);
@@ -173,6 +178,19 @@ static int ipc_fd_destructor(void *ptr)
return 0;
}
+static struct socket_address *ipc_get_my_addr(struct dcesrv_connection *dce_conn, TALLOC_CTX *mem_ctx)
+{
+ struct ipc_private *private = dce_conn->transport.private_data;
+
+ return socket_get_my_addr(private->stream_conn->socket, mem_ctx);
+}
+
+static struct socket_address *ipc_get_peer_addr(struct dcesrv_connection *dce_conn, TALLOC_CTX *mem_ctx)
+{
+ struct ipc_private *private = dce_conn->transport.private_data;
+
+ return socket_get_peer_addr(private->stream_conn->socket, mem_ctx);
+}
/*
open a file backend - used for MSRPC pipes
@@ -227,7 +245,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs,
p,
ep_description,
req->session->session_info,
- srv_conn,
+ srv_conn->event.ctx,
0,
&p->dce_conn);
if (!NT_STATUS_IS_OK(status)) {
@@ -235,6 +253,11 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs,
return status;
}
+ p->dce_conn->transport.private_data = private;
+ p->dce_conn->transport.report_output_data = NULL;
+ p->dce_conn->transport.get_my_addr = ipc_get_my_addr;
+ p->dce_conn->transport.get_peer_addr = ipc_get_peer_addr;
+
DLIST_ADD(private->pipe_list, p);
p->smbpid = req->smbpid;
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);