source: trunk/server/librpc/rpc/dcerpc_error.c

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 4.2 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 dcerpc fault functions
5
6 Copyright (C) Stefan Metzmacher 2004
7
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.
12
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.
17
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/>.
20*/
21
22#include "includes.h"
23#include "librpc/rpc/dcerpc.h"
24#include "rpc_common.h"
25
26struct dcerpc_fault_table {
27 const char *errstr;
28 uint32_t faultcode;
29};
30
31static const struct dcerpc_fault_table dcerpc_faults[] =
32{
33#define _FAULT_STR(x) { #x , x }
34 _FAULT_STR(DCERPC_NCA_S_COMM_FAILURE),
35 _FAULT_STR(DCERPC_NCA_S_OP_RNG_ERROR),
36 _FAULT_STR(DCERPC_NCA_S_UNKNOWN_IF),
37 _FAULT_STR(DCERPC_NCA_S_WRONG_BOOT_TIME),
38 _FAULT_STR(DCERPC_NCA_S_YOU_CRASHED),
39 _FAULT_STR(DCERPC_NCA_S_PROTO_ERROR),
40 _FAULT_STR(DCERPC_NCA_S_OUT_ARGS_TOO_BIG),
41 _FAULT_STR(DCERPC_NCA_S_SERVER_TOO_BUSY),
42 _FAULT_STR(DCERPC_NCA_S_FAULT_STRING_TOO_LARGE),
43 _FAULT_STR(DCERPC_NCA_S_UNSUPPORTED_TYPE),
44 _FAULT_STR(DCERPC_NCA_S_FAULT_INT_DIV_BY_ZERO),
45 _FAULT_STR(DCERPC_NCA_S_FAULT_ADDR_ERROR),
46 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_DIV_BY_ZERO),
47 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_UNDERFLOW),
48 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_OVERRFLOW),
49 _FAULT_STR(DCERPC_NCA_S_FAULT_INVALID_TAG),
50 _FAULT_STR(DCERPC_NCA_S_FAULT_INVALID_BOUND),
51 _FAULT_STR(DCERPC_NCA_S_FAULT_RPC_VERSION_MISMATCH),
52 _FAULT_STR(DCERPC_NCA_S_FAULT_UNSPEC_REJECT),
53 _FAULT_STR(DCERPC_NCA_S_FAULT_BAD_ACTID),
54 _FAULT_STR(DCERPC_NCA_S_FAULT_WHO_ARE_YOU_FAILED),
55 _FAULT_STR(DCERPC_NCA_S_FAULT_MANAGER_NOT_ENTERED),
56 _FAULT_STR(DCERPC_NCA_S_FAULT_CANCEL),
57 _FAULT_STR(DCERPC_NCA_S_FAULT_ILL_INST),
58 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_ERROR),
59 _FAULT_STR(DCERPC_NCA_S_FAULT_INT_OVERFLOW),
60 _FAULT_STR(DCERPC_NCA_S_UNUSED_1C000011),
61 _FAULT_STR(DCERPC_NCA_S_FAULT_UNSPEC),
62 _FAULT_STR(DCERPC_NCA_S_FAULT_REMOTE_COMM_FAILURE),
63 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_EMPTY),
64 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_CLOSED),
65 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_ORDER),
66 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_DISCIPLINE),
67 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_COMM_ERROR),
68 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_MEMORY),
69 _FAULT_STR(DCERPC_NCA_S_FAULT_CONTEXT_MISMATCH),
70 _FAULT_STR(DCERPC_NCA_S_FAULT_REMOTE_NO_MEMORY),
71 _FAULT_STR(DCERPC_NCA_S_INVALID_PRES_CONTEXT_ID),
72 _FAULT_STR(DCERPC_NCA_S_UNSUPPORTED_AUTHN_LEVEL),
73 _FAULT_STR(DCERPC_NCA_S_UNUSED_1C00001E),
74 _FAULT_STR(DCERPC_NCA_S_INVALID_CHECKSUM),
75 _FAULT_STR(DCERPC_NCA_S_INVALID_CRC),
76 _FAULT_STR(DCERPC_NCA_S_FAULT_USER_DEFINED),
77 _FAULT_STR(DCERPC_NCA_S_FAULT_TX_OPEN_FAILED),
78 _FAULT_STR(DCERPC_NCA_S_FAULT_CODESET_CONV_ERROR),
79 _FAULT_STR(DCERPC_NCA_S_FAULT_OBJECT_NOT_FOUND),
80 _FAULT_STR(DCERPC_NCA_S_FAULT_NO_CLIENT_STUB),
81 { NULL, 0 }
82#undef _FAULT_STR
83};
84
85_PUBLIC_ const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code)
86{
87 int idx = 0;
88 WERROR werr = W_ERROR(fault_code);
89
90 while (dcerpc_faults[idx].errstr != NULL) {
91 if (dcerpc_faults[idx].faultcode == fault_code) {
92 return dcerpc_faults[idx].errstr;
93 }
94 idx++;
95 }
96
97 return win_errstr(werr);
98}
99
100_PUBLIC_ NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code)
101{
102 /* TODO: add more mappings */
103 switch (fault_code) {
104 case DCERPC_FAULT_OP_RNG_ERROR:
105 return NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE;
106 case DCERPC_FAULT_UNK_IF:
107 return NT_STATUS_RPC_UNKNOWN_IF;
108 case DCERPC_FAULT_NDR:
109 return NT_STATUS_RPC_BAD_STUB_DATA;
110 case DCERPC_FAULT_INVALID_TAG:
111 return NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE;
112 case DCERPC_FAULT_CONTEXT_MISMATCH:
113 return NT_STATUS_RPC_SS_CONTEXT_MISMATCH;
114 case DCERPC_FAULT_OTHER:
115 return NT_STATUS_RPC_CALL_FAILED;
116 case DCERPC_FAULT_ACCESS_DENIED:
117 return NT_STATUS_ACCESS_DENIED;
118 case DCERPC_FAULT_SEC_PKG_ERROR:
119 return NT_STATUS_RPC_SEC_PKG_ERROR;
120 }
121
122 return NT_STATUS_RPC_PROTOCOL_ERROR;
123}
124
Note: See TracBrowser for help on using the repository browser.