diff options
author | Andreas Schneider <asn@samba.org> | 2011-06-30 11:56:11 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2011-08-01 08:50:35 +0200 |
commit | c810e475194775c63f32c4efeb9a505d9647b2bc (patch) | |
tree | f209f30e0ca290753de833826a7267098781116a | |
parent | 08523ed6b8105aee97225bdf389bd029754aacb1 (diff) | |
download | samba-c810e475194775c63f32c4efeb9a505d9647b2bc.tar.gz samba-c810e475194775c63f32c4efeb9a505d9647b2bc.tar.bz2 samba-c810e475194775c63f32c4efeb9a505d9647b2bc.zip |
s3-librpc: Add dcerpc_binding_vector_add_np_default().
-rw-r--r-- | source3/librpc/rpc/dcerpc_ep.c | 67 | ||||
-rw-r--r-- | source3/librpc/rpc/dcerpc_ep.h | 12 |
2 files changed, 79 insertions, 0 deletions
diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c index cd8b656a7b..bd4e9ee0d9 100644 --- a/source3/librpc/rpc/dcerpc_ep.c +++ b/source3/librpc/rpc/dcerpc_ep.c @@ -28,6 +28,25 @@ #define EPM_MAX_ANNOTATION_SIZE 64 +static bool binding_vector_realloc(struct dcerpc_binding_vector *bvec) +{ + if (bvec->count >= bvec->allocated) { + struct dcerpc_binding *tmp; + + tmp = talloc_realloc(bvec, + bvec->bindings, + struct dcerpc_binding, + bvec->allocated * 2); + if (tmp == NULL) { + return false; + } + bvec->bindings = tmp; + bvec->allocated = bvec->allocated * 2; + } + + return true; +} + NTSTATUS dcerpc_binding_vector_new(TALLOC_CTX *mem_ctx, struct dcerpc_binding_vector **pbvec) { @@ -66,6 +85,54 @@ done: return status; } +NTSTATUS dcerpc_binding_vector_add_np_default(const struct ndr_interface_table *iface, + struct dcerpc_binding_vector *bvec) +{ + uint32_t ep_count = iface->endpoints->count; + uint32_t i; + NTSTATUS status; + bool ok; + + for (i = 0; i < ep_count; i++) { + struct dcerpc_binding *b; + + b = talloc_zero(bvec->bindings, struct dcerpc_binding); + if (b == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = dcerpc_parse_binding(b, iface->endpoints->names[i], &b); + if (!NT_STATUS_IS_OK(status)) { + return NT_STATUS_UNSUCCESSFUL; + } + + /* Only add the named pipes defined in the iface endpoints */ + if (b->transport != NCACN_NP) { + talloc_free(b); + continue; + } + + b->object = iface->syntax_id; + + b->host = talloc_asprintf(b, "\\\\%s", lp_netbios_name()); + if (b->host == NULL) { + talloc_free(b); + return NT_STATUS_NO_MEMORY; + } + + ok = binding_vector_realloc(bvec); + if (!ok) { + talloc_free(b); + return NT_STATUS_NO_MEMORY; + } + + bvec->bindings[bvec->count] = *b; + bvec->count++; + } + + return NT_STATUS_OK; +} + NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *iface, uint16_t port, diff --git a/source3/librpc/rpc/dcerpc_ep.h b/source3/librpc/rpc/dcerpc_ep.h index 61b85e23dc..b8ea7abeb4 100644 --- a/source3/librpc/rpc/dcerpc_ep.h +++ b/source3/librpc/rpc/dcerpc_ep.h @@ -38,6 +38,18 @@ struct dcerpc_binding_vector { NTSTATUS dcerpc_binding_vector_new(TALLOC_CTX *mem_ctx, struct dcerpc_binding_vector **pbvec); +/** + * @brief Add default named pipes to the binding vector. + * + * @param[in] iface The rpc interface to add. + * + * @param[in] bvec The binding vector to add the interface. + * + * @return An NTSTATUS error code. + */ +NTSTATUS dcerpc_binding_vector_add_np_default(const struct ndr_interface_table *iface, + struct dcerpc_binding_vector *bvec); + NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *iface, uint16_t port, |