2 * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Alistair Crooks (agc@NetBSD.org)
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
30 * Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
31 * All rights reserved.
32 * Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
33 * their moral rights under the UK Copyright Design and Patents Act 1988 to
34 * be recorded as the authors of this copyright work.
36 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
37 * use this file except in compliance with the License.
39 * You may obtain a copy of the License at
40 * http://www.apache.org/licenses/LICENSE-2.0
42 * Unless required by applicable law or agreed to in writing, software
43 * distributed under the License is distributed on an "AS IS" BASIS,
44 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 * See the License for the specific language governing permissions and
47 * limitations under the License.
59 /* Remember to add names to map in errors.c */
61 OPS_E_OK
= 0x0000, /* no error */
62 OPS_E_FAIL
= 0x0001, /* general error */
63 OPS_E_SYSTEM_ERROR
= 0x0002, /* system error, look at errno for
65 OPS_E_UNIMPLEMENTED
= 0x0003, /* feature not yet implemented */
68 OPS_E_R
= 0x1000, /* general reader error */
69 OPS_E_R_READ_FAILED
= OPS_E_R
+ 1,
70 OPS_E_R_EARLY_EOF
= OPS_E_R
+ 2,
71 OPS_E_R_BAD_FORMAT
= OPS_E_R
+ 3, /* For example, malformed
73 OPS_E_R_UNSUPPORTED
= OPS_E_R
+ 4,
74 OPS_E_R_UNCONSUMED_DATA
= OPS_E_R
+ 5,
77 OPS_E_W
= 0x2000, /* general writer error */
78 OPS_E_W_WRITE_FAILED
= OPS_E_W
+ 1,
79 OPS_E_W_WRITE_TOO_SHORT
= OPS_E_W
+ 2,
82 OPS_E_P
= 0x3000, /* general parser error */
83 OPS_E_P_NOT_ENOUGH_DATA
= OPS_E_P
+ 1,
84 OPS_E_P_UNKNOWN_TAG
= OPS_E_P
+ 2,
85 OPS_E_P_PACKET_CONSUMED
= OPS_E_P
+ 3,
86 OPS_E_P_MPI_FORMAT_ERROR
= OPS_E_P
+ 4,
87 OPS_E_P_PACKET_NOT_CONSUMED
= OPS_E_P
+ 5,
88 OPS_E_P_DECOMPRESSION_ERROR
= OPS_E_P
+ 6,
89 OPS_E_P_NO_USERID
= OPS_E_P
+ 7,
92 OPS_E_C
= 0x4000, /* general creator error */
94 /* validation errors */
95 OPS_E_V
= 0x5000, /* general validation error */
96 OPS_E_V_BAD_SIGNATURE
= OPS_E_V
+ 1,
97 OPS_E_V_NO_SIGNATURE
= OPS_E_V
+ 2,
98 OPS_E_V_UNKNOWN_SIGNER
= OPS_E_V
+ 3,
99 OPS_E_V_BAD_HASH
= OPS_E_V
+ 4,
101 /* Algorithm support errors */
102 OPS_E_ALG
= 0x6000, /* general algorithm error */
103 OPS_E_ALG_UNSUPPORTED_SYMMETRIC_ALG
= OPS_E_ALG
+ 1,
104 OPS_E_ALG_UNSUPPORTED_PUBLIC_KEY_ALG
= OPS_E_ALG
+ 2,
105 OPS_E_ALG_UNSUPPORTED_SIGNATURE_ALG
= OPS_E_ALG
+ 3,
106 OPS_E_ALG_UNSUPPORTED_HASH_ALG
= OPS_E_ALG
+ 4,
107 OPS_E_ALG_UNSUPPORTED_COMPRESS_ALG
= OPS_E_ALG
+ 5,
109 /* Protocol errors */
110 OPS_E_PROTO
= 0x7000, /* general protocol error */
111 OPS_E_PROTO_BAD_SYMMETRIC_DECRYPT
= OPS_E_PROTO
+ 2,
112 OPS_E_PROTO_UNKNOWN_SS
= OPS_E_PROTO
+ 3,
113 OPS_E_PROTO_CRITICAL_SS_IGNORED
= OPS_E_PROTO
+ 4,
114 OPS_E_PROTO_BAD_PUBLIC_KEY_VRSN
= OPS_E_PROTO
+ 5,
115 OPS_E_PROTO_BAD_SIGNATURE_VRSN
= OPS_E_PROTO
+ 6,
116 OPS_E_PROTO_BAD_ONE_PASS_SIG_VRSN
= OPS_E_PROTO
+ 7,
117 OPS_E_PROTO_BAD_PKSK_VRSN
= OPS_E_PROTO
+ 8,
118 OPS_E_PROTO_DECRYPTED_MSG_WRONG_LEN
= OPS_E_PROTO
+ 9,
119 OPS_E_PROTO_BAD_SK_CHECKSUM
= OPS_E_PROTO
+ 10
122 /** one entry in a linked list of errors */
123 typedef struct __ops_error
{
124 __ops_errcode_t errcode
;
125 int sys_errno
; /* irrelevent unless errcode ==
126 * OPS_E_SYSTEM_ERROR */
130 struct __ops_error
*next
;
133 const char *__ops_errcode(const __ops_errcode_t
);
136 __ops_push_error(__ops_error_t
**, __ops_errcode_t
,
138 const char *, int, const char *,...);
139 void __ops_print_error(__ops_error_t
*);
140 void __ops_print_errors(__ops_error_t
*);
141 void __ops_free_errors(__ops_error_t
*);
142 int __ops_has_error(__ops_error_t
*, __ops_errcode_t
);
144 #define OPS_SYSTEM_ERROR_1(err,code,sys,fmt,arg) do { \
145 __ops_push_error(err,OPS_E_SYSTEM_ERROR,errno,__FILE__,__LINE__,sys);\
146 __ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg); \
147 } while(/*CONSTCOND*/0)
149 #define OPS_MEMORY_ERROR(err) { \
150 fprintf(stderr, "Memory error\n"); \
151 } /* \todo placeholder for better error
153 #define OPS_ERROR(err,code,fmt) do { \
154 __ops_push_error(err,code,0,__FILE__,__LINE__,fmt); \
155 } while(/*CONSTCOND*/0)
156 #define OPS_ERROR_1(err,code,fmt,arg) do { \
157 __ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg); \
158 } while(/*CONSTCOND*/0)
159 #define OPS_ERROR_2(err,code,fmt,arg,arg2) do { \
160 __ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2); \
161 } while(/*CONSTCOND*/0)
162 #define OPS_ERROR_3(err,code,fmt,arg,arg2,arg3) do { \
163 __ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2,arg3); \
164 } while(/*CONSTCOND*/0)
165 #define OPS_ERROR_4(err,code,fmt,arg,arg2,arg3,arg4) do { \
166 __ops_push_error(err,code,0,__FILE__,__LINE__,fmt,arg,arg2,arg3,arg4); \
167 } while(/*CONSTCOND*/0)
169 #endif /* ERRORS_H_ */