From 81a2046879299a051e69fd4d78b3a8e49b690f1b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 9 Mar 2011 10:17:06 +0100 Subject: s3-librpc: Leave the epm registration connection open. --- source3/librpc/rpc/dcerpc_ep.c | 50 ++++++++++++++++++++++++++++++++++-------- source3/librpc/rpc/dcerpc_ep.h | 18 +++++++++++---- 2 files changed, 55 insertions(+), 13 deletions(-) (limited to 'source3/librpc') diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c index 764dc17233..92c01a32bb 100644 --- a/source3/librpc/rpc/dcerpc_ep.c +++ b/source3/librpc/rpc/dcerpc_ep.c @@ -130,12 +130,14 @@ done: return status; } -static NTSTATUS ep_register(const struct ndr_interface_table *iface, +static NTSTATUS ep_register(TALLOC_CTX *mem_ctx, + const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, const char *annotation, uint32_t replace, - uint32_t unregister) + uint32_t unregister, + struct dcerpc_binding_handle **pbh) { struct rpc_pipe_client *cli = NULL; struct dcerpc_binding_handle *h; @@ -285,33 +287,63 @@ static NTSTATUS ep_register(const struct ndr_interface_table *iface, goto done; } + if (pbh != NULL) { + *pbh = talloc_move(mem_ctx, &h); + talloc_steal(mem_ctx, cli); + } + done: talloc_free(tmp_ctx); return status; } -NTSTATUS dcerpc_ep_register(const struct ndr_interface_table *iface, +NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, + const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, - const char *annotation) + const char *annotation, + struct dcerpc_binding_handle **ph) { - return ep_register(iface, bind_vec, object_guid, annotation, 1, 0); + return ep_register(mem_ctx, + iface, + bind_vec, + object_guid, + annotation, + 1, + 0, + ph); } -NTSTATUS dcerpc_ep_register_noreplace(const struct ndr_interface_table *iface, +NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx, + const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, - const char *annotation) + const char *annotation, + struct dcerpc_binding_handle **ph) { - return ep_register(iface, bind_vec, object_guid, annotation, 0, 0); + return ep_register(mem_ctx, + iface, + bind_vec, + object_guid, + annotation, + 0, + 0, + ph); } NTSTATUS dcerpc_ep_unregister(const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid) { - return ep_register(iface, bind_vec, object_guid, NULL, 0, 1); + return ep_register(NULL, + iface, + bind_vec, + object_guid, + NULL, + 0, + 1, + NULL); } /* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */ diff --git a/source3/librpc/rpc/dcerpc_ep.h b/source3/librpc/rpc/dcerpc_ep.h index 99682beb9a..57b1d27440 100644 --- a/source3/librpc/rpc/dcerpc_ep.h +++ b/source3/librpc/rpc/dcerpc_ep.h @@ -34,6 +34,8 @@ NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx, /** * @brief Adds server address information in the local endpoint map. * + * @param[in] mem_ctx The memory context to use for the binding handle. + * * @param[in] iface The interface specification to register with the local * endpoint map. * @@ -55,17 +57,25 @@ NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx, * supplied, including an empty annotation string, * replaces any existing annotation string. * + * @param[out] ph A pointer to store the binding handle. The memory + * context will be the give one. If you free this handle + * then the connection will be closed. + * * @return An NTSTATUS error code. */ -NTSTATUS dcerpc_ep_register(const struct ndr_interface_table *iface, +NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, + const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, - const char *annotation); + const char *annotation, + struct dcerpc_binding_handle **ph); -NTSTATUS dcerpc_ep_register_noreplace(const struct ndr_interface_table *iface, +NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx, + const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, const struct GUID *object_guid, - const char *annotation); + const char *annotation, + struct dcerpc_binding_handle **ph); NTSTATUS dcerpc_ep_unregister(const struct ndr_interface_table *iface, const struct dcerpc_binding_vector *bind_vec, -- cgit