summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-09-03 19:28:00 +0200
committerStefan Metzmacher <metze@samba.org>2010-09-04 09:01:10 +0200
commit2907310803a3168582fa0d7ffb5c357e89723434 (patch)
tree63351ea8c4abd55885b9a2d943f41e445046500f
parent389d35708ea910e68468648396f405e52907c749 (diff)
downloadsamba-2907310803a3168582fa0d7ffb5c357e89723434.tar.gz
samba-2907310803a3168582fa0d7ffb5c357e89723434.tar.bz2
samba-2907310803a3168582fa0d7ffb5c357e89723434.zip
s3:rpc_server: make it possible to use rpcint_binding_handle() directly
metze
-rw-r--r--source3/include/client.h3
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/rpc_server/rpc_ncacn_np_internal.c94
3 files changed, 82 insertions, 21 deletions
diff --git a/source3/include/client.h b/source3/include/client.h
index 326931c95f..03d4c85583 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -125,9 +125,6 @@ struct rpc_pipe_client {
/* The following is only non-null on a netlogon client pipe. */
struct netlogon_creds_CredentialState *dc;
-
- /* Used by internal rpc_pipe_client */
- struct pipes_struct *pipes_struct;
};
/* Transport encryption state. */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 180e1c03bd..2f82e70f5f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4169,6 +4169,12 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
struct client_address *client_id,
struct auth_serversupplied_info *server_info,
struct messaging_context *msg_ctx);
+NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
+ const struct ndr_interface_table *ndr_table,
+ struct client_address *client_id,
+ struct auth_serversupplied_info *server_info,
+ struct messaging_context *msg_ctx,
+ struct dcerpc_binding_handle **binding_handle);
NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
const struct ndr_syntax_id *abstract_syntax,
struct auth_serversupplied_info *serversupplied_info,
diff --git a/source3/rpc_server/rpc_ncacn_np_internal.c b/source3/rpc_server/rpc_ncacn_np_internal.c
index d4cb342e1a..69688d3658 100644
--- a/source3/rpc_server/rpc_ncacn_np_internal.c
+++ b/source3/rpc_server/rpc_ncacn_np_internal.c
@@ -417,25 +417,84 @@ static const struct dcerpc_binding_handle_ops rpcint_bh_ops = {
.do_ndr_print = rpcint_bh_do_ndr_print,
};
-/* initialise a wbint binding handle */
-static struct dcerpc_binding_handle *rpcint_binding_handle(struct pipes_struct *p)
+static NTSTATUS rpcint_binding_handle_ex(TALLOC_CTX *mem_ctx,
+ const struct ndr_syntax_id *abstract_syntax,
+ const struct ndr_interface_table *ndr_table,
+ struct client_address *client_id,
+ struct auth_serversupplied_info *server_info,
+ struct messaging_context *msg_ctx,
+ struct dcerpc_binding_handle **binding_handle)
{
struct dcerpc_binding_handle *h;
struct rpcint_bh_state *hs;
- h = dcerpc_binding_handle_create(p,
+ if (ndr_table) {
+ abstract_syntax = &ndr_table->syntax_id;
+ }
+
+ h = dcerpc_binding_handle_create(mem_ctx,
&rpcint_bh_ops,
NULL,
- NULL, /* TODO */
+ ndr_table,
&hs,
struct rpcint_bh_state,
__location__);
if (h == NULL) {
- return NULL;
+ return NT_STATUS_NO_MEMORY;
+ }
+ hs->p = make_internal_rpc_pipe_p(hs,
+ abstract_syntax,
+ client_id,
+ server_info,
+ msg_ctx);
+ if (hs->p == NULL) {
+ TALLOC_FREE(h);
+ return NT_STATUS_NO_MEMORY;
}
- hs->p = p;
- return h;
+ *binding_handle = h;
+ return NT_STATUS_OK;
+}
+/**
+ * @brief Create a new DCERPC Binding Handle which uses a local dispatch function.
+ *
+ * @param[in] mem_ctx The memory context to use.
+ *
+ * @param[in] ndr_table Normally the ndr_table_<name>.
+ *
+ * @param[in] client_id The info about the connected client.
+ *
+ * @param[in] serversupplied_info The server supplied authentication function.
+ *
+ * @param[in] msg_ctx The messaging context that can be used by the server
+ *
+ * @param[out] binding_handle A pointer to store the connected
+ * dcerpc_binding_handle
+ *
+ * @return NT_STATUS_OK on success, a corresponding NT status if an
+ * error occured.
+ *
+ * @code
+ * struct dcerpc_binding_handle *winreg_binding;
+ * NTSTATUS status;
+ *
+ * status = rpcint_binding_handle(tmp_ctx,
+ * &ndr_table_winreg,
+ * p->client_id,
+ * p->server_info,
+ * p->msg_ctx
+ * &winreg_binding);
+ * @endcode
+ */
+NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
+ const struct ndr_interface_table *ndr_table,
+ struct client_address *client_id,
+ struct auth_serversupplied_info *server_info,
+ struct messaging_context *msg_ctx,
+ struct dcerpc_binding_handle **binding_handle)
+{
+ return rpcint_binding_handle_ex(mem_ctx, NULL, ndr_table, client_id,
+ server_info, msg_ctx, binding_handle);
}
/**
@@ -475,6 +534,7 @@ NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client **presult)
{
struct rpc_pipe_client *result;
+ NTSTATUS status;
result = TALLOC_ZERO_P(mem_ctx, struct rpc_pipe_client);
if (result == NULL) {
@@ -491,21 +551,19 @@ NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
client_id = &unknown;
}
- result->pipes_struct = make_internal_rpc_pipe_p(
- result, abstract_syntax, client_id, serversupplied_info,
- msg_ctx);
- if (result->pipes_struct == NULL) {
- TALLOC_FREE(result);
- return NT_STATUS_NO_MEMORY;
- }
-
result->max_xmit_frag = -1;
result->max_recv_frag = -1;
- result->binding_handle = rpcint_binding_handle(result->pipes_struct);
- if (result->binding_handle == NULL) {
+ status = rpcint_binding_handle_ex(result,
+ abstract_syntax,
+ NULL,
+ client_id,
+ serversupplied_info,
+ msg_ctx,
+ &result->binding_handle);
+ if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(result);
- return NT_STATUS_NO_MEMORY;
+ return status;
}
*presult = result;