From 9e723f9d69bbbaefd9e15399654668693854628b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 25 Sep 2013 11:34:56 +0200 Subject: [PATCH] s3-rpc_server: Add named_pipe_client_init() function. Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- source3/rpc_server/rpc_server.c | 68 ++++++++++++++++++--------------- source3/rpc_server/rpc_server.h | 40 +++++++++++++++++++ 2 files changed, 78 insertions(+), 30 deletions(-) diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c index cecc9881f30..f283559dddd 100644 --- a/source3/rpc_server/rpc_server.c +++ b/source3/rpc_server/rpc_server.c @@ -248,36 +248,6 @@ static void named_pipe_listener(struct tevent_context *ev, * Accepts connections from clients and process requests using the appropriate * dispatcher table. */ -struct named_pipe_client { - const char *pipe_name; - - struct tevent_context *ev; - struct messaging_context *msg_ctx; - - uint16_t file_type; - uint16_t device_state; - uint64_t allocation_size; - - struct tstream_context *tstream; - - struct tsocket_address *client; - char *client_name; - struct tsocket_address *server; - char *server_name; - - struct auth_session_info *session_info; - - struct pipes_struct *p; - - struct tevent_queue *write_queue; - - struct iovec *iov; - size_t count; - - named_pipe_termination_fn *term_fn; - void *private_data; -}; - static int named_pipe_destructor(struct named_pipe_client *npc) { if (npc->term_fn) { @@ -286,6 +256,44 @@ static int named_pipe_destructor(struct named_pipe_client *npc) return 0; } +struct named_pipe_client *named_pipe_client_init(TALLOC_CTX *mem_ctx, + struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, + const char *pipe_name, + named_pipe_termination_fn *term_fn, + uint16_t file_type, + uint16_t device_state, + uint64_t allocation_size, + void *private_data) +{ + struct named_pipe_client *npc; + + npc = talloc_zero(mem_ctx, struct named_pipe_client); + if (npc == NULL) { + DEBUG(0, ("Out of memory!\n")); + return NULL; + } + talloc_set_destructor(npc, named_pipe_destructor); + + npc->pipe_name = talloc_strdup(npc, pipe_name); + if (npc->pipe_name == NULL) { + DEBUG(0, ("Out of memory!\n")); + talloc_free(npc); + return NULL; + } + + npc->ev = ev_ctx; + npc->msg_ctx = msg_ctx; + npc->term_fn = term_fn; + npc->private_data = private_data; + + npc->file_type = file_type; + npc->device_state = device_state; + npc->allocation_size = allocation_size; + + return npc; +} + static void named_pipe_accept_done(struct tevent_req *subreq); void named_pipe_accept_function(struct tevent_context *ev_ctx, diff --git a/source3/rpc_server/rpc_server.h b/source3/rpc_server/rpc_server.h index 9e9036b93ca..d204a8b3adc 100644 --- a/source3/rpc_server/rpc_server.h +++ b/source3/rpc_server/rpc_server.h @@ -25,6 +25,46 @@ struct pipes_struct; typedef bool (*dcerpc_ncacn_disconnect_fn)(struct pipes_struct *p); typedef void (named_pipe_termination_fn)(void *private_data); +struct named_pipe_client { + const char *pipe_name; + + struct tevent_context *ev; + struct messaging_context *msg_ctx; + + uint16_t file_type; + uint16_t device_state; + uint64_t allocation_size; + + struct tstream_context *tstream; + + struct tsocket_address *client; + char *client_name; + struct tsocket_address *server; + char *server_name; + + struct auth_session_info *session_info; + + struct pipes_struct *p; + + struct tevent_queue *write_queue; + + struct iovec *iov; + size_t count; + + named_pipe_termination_fn *term_fn; + void *private_data; +}; + +struct named_pipe_client *named_pipe_client_init(TALLOC_CTX *mem_ctx, + struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, + const char *pipe_name, + named_pipe_termination_fn *term_fn, + uint16_t file_type, + uint16_t device_state, + uint64_t allocation_size, + void *private_data); + int make_server_pipes_struct(TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx, const char *pipe_name, -- 2.34.1