| 1 |
/* |
| 2 |
Unix SMB/CIFS implementation. |
| 3 |
SMB parameters and setup, plus a whole lot more. |
| 4 |
|
| 5 |
Copyright (C) Andrew Tridgell 2001 |
| 6 |
|
| 7 |
This program is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 3 of the License, or |
| 10 |
(at your option) any later version. |
| 11 |
|
| 12 |
This program is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef _WERROR_H_ |
| 22 |
#define _WERROR_H_ |
| 23 |
|
| 24 |
#include <stdint.h> |
| 25 |
|
| 26 |
/* the following rather strange looking definitions of NTSTATUS and WERROR |
| 27 |
and there in order to catch common coding errors where different error types |
| 28 |
are mixed up. This is especially important as we slowly convert Samba |
| 29 |
from using bool for internal functions |
| 30 |
*/ |
| 31 |
|
| 32 |
#if defined(HAVE_IMMEDIATE_STRUCTURES) |
| 33 |
typedef struct {uint32_t w;} WERROR; |
| 34 |
#define W_ERROR(x) ((WERROR) { x }) |
| 35 |
#define W_ERROR_V(x) ((x).w) |
| 36 |
#else |
| 37 |
typedef uint32_t WERROR; |
| 38 |
#define W_ERROR(x) (x) |
| 39 |
#define W_ERROR_V(x) (x) |
| 40 |
#endif |
| 41 |
|
| 42 |
#include "libcli/util/werror_gen.h" |
| 43 |
|
| 44 |
#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0) |
| 45 |
#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y)) |
| 46 |
|
| 47 |
#define W_ERROR_HAVE_NO_MEMORY(x) do { \ |
| 48 |
if (!(x)) {\ |
| 49 |
return WERR_NOT_ENOUGH_MEMORY;\ |
| 50 |
}\ |
| 51 |
} while (0) |
| 52 |
|
| 53 |
#define W_ERROR_HAVE_NO_MEMORY_AND_FREE(x, ctx) do { \ |
| 54 |
if (!(x)) {\ |
| 55 |
talloc_free(ctx); \ |
| 56 |
return WERR_NOT_ENOUGH_MEMORY;\ |
| 57 |
}\ |
| 58 |
} while (0) |
| 59 |
|
| 60 |
#define W_ERROR_IS_OK_RETURN(x) do { \ |
| 61 |
if (W_ERROR_IS_OK(x)) {\ |
| 62 |
return x;\ |
| 63 |
}\ |
| 64 |
} while (0) |
| 65 |
|
| 66 |
#define W_ERROR_NOT_OK_RETURN(x) do { \ |
| 67 |
if (!W_ERROR_IS_OK(x)) {\ |
| 68 |
return x;\ |
| 69 |
}\ |
| 70 |
} while (0) |
| 71 |
|
| 72 |
#define W_ERROR_NOT_OK_GOTO_DONE(x) do { \ |
| 73 |
if (!W_ERROR_IS_OK(x)) {\ |
| 74 |
goto done;\ |
| 75 |
}\ |
| 76 |
} while (0) |
| 77 |
|
| 78 |
#define W_ERROR_NOT_OK_GOTO(x, y) do {\ |
| 79 |
if (!W_ERROR_IS_OK(x)) {\ |
| 80 |
goto y;\ |
| 81 |
}\ |
| 82 |
} while(0) |
| 83 |
|
| 84 |
/* these are win32 error codes. There are only a few places where |
| 85 |
these matter for Samba, primarily in the NT printing code */ |
| 86 |
#define WERR_OK W_ERROR(0x00000000) |
| 87 |
#define WERR_STATUS_MORE_ENTRIES W_ERROR(0x00000105) |
| 88 |
|
| 89 |
#define WERR_MULTIPLE_FAULT_VIOLATION W_ERROR(0x00000280) |
| 90 |
#define WERR_SERVICE_NOTIFICATION W_ERROR(0x000002CC) |
| 91 |
#define WERR_LOG_HARD_ERROR W_ERROR(0x000002CE) |
| 92 |
#define WERR_WAIT_1 W_ERROR(0x000002DB) |
| 93 |
#define WERR_WAIT_2 W_ERROR(0x000002DC) |
| 94 |
#define WERR_WAIT_3 W_ERROR(0x000002DD) |
| 95 |
#define WERR_WAIT_63 W_ERROR(0x000002DE) |
| 96 |
#define WERR_ABANDONED_WAIT_63 W_ERROR(0x000002E0) |
| 97 |
#define WERR_USER_APC W_ERROR(0x000002E1) |
| 98 |
#define WERR_KERNEL_APC W_ERROR(0x000002E2) |
| 99 |
#define WERR_ALERTED W_ERROR(0x000002E3) |
| 100 |
#define WERR_INVALID_PRIMARY_GROUP W_ERROR(0x0000051C) |
| 101 |
|
| 102 |
#define WERR_DS_DRA_SECRETS_DENIED W_ERROR(0x000021B6) |
| 103 |
|
| 104 |
#define WERR_DNS_ERROR_KEYMASTER_REQUIRED W_ERROR(0x0000238D) |
| 105 |
#define WERR_DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE W_ERROR(0x0000238E) |
| 106 |
#define WERR_DNS_ERROR_INVALID_NSEC3_PARAMETERS W_ERROR(0x0000238F) |
| 107 |
#define WERR_DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS W_ERROR(0x00002390) |
| 108 |
#define WERR_DNS_ERROR_UNSUPPORTED_ALGORITHM W_ERROR(0x00002391) |
| 109 |
#define WERR_DNS_ERROR_INVALID_KEY_SIZE W_ERROR(0x00002392) |
| 110 |
#define WERR_DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE W_ERROR(0x00002393) |
| 111 |
#define WERR_DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION W_ERROR(0x00002394) |
| 112 |
#define WERR_DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR W_ERROR(0x00002395) |
| 113 |
#define WERR_DNS_ERROR_UNEXPECTED_CNG_ERROR W_ERROR(0x00002396) |
| 114 |
#define WERR_DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION W_ERROR(0x00002397) |
| 115 |
#define WERR_DNS_ERROR_KSP_NOT_ACCESSIBLE W_ERROR(0x00002398) |
| 116 |
#define WERR_DNS_ERROR_TOO_MANY_SKDS W_ERROR(0x00002399) |
| 117 |
#define WERR_DNS_ERROR_INVALID_ROLLOVER_PERIOD W_ERROR(0x0000239A) |
| 118 |
#define WERR_DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET W_ERROR(0x0000239B) |
| 119 |
#define WERR_DNS_ERROR_ROLLOVER_IN_PROGRESS W_ERROR(0x0000239C) |
| 120 |
#define WERR_DNS_ERROR_STANDBY_KEY_NOT_PRESENT W_ERROR(0x0000239D) |
| 121 |
#define WERR_DNS_ERROR_NOT_ALLOWED_ON_ZSK W_ERROR(0x0000239E) |
| 122 |
#define WERR_DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD W_ERROR(0x0000239F) |
| 123 |
#define WERR_DNS_ERROR_ROLLOVER_ALREADY_QUEUED W_ERROR(0x000023A0) |
| 124 |
#define WERR_DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE W_ERROR(0x000023A1) |
| 125 |
#define WERR_DNS_ERROR_BAD_KEYMASTER W_ERROR(0x000023A2) |
| 126 |
#define WERR_DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD W_ERROR(0x000023A3) |
| 127 |
#define WERR_DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT W_ERROR(0x000023A4) |
| 128 |
#define WERR_DNS_ERROR_DNSSEC_IS_DISABLED W_ERROR(0x000023A5) |
| 129 |
#define WERR_DNS_ERROR_INVALID_XML W_ERROR(0x000023A6) |
| 130 |
#define WERR_DNS_ERROR_NO_VALID_TRUST_ANCHORS W_ERROR(0x000023A7) |
| 131 |
#define WERR_DNS_ERROR_ROLLOVER_NOT_POKEABLE W_ERROR(0x000023A8) |
| 132 |
#define WERR_DNS_ERROR_NSEC3_NAME_COLLISION W_ERROR(0x000023A9) |
| 133 |
|
| 134 |
#define WERR_DNS_REQUEST_PENDING W_ERROR(0x00002522) |
| 135 |
#define WERR_DNS_ERROR_NOT_ALLOWED_UNDER_DNAME W_ERROR(0x00002562) |
| 136 |
#define WERR_DNS_ERROR_DELEGATION_REQUIRED W_ERROR(0x00002563) |
| 137 |
#define WERR_DNS_ERROR_INVALID_POLICY_TABLE W_ERROR(0x00002564) |
| 138 |
#define WERR_DNS_ERROR_NODE_IS_DNMAE WERR_DNS_ERROR_NODE_IS_DNAME |
| 139 |
#define WERR_DNS_ERROR_NODE_IS_DNAME W_ERROR(0x000025F8) /* Used to be: "WERR_DNS_ERROR_NODE_IS_DNMAE" */ |
| 140 |
#define WERR_DNS_ERROR_DNAME_COLLISION W_ERROR(0x000025F9) |
| 141 |
#define WERR_DNS_ERROR_ALIAS_LOOP W_ERROR(0x000025FA) |
| 142 |
|
| 143 |
/* Configuration Manager Errors */ |
| 144 |
/* Basically Win32 errors meanings are specific to the \ntsvcs pipe */ |
| 145 |
#define WERR_CM_INVALID_POINTER W_ERROR(3) |
| 146 |
#define WERR_CM_BUFFER_SMALL W_ERROR(26) |
| 147 |
#define WERR_CM_NO_MORE_HW_PROFILES W_ERROR(35) |
| 148 |
#define WERR_CM_NO_SUCH_VALUE W_ERROR(37) |
| 149 |
|
| 150 |
/* DFS errors */ |
| 151 |
|
| 152 |
#ifndef NERR_BASE |
| 153 |
#define NERR_BASE (2100) |
| 154 |
#endif |
| 155 |
|
| 156 |
#ifndef MAX_NERR |
| 157 |
#define MAX_NERR (NERR_BASE+899) |
| 158 |
#endif |
| 159 |
|
| 160 |
/* Generic error code aliases */ |
| 161 |
#define WERR_FOOBAR WERR_GEN_FAILURE |
| 162 |
|
| 163 |
/***************************************************************************** |
| 164 |
returns a windows error message. not amazingly helpful, but better than a number. |
| 165 |
*****************************************************************************/ |
| 166 |
const char *win_errstr(WERROR werror); |
| 167 |
|
| 168 |
const char *get_friendly_werror_msg(WERROR werror); |
| 169 |
|
| 170 |
|
| 171 |
#endif |