summaryrefslogtreecommitdiff
path: root/librpc
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-10 14:29:19 +1100
committerAndrew Tridgell <tridge@samba.org>2009-12-10 17:51:28 +1100
commit3ce800dcbe097f0683cedf7465f0562c7111444a (patch)
tree383c9d1862e9950e1a8f2b5dfda02f39109e0807 /librpc
parent2493776f59f13ce20a39c0767bdfe85de6b0bdcd (diff)
downloadsamba-3ce800dcbe097f0683cedf7465f0562c7111444a.tar.gz
samba-3ce800dcbe097f0683cedf7465f0562c7111444a.tar.bz2
samba-3ce800dcbe097f0683cedf7465f0562c7111444a.zip
libndr: added a GUID_to_ndr_blob() helper function
This can be used in many places that deal with GUIDs
Diffstat (limited to 'librpc')
-rw-r--r--librpc/ndr/libndr.h1
-rw-r--r--librpc/ndr/uuid.c20
2 files changed, 15 insertions, 6 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index d26adb8bbe..dbdc0e65bf 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -536,6 +536,7 @@ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const ch
/* GUIDs */
bool GUID_equal(const struct GUID *u1, const struct GUID *u2);
+NTSTATUS GUID_to_ndr_blob(const struct GUID *guid, TALLOC_CTX *mem_ctx, DATA_BLOB *b);
NTSTATUS GUID_from_ndr_blob(const DATA_BLOB *b, struct GUID *guid);
NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid);
NTSTATUS GUID_from_string(const char *s, struct GUID *guid);
diff --git a/librpc/ndr/uuid.c b/librpc/ndr/uuid.c
index c3f6a05453..429a1b1ac9 100644
--- a/librpc/ndr/uuid.c
+++ b/librpc/ndr/uuid.c
@@ -25,6 +25,17 @@
#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/ndr_misc.h"
+/**
+ build a NDR blob from a GUID
+*/
+_PUBLIC_ NTSTATUS GUID_to_ndr_blob(const struct GUID *guid, TALLOC_CTX *mem_ctx, DATA_BLOB *b)
+{
+ enum ndr_err_code ndr_err;
+ ndr_err = ndr_push_struct_blob(b, mem_ctx, NULL, guid,
+ (ndr_push_flags_fn_t)ndr_push_GUID);
+ return ndr_map_error2ntstatus(ndr_err);
+}
+
/**
build a GUID from a NDR data blob
@@ -280,18 +291,15 @@ _PUBLIC_ char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid)
{
char *ret;
DATA_BLOB guid_blob;
- enum ndr_err_code ndr_err;
TALLOC_CTX *tmp_mem;
+ NTSTATUS status;
tmp_mem = talloc_new(mem_ctx);
if (!tmp_mem) {
return NULL;
}
- ndr_err = ndr_push_struct_blob(&guid_blob, tmp_mem,
- NULL,
- guid,
- (ndr_push_flags_fn_t)ndr_push_GUID);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ status = GUID_to_ndr_blob(guid, tmp_mem, &guid_blob);
+ if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_mem);
return NULL;
}