diff options
author | Jeremy Allison <jra@samba.org> | 2007-11-11 13:18:22 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2007-11-11 13:18:22 -0800 |
commit | a084eae03989957ad2cc4a9705697ca6c422b25c (patch) | |
tree | 1e6a286860758d90923b42626a3d316550058ac6 | |
parent | 63d141d4e8b6fa0977b9b89545e9cf8bc694f416 (diff) | |
parent | f976f5e067e48a10178ff296d343ef5007695848 (diff) | |
download | samba-a084eae03989957ad2cc4a9705697ca6c422b25c.tar.gz samba-a084eae03989957ad2cc4a9705697ca6c422b25c.tar.bz2 samba-a084eae03989957ad2cc4a9705697ca6c422b25c.zip |
Merge branch 'v3-2-test' of ssh://jra@git.samba.org/data/git/samba into v3-2-test
(This used to be commit b9d79fb509a6c59fdd73b016be5f4da3435c7789)
-rw-r--r-- | source3/lib/ctdbd_conn.c | 25 | ||||
-rw-r--r-- | source3/librpc/ndr/ndr.c | 66 |
2 files changed, 79 insertions, 12 deletions
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 2892b8f6ab..b43aec7fd0 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -243,7 +243,7 @@ static struct messaging_rec *ctdb_pull_messaging_rec(TALLOC_CTX *mem_ctx, { struct messaging_rec *result; DATA_BLOB blob; - NTSTATUS status; + enum ndr_err_code ndr_err; if ((overall_length < offsetof(struct ctdb_req_message, data)) || (overall_length @@ -259,22 +259,22 @@ static struct messaging_rec *ctdb_pull_messaging_rec(TALLOC_CTX *mem_ctx, blob = data_blob_const(msg->data, msg->datalen); - status = ndr_pull_struct_blob( + ndr_err = ndr_pull_struct_blob( &blob, result, result, (ndr_pull_flags_fn_t)ndr_pull_messaging_rec); - if (DEBUGLEVEL >= 10) { - DEBUG(10, ("ctdb_pull_messaging_rec:\n")); - NDR_PRINT_DEBUG(messaging_rec, result); - } - - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0, ("ndr_pull_struct_blob failed: %s\n", - nt_errstr(status))); + ndr_errstr(ndr_err))); TALLOC_FREE(result); return NULL; } + if (DEBUGLEVEL >= 10) { + DEBUG(10, ("ctdb_pull_messaging_rec:\n")); + NDR_PRINT_DEBUG(messaging_rec, result); + } + return result; } @@ -620,19 +620,20 @@ NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn, TALLOC_CTX *mem_ctx; DATA_BLOB blob; NTSTATUS status; + enum ndr_err_code ndr_err; if (!(mem_ctx = talloc_init("ctdbd_messaging_send"))) { DEBUG(0, ("talloc failed\n")); return NT_STATUS_NO_MEMORY; } - status = ndr_push_struct_blob( + ndr_err = ndr_push_struct_blob( &blob, mem_ctx, msg, (ndr_push_flags_fn_t)ndr_push_messaging_rec); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(0, ("ndr_push_struct_blob failed: %s\n", - nt_errstr(status))); + ndr_errstr(ndr_err))); goto fail; } diff --git a/source3/librpc/ndr/ndr.c b/source3/librpc/ndr/ndr.c index a1295c7db5..62a88a8856 100644 --- a/source3/librpc/ndr/ndr.c +++ b/source3/librpc/ndr/ndr.c @@ -376,6 +376,72 @@ NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err) } /* + * Convert an ndr error to string + */ + +const char *ndr_errstr(enum ndr_err_code err) +{ + switch (err) { + case NDR_ERR_SUCCESS: + return "NDR_ERR_SUCCESS"; + break; + case NDR_ERR_ARRAY_SIZE: + return "NDR_ERR_ARRAY_SIZE"; + break; + case NDR_ERR_BAD_SWITCH: + return "NDR_ERR_BAD_SWITCH"; + break; + case NDR_ERR_OFFSET: + return "NDR_ERR_OFFSET"; + break; + case NDR_ERR_RELATIVE: + return "NDR_ERR_RELATIVE"; + break; + case NDR_ERR_CHARCNV: + return "NDR_ERR_CHARCNV"; + break; + case NDR_ERR_LENGTH: + return "NDR_ERR_LENGTH"; + break; + case NDR_ERR_SUBCONTEXT: + return "NDR_ERR_SUBCONTEXT"; + break; + case NDR_ERR_COMPRESSION: + return "NDR_ERR_COMPRESSION"; + break; + case NDR_ERR_STRING: + return "NDR_ERR_STRING"; + break; + case NDR_ERR_VALIDATE: + return "NDR_ERR_VALIDATE"; + break; + case NDR_ERR_BUFSIZE: + return "NDR_ERR_BUFSIZE"; + break; + case NDR_ERR_ALLOC: + return "NDR_ERR_ALLOC"; + break; + case NDR_ERR_RANGE: + return "NDR_ERR_RANGE"; + break; + case NDR_ERR_TOKEN: + return "NDR_ERR_TOKEN"; + break; + case NDR_ERR_IPV4ADDRESS: + return "NDR_ERR_IPV4ADDRESS"; + break; + case NDR_ERR_INVALID_POINTER: + return "NDR_ERR_INVALID_POINTER"; + break; + case NDR_ERR_UNREAD_BYTES: + return "NDR_ERR_UNREAD_BYTES"; + break; + } + + return talloc_asprintf(talloc_tos(), "Unknown NDR error: %d", err); +} + +/* return and possibly log an NDR error */ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr, |