1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

librpc: add dcerpc_default_transport_endpoint() function.

Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Günther Deschner 2013-08-08 17:33:29 +02:00
parent 3135533710
commit 40ee3d8a5f
2 changed files with 58 additions and 0 deletions

View File

@ -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;
}

View File

@ -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