summaryrefslogtreecommitdiff
path: root/librpc
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2013-08-08 17:33:29 +0200
committerGünther Deschner <gd@samba.org>2013-09-20 13:07:23 +0200
commit40ee3d8a5f7439b90f1ebf5e40535fad51038fe6 (patch)
treef18254201fc74e39db528cc74277edd999007eac /librpc
parent3135533710b2a1b64aaf6b10d30b86f3c004657d (diff)
downloadsamba-40ee3d8a5f7439b90f1ebf5e40535fad51038fe6.tar.gz
samba-40ee3d8a5f7439b90f1ebf5e40535fad51038fe6.tar.bz2
samba-40ee3d8a5f7439b90f1ebf5e40535fad51038fe6.zip
librpc: add dcerpc_default_transport_endpoint() function.
Guenther Signed-off-by: Günther Deschner <gd@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'librpc')
-rw-r--r--librpc/rpc/dcerpc_util.c55
-rw-r--r--librpc/rpc/rpc_common.h3
2 files changed, 58 insertions, 0 deletions
diff --git a/librpc/rpc/dcerpc_util.c b/librpc/rpc/dcerpc_util.c
index de292c8366..980b0709db 100644
--- a/librpc/rpc/dcerpc_util.c
+++ b/librpc/rpc/dcerpc_util.c
@@ -318,3 +318,58 @@ NTSTATUS dcerpc_read_ncacn_packet_recv(struct tevent_req *req,
tevent_req_received(req);
return NT_STATUS_OK;
}
+
+const char *dcerpc_default_transport_endpoint(TALLOC_CTX *mem_ctx,
+ enum dcerpc_transport_t transport,
+ const struct ndr_interface_table *table)
+{
+ NTSTATUS status;
+ const char *p = NULL;
+ const char *endpoint = NULL;
+ int i;
+ struct dcerpc_binding *default_binding = NULL;
+ TALLOC_CTX *frame = talloc_stackframe();
+
+ /* Find one of the default pipes for this interface */
+
+ for (i = 0; i < table->endpoints->count; i++) {
+
+ status = dcerpc_parse_binding(frame, table->endpoints->names[i],
+ &default_binding);
+ if (NT_STATUS_IS_OK(status)) {
+ if (transport == NCA_UNKNOWN &&
+ default_binding->endpoint != NULL) {
+ p = default_binding->endpoint;
+ break;
+ }
+ if (default_binding->transport == transport &&
+ default_binding->endpoint != NULL) {
+ p = default_binding->endpoint;
+ break;
+ }
+ }
+ }
+
+ if (i == table->endpoints->count || p == NULL) {
+ goto done;
+ }
+
+ /*
+ * extract the pipe name without \\pipe from for example
+ * ncacn_np:[\\pipe\\epmapper]
+ */
+ if (default_binding->transport == NCACN_NP) {
+ if (strncasecmp(p, "\\pipe\\", 6) == 0) {
+ p += 6;
+ }
+ if (strncmp(p, "\\", 1) == 0) {
+ p += 1;
+ }
+ }
+
+ endpoint = talloc_strdup(mem_ctx, p);
+
+ done:
+ talloc_free(frame);
+ return endpoint;
+}
diff --git a/librpc/rpc/rpc_common.h b/librpc/rpc/rpc_common.h
index e2b37550e1..d2816f508b 100644
--- a/librpc/rpc/rpc_common.h
+++ b/librpc/rpc/rpc_common.h
@@ -143,6 +143,9 @@ void dcerpc_set_frag_length(DATA_BLOB *blob, uint16_t v);
uint16_t dcerpc_get_frag_length(const DATA_BLOB *blob);
void dcerpc_set_auth_length(DATA_BLOB *blob, uint16_t v);
uint8_t dcerpc_get_endian_flag(DATA_BLOB *blob);
+const char *dcerpc_default_transport_endpoint(TALLOC_CTX *mem_ctx,
+ enum dcerpc_transport_t transport,
+ const struct ndr_interface_table *table);
/**
* @brief Pull a dcerpc_auth structure, taking account of any auth