s4:drsuapi RPC server - fix "enum security_user_level" warning on Tru64
[Samba/gebeck_regimport.git] / librpc / rpc / dcerpc_error.c
blobb4289db356baf3bbd0de93335323d3d54b0514c1
1 /*
2 Unix SMB/CIFS implementation.
4 dcerpc fault functions
6 Copyright (C) Stefan Metzmacher 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "librpc/rpc/dcerpc.h"
25 struct dcerpc_fault_table {
26 const char *errstr;
27 uint32_t faultcode;
30 static const struct dcerpc_fault_table dcerpc_faults[] =
32 #define _FAULT_STR(x) { #x , x }
33 _FAULT_STR(DCERPC_NCA_S_COMM_FAILURE),
34 _FAULT_STR(DCERPC_NCA_S_OP_RNG_ERROR),
35 _FAULT_STR(DCERPC_NCA_S_UNKNOWN_IF),
36 _FAULT_STR(DCERPC_NCA_S_WRONG_BOOT_TIME),
37 _FAULT_STR(DCERPC_NCA_S_YOU_CRASHED),
38 _FAULT_STR(DCERPC_NCA_S_PROTO_ERROR),
39 _FAULT_STR(DCERPC_NCA_S_OUT_ARGS_TOO_BIG),
40 _FAULT_STR(DCERPC_NCA_S_SERVER_TOO_BUSY),
41 _FAULT_STR(DCERPC_NCA_S_FAULT_STRING_TOO_LARGE),
42 _FAULT_STR(DCERPC_NCA_S_UNSUPPORTED_TYPE),
43 _FAULT_STR(DCERPC_NCA_S_FAULT_INT_DIV_BY_ZERO),
44 _FAULT_STR(DCERPC_NCA_S_FAULT_ADDR_ERROR),
45 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_DIV_BY_ZERO),
46 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_UNDERFLOW),
47 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_OVERRFLOW),
48 _FAULT_STR(DCERPC_NCA_S_FAULT_INVALID_TAG),
49 _FAULT_STR(DCERPC_NCA_S_FAULT_INVALID_BOUND),
50 _FAULT_STR(DCERPC_NCA_S_FAULT_RPC_VERSION_MISMATCH),
51 _FAULT_STR(DCERPC_NCA_S_FAULT_UNSPEC_REJECT),
52 _FAULT_STR(DCERPC_NCA_S_FAULT_BAD_ACTID),
53 _FAULT_STR(DCERPC_NCA_S_FAULT_WHO_ARE_YOU_FAILED),
54 _FAULT_STR(DCERPC_NCA_S_FAULT_MANAGER_NOT_ENTERED),
55 _FAULT_STR(DCERPC_NCA_S_FAULT_CANCEL),
56 _FAULT_STR(DCERPC_NCA_S_FAULT_ILL_INST),
57 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_ERROR),
58 _FAULT_STR(DCERPC_NCA_S_FAULT_INT_OVERFLOW),
59 _FAULT_STR(DCERPC_NCA_S_UNUSED_1C000011),
60 _FAULT_STR(DCERPC_NCA_S_FAULT_UNSPEC),
61 _FAULT_STR(DCERPC_NCA_S_FAULT_REMOTE_COMM_FAILURE),
62 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_EMPTY),
63 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_CLOSED),
64 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_ORDER),
65 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_DISCIPLINE),
66 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_COMM_ERROR),
67 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_MEMORY),
68 _FAULT_STR(DCERPC_NCA_S_FAULT_CONTEXT_MISMATCH),
69 _FAULT_STR(DCERPC_NCA_S_FAULT_REMOTE_NO_MEMORY),
70 _FAULT_STR(DCERPC_NCA_S_INVALID_PRES_CONTEXT_ID),
71 _FAULT_STR(DCERPC_NCA_S_UNSUPPORTED_AUTHN_LEVEL),
72 _FAULT_STR(DCERPC_NCA_S_UNUSED_1C00001E),
73 _FAULT_STR(DCERPC_NCA_S_INVALID_CHECKSUM),
74 _FAULT_STR(DCERPC_NCA_S_INVALID_CRC),
75 _FAULT_STR(DCERPC_NCA_S_FAULT_USER_DEFINED),
76 _FAULT_STR(DCERPC_NCA_S_FAULT_TX_OPEN_FAILED),
77 _FAULT_STR(DCERPC_NCA_S_FAULT_CODESET_CONV_ERROR),
78 _FAULT_STR(DCERPC_NCA_S_FAULT_OBJECT_NOT_FOUND),
79 _FAULT_STR(DCERPC_NCA_S_FAULT_NO_CLIENT_STUB),
80 { NULL, 0 }
81 #undef _FAULT_STR
84 _PUBLIC_ const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code)
86 int idx = 0;
87 WERROR werr = W_ERROR(fault_code);
89 while (dcerpc_faults[idx].errstr != NULL) {
90 if (dcerpc_faults[idx].faultcode == fault_code) {
91 return dcerpc_faults[idx].errstr;
93 idx++;
96 return win_errstr(werr);
99 _PUBLIC_ NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code)
101 /* TODO: add more mappings */
102 switch (fault_code) {
103 case DCERPC_FAULT_OP_RNG_ERROR:
104 return NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE;
105 case DCERPC_FAULT_UNK_IF:
106 return NT_STATUS_RPC_UNKNOWN_IF;
107 case DCERPC_FAULT_NDR:
108 return NT_STATUS_RPC_BAD_STUB_DATA;
109 case DCERPC_FAULT_INVALID_TAG:
110 return NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE;
111 case DCERPC_FAULT_CONTEXT_MISMATCH:
112 return NT_STATUS_RPC_SS_CONTEXT_MISMATCH;
113 case DCERPC_FAULT_OTHER:
114 return NT_STATUS_RPC_CALL_FAILED;
115 case DCERPC_FAULT_ACCESS_DENIED:
116 return NT_STATUS_ACCESS_DENIED;
119 return NT_STATUS_RPC_PROTOCOL_ERROR;