s3-rpc_server: Add named_pipe_client_init() function.
authorAndreas Schneider <asn@samba.org>
Wed, 25 Sep 2013 09:34:56 +0000 (11:34 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 29 Oct 2013 14:51:47 +0000 (15:51 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/rpc_server/rpc_server.c
source3/rpc_server/rpc_server.h

index cecc9881f3021e85126ab230c7250d1ee49e08fc..f283559dddd4e6d6966453abba1cba01938f64d4 100644 (file)
@@ -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,
index 9e9036b93cac5cced94997f4998c5eda0f5792ce..d204a8b3adc6bf66823a054eaca653c3ec21f5b6 100644 (file)
@@ -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,