summaryrefslogtreecommitdiffstats
path: root/librpc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-01-24 16:56:34 +0100
committerGünther Deschner <gd@samba.org>2014-02-13 11:54:15 +0100
commitf066bd7b33e6c44311af7d82835017aac0b85c0d (patch)
tree3d04dadaa59556535ac803d587c0b899578bf664 /librpc
parent8dac96728aee72f4d5510d53c3b00bdbd250a867 (diff)
downloadsamba-f066bd7b33e6c44311af7d82835017aac0b85c0d.tar.gz
samba-f066bd7b33e6c44311af7d82835017aac0b85c0d.tar.xz
samba-f066bd7b33e6c44311af7d82835017aac0b85c0d.zip
librpc/rpc: add dcerpc_binding_[g|s]et_object()
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
Diffstat (limited to 'librpc')
-rw-r--r--librpc/rpc/binding.c69
-rw-r--r--librpc/rpc/rpc_common.h3
2 files changed, 44 insertions, 28 deletions
diff --git a/librpc/rpc/binding.c b/librpc/rpc/binding.c
index 09c0c8d6cbc..43bbbce2540 100644
--- a/librpc/rpc/binding.c
+++ b/librpc/rpc/binding.c
@@ -428,6 +428,35 @@ _PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *_s, stru
return NT_STATUS_OK;
}
+_PUBLIC_ struct GUID dcerpc_binding_get_object(const struct dcerpc_binding *b)
+{
+ return b->object.uuid;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_binding_set_object(struct dcerpc_binding *b,
+ struct GUID object)
+{
+ char *tmp = discard_const_p(char, b->object_string);
+
+ if (GUID_all_zero(&object)) {
+ talloc_free(tmp);
+ b->object_string = NULL;
+ ZERO_STRUCT(b->object);
+ return NT_STATUS_OK;
+ }
+
+ b->object_string = GUID_string(b, &object);
+ if (b->object_string == NULL) {
+ b->object_string = tmp;
+ return NT_STATUS_NO_MEMORY;
+ }
+ talloc_free(tmp);
+
+ ZERO_STRUCT(b->object);
+ b->object.uuid = object;
+ return NT_STATUS_OK;
+}
+
_PUBLIC_ void dcerpc_binding_get_auth_info(const struct dcerpc_binding *b,
enum dcerpc_AuthType *_auth_type,
enum dcerpc_AuthLevel *_auth_level)
@@ -598,39 +627,23 @@ _PUBLIC_ NTSTATUS dcerpc_binding_set_string_option(struct dcerpc_binding *b,
ret = strcmp(name, "object");
if (ret == 0) {
- DATA_BLOB blob;
NTSTATUS status;
- struct GUID uuid;
-
- tmp = discard_const_p(char, b->object_string);
+ struct GUID uuid = GUID_zero();
- if (value == NULL) {
- talloc_free(tmp);
- b->object_string = NULL;
- ZERO_STRUCT(b->object);
- return NT_STATUS_OK;
- }
-
- blob = data_blob_string_const(value);
- if (blob.length != 36) {
- return NT_STATUS_INVALID_PARAMETER_MIX;
- }
-
- status = GUID_from_data_blob(&blob, &uuid);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
+ if (value != NULL) {
+ DATA_BLOB blob;
+ blob = data_blob_string_const(value);
+ if (blob.length != 36) {
+ return NT_STATUS_INVALID_PARAMETER_MIX;
+ }
- b->object_string = GUID_string(b, &uuid);
- if (b->object_string == NULL) {
- b->object_string = tmp;
- return NT_STATUS_NO_MEMORY;
+ status = GUID_from_data_blob(&blob, &uuid);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
}
- talloc_free(tmp);
- ZERO_STRUCT(b->object);
- b->object.uuid = uuid;
- return NT_STATUS_OK;
+ return dcerpc_binding_set_object(b, uuid);
}
for (i=0; i < ARRAY_SIZE(specials); i++) {
diff --git a/librpc/rpc/rpc_common.h b/librpc/rpc/rpc_common.h
index 2ac243b700f..473d126a6a4 100644
--- a/librpc/rpc/rpc_common.h
+++ b/librpc/rpc/rpc_common.h
@@ -133,6 +133,9 @@ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
struct dcerpc_binding **b_out);
NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out);
char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b);
+struct GUID dcerpc_binding_get_object(const struct dcerpc_binding *b);
+NTSTATUS dcerpc_binding_set_object(struct dcerpc_binding *b,
+ struct GUID object);
void dcerpc_binding_get_auth_info(const struct dcerpc_binding *b,
enum dcerpc_AuthType *_auth_type,
enum dcerpc_AuthLevel *_auth_level);