diff options
author | Andrew Tridgell <tridge@samba.org> | 2008-02-12 16:18:51 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2008-02-12 16:18:51 +1100 |
commit | 7b96c53bcbe367963da4f4fa87704e1435c35055 (patch) | |
tree | e055c57cc8f53f7b65d96f915b8ae57da5afcd0d /source4 | |
parent | f7bcc15bf8acc157dde8a9895773a0dd03ca6cfb (diff) | |
download | samba-7b96c53bcbe367963da4f4fa87704e1435c35055.tar.gz samba-7b96c53bcbe367963da4f4fa87704e1435c35055.tar.bz2 samba-7b96c53bcbe367963da4f4fa87704e1435c35055.zip |
added some helper functions for GUID handling
(This used to be commit 7d3ffd4d2b59d7c87c0a81030f349db21c071967)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/libcli/raw/rawrequest.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c index e7dffaf054..3551e5d441 100644 --- a/source4/libcli/raw/rawrequest.c +++ b/source4/libcli/raw/rawrequest.c @@ -972,3 +972,44 @@ size_t smbcli_blob_append_string(struct smbcli_session *session, return len; } + +/* + pull a GUID structure from the wire. The buffer must be at least 16 + bytes long + */ +enum ndr_err_code smbcli_pull_guid(void *base, uint16_t offset, + struct GUID *guid) +{ + DATA_BLOB blob; + TALLOC_CTX *tmp_ctx = talloc_new(NULL); + enum ndr_err_code ndr_err; + + ZERO_STRUCTP(guid); + + blob.data = offset + (uint8_t *)base; + blob.length = 16; + ndr_err = ndr_pull_struct_blob(&blob, tmp_ctx, NULL, guid, + (ndr_pull_flags_fn_t)ndr_pull_GUID); + talloc_free(tmp_ctx); + return ndr_err; +} + +/* + push a guid onto the wire. The buffer must hold 16 bytes + */ +enum ndr_err_code smbcli_push_guid(void *base, uint16_t offset, + const struct GUID *guid) +{ + TALLOC_CTX *tmp_ctx = talloc_new(NULL); + enum ndr_err_code ndr_err; + DATA_BLOB blob; + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, NULL, + guid, (ndr_push_flags_fn_t)ndr_push_GUID); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err) || blob.length != 16) { + talloc_free(tmp_ctx); + return ndr_err; + } + memcpy(offset + (uint8_t *)base, blob.data, blob.length); + talloc_free(tmp_ctx); + return ndr_err; +} |