diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-03-19 22:22:58 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2015-07-03 02:00:28 +0200 |
commit | 18dce19ef988d5398ba3f3ae59931b121dd85e3d (patch) | |
tree | df745db2278f41015ac94a64a015593f09bb4aba /librpc/rpc | |
parent | 1eef70872930fa4f9d3dedd23476b34cae638428 (diff) | |
download | samba-18dce19ef988d5398ba3f3ae59931b121dd85e3d.tar.gz |
librpc/rpc: add dcerpc_fault_from_nt_status()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Diffstat (limited to 'librpc/rpc')
-rw-r--r-- | librpc/rpc/dcerpc_error.c | 21 | ||||
-rw-r--r-- | librpc/rpc/rpc_common.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/librpc/rpc/dcerpc_error.c b/librpc/rpc/dcerpc_error.c index 3366f63e916..2b90334bf72 100644 --- a/librpc/rpc/dcerpc_error.c +++ b/librpc/rpc/dcerpc_error.c @@ -129,3 +129,24 @@ _PUBLIC_ NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code) return werror_to_ntstatus(werr); } + +_PUBLIC_ uint32_t dcerpc_fault_from_nt_status(NTSTATUS nt_status) +{ + int idx = 0; + WERROR werr; + + if (NT_STATUS_IS_OK(nt_status)) { + return DCERPC_NCA_S_PROTO_ERROR; + } + + while (dcerpc_faults[idx].errstr != NULL) { + if (NT_STATUS_EQUAL(dcerpc_faults[idx].nt_status, nt_status)) { + return dcerpc_faults[idx].faultcode; + } + idx++; + } + + werr = ntstatus_to_werror(nt_status); + + return W_ERROR_V(werr); +} diff --git a/librpc/rpc/rpc_common.h b/librpc/rpc/rpc_common.h index 61a8eab71d1..4210228d1d1 100644 --- a/librpc/rpc/rpc_common.h +++ b/librpc/rpc/rpc_common.h @@ -108,6 +108,7 @@ struct dcerpc_binding; const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code); NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code); +uint32_t dcerpc_fault_from_nt_status(NTSTATUS nt_status); /* The following definitions come from ../librpc/rpc/binding.c */ |