Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: srtp/crypto/include/err.h

Issue 2344973002: Update libsrtp to version 2.0 (Closed)
Patch Set: Add '.' back to include_dirs Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « srtp/crypto/include/datatypes.h ('k') | srtp/crypto/include/gf2_8.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * err.h
3 *
4 * error status codes
5 *
6 * David A. McGrew
7 * Cisco Systems, Inc.
8 */
9 /*
10 *
11 * Copyright (c) 2001-2006, Cisco Systems, Inc.
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials provided
24 * with the distribution.
25 *
26 * Neither the name of the Cisco Systems, Inc. nor the names of its
27 * contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
35 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
41 * OF THE POSSIBILITY OF SUCH DAMAGE.
42 *
43 */
44
45
46 #ifndef ERR_H
47 #define ERR_H
48
49 #include <stdio.h>
50 #include <stdarg.h>
51
52 /*
53 * Compatibility shim for v1->v2 transition.
54 */
55
56 #define srtp_err_status_t err_status_t
57
58 #define srtp_err_status_ok err_status_ok
59 #define srtp_err_status_fail err_status_fail
60 #define srtp_err_status_bad_param err_status_bad_param
61 #define srtp_err_status_alloc_fail err_status_alloc_fail
62 #define srtp_err_status_dealloc_fail err_status_dealloc_fail
63 #define srtp_err_status_init_fail err_status_init_fail
64 #define srtp_err_status_terminus err_status_terminus
65 #define srtp_err_status_auth_fail err_status_auth_fail
66 #define srtp_err_status_cipher_fail err_status_cipher_fail
67 #define srtp_err_status_replay_fail err_status_replay_fail
68 #define srtp_err_status_replay_old err_status_replay_old
69 #define srtp_err_status_algo_fail err_status_algo_fail
70 #define srtp_err_status_no_such_op err_status_no_such_op
71 #define srtp_err_status_no_ctx err_status_no_ctx
72 #define srtp_err_status_cant_check err_status_cant_check
73 #define srtp_err_status_key_expired err_status_key_expired
74 #define srtp_err_status_socket_err err_status_socket_err
75 #define srtp_err_status_signal_err err_status_signal_err
76 #define srtp_err_status_nonce_bad err_status_nonce_bad
77 #define srtp_err_status_read_fail err_status_read_fail
78 #define srtp_err_status_write_fail err_status_write_fail
79 #define srtp_err_status_parse_err err_status_parse_err
80 #define srtp_err_status_encode_err err_status_encode_err
81 #define srtp_err_status_semaphore_err err_status_semaphore_err
82 #define srtp_err_status_pfkey_err err_status_pfkey_err
83
84 #define srtp_debug_module_t debug_module_t
85
86 /**
87 * @defgroup Error Error Codes
88 *
89 * Error status codes are represented by the enumeration err_status_t.
90 *
91 * @{
92 */
93
94
95 /*
96 * @brief err_status_t defines error codes.
97 *
98 * The enumeration err_status_t defines error codes. Note that the
99 * value of err_status_ok is equal to zero, which can simplify error
100 * checking somewhat.
101 *
102 */
103 typedef enum {
104 err_status_ok = 0, /**< nothing to report */
105 err_status_fail = 1, /**< unspecified failure */
106 err_status_bad_param = 2, /**< unsupported parameter */
107 err_status_alloc_fail = 3, /**< couldn't allocate memory */
108 err_status_dealloc_fail = 4, /**< couldn't deallocate properly */
109 err_status_init_fail = 5, /**< couldn't initialize */
110 err_status_terminus = 6, /**< can't process as much data as requested */
111 err_status_auth_fail = 7, /**< authentication failure */
112 err_status_cipher_fail = 8, /**< cipher failure */
113 err_status_replay_fail = 9, /**< replay check failed (bad index) */
114 err_status_replay_old = 10, /**< replay check failed (index too old) */
115 err_status_algo_fail = 11, /**< algorithm failed test routine */
116 err_status_no_such_op = 12, /**< unsupported operation */
117 err_status_no_ctx = 13, /**< no appropriate context found */
118 err_status_cant_check = 14, /**< unable to perform desired validation */
119 err_status_key_expired = 15, /**< can't use key any more */
120 err_status_socket_err = 16, /**< error in use of socket */
121 err_status_signal_err = 17, /**< error in use POSIX signals */
122 err_status_nonce_bad = 18, /**< nonce check failed */
123 err_status_read_fail = 19, /**< couldn't read data */
124 err_status_write_fail = 20, /**< couldn't write data */
125 err_status_parse_err = 21, /**< error parsing data */
126 err_status_encode_err = 22, /**< error encoding data */
127 err_status_semaphore_err = 23,/**< error while using semaphores */
128 err_status_pfkey_err = 24 /**< error while using pfkey */
129 } err_status_t;
130
131 /**
132 * @}
133 */
134
135 typedef enum {
136 err_level_emergency = 0,
137 err_level_alert,
138 err_level_critical,
139 err_level_error,
140 err_level_warning,
141 err_level_notice,
142 err_level_info,
143 err_level_debug,
144 err_level_none
145 } err_reporting_level_t;
146
147 /*
148 * err_reporting_init prepares the error system. If
149 * ERR_REPORTING_SYSLOG is defined, it will open syslog.
150 *
151 * The ident argument is a string that will be prepended to
152 * all syslog messages. It is conventionally argv[0].
153 */
154
155 err_status_t
156 err_reporting_init(const char *ident);
157
158 #ifdef SRTP_KERNEL_LINUX
159 extern err_reporting_level_t err_level;
160 #else
161
162 /*
163 * keydaemon_report_error reports a 'printf' formatted error
164 * string, followed by a an arg list. The priority argument
165 * is equivalent to that defined for syslog.
166 *
167 * Errors will be reported to ERR_REPORTING_FILE, if defined, and to
168 * syslog, if ERR_REPORTING_SYSLOG is defined.
169 *
170 */
171
172 void
173 err_report(int priority, const char *format, ...);
174 #endif /* ! SRTP_KERNEL_LINUX */
175
176
177 /*
178 * debug_module_t defines a debug module
179 */
180
181 typedef struct {
182 int on; /* 1 if debugging is on, 0 if it is off */
183 const char *name; /* printable name for debug module */
184 } debug_module_t;
185
186 #ifdef ENABLE_DEBUGGING
187
188 #define debug_on(mod) (mod).on = 1
189
190 #define debug_off(mod) (mod).on = 0
191
192 /* use err_report() to report debug message */
193 #define debug_print(mod, format, arg) \
194 if (mod.on) err_report(err_level_debug, ("%s: " format "\n"), mod.name, arg)
195 #define debug_print2(mod, format, arg1,arg2) \
196 if (mod.on) err_report(err_level_debug, ("%s: " format "\n"), mod.name, arg1,a rg2)
197
198 #else
199
200 /* define macros to do nothing */
201 #define debug_print(mod, format, arg)
202
203 #define debug_on(mod)
204
205 #define debug_off(mod)
206
207 #endif
208
209 #endif /* ERR_H */
OLDNEW
« no previous file with comments | « srtp/crypto/include/datatypes.h ('k') | srtp/crypto/include/gf2_8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698