OLD | NEW |
1 /* | 1 /* |
2 * err.h | 2 * err.h |
3 * | 3 * |
4 * error status codes | 4 * error status codes |
5 * | 5 * |
6 * David A. McGrew | 6 * David A. McGrew |
7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
8 */ | 8 */ |
9 /* | 9 /* |
10 * | 10 * |
(...skipping 28 matching lines...) Expand all Loading... |
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
41 * OF THE POSSIBILITY OF SUCH DAMAGE. | 41 * OF THE POSSIBILITY OF SUCH DAMAGE. |
42 * | 42 * |
43 */ | 43 */ |
44 | 44 |
45 | 45 |
46 #ifndef ERR_H | 46 #ifndef ERR_H |
47 #define ERR_H | 47 #define ERR_H |
48 | 48 |
49 #include "datatypes.h" | 49 #include <stdio.h> |
| 50 #include <stdarg.h> |
50 | 51 |
51 /** | 52 /** |
52 * @defgroup Error Error Codes | 53 * @defgroup Error Error Codes |
53 * | 54 * |
54 * Error status codes are represented by the enumeration err_status_t. | 55 * Error status codes are represented by the enumeration err_status_t. |
55 * | 56 * |
56 * @{ | 57 * @{ |
57 */ | 58 */ |
58 | 59 |
59 | 60 |
(...skipping 20 matching lines...) Expand all Loading... |
80 err_status_algo_fail = 11, /**< algorithm failed test routine */ | 81 err_status_algo_fail = 11, /**< algorithm failed test routine */ |
81 err_status_no_such_op = 12, /**< unsupported operation */ | 82 err_status_no_such_op = 12, /**< unsupported operation */ |
82 err_status_no_ctx = 13, /**< no appropriate context found */ | 83 err_status_no_ctx = 13, /**< no appropriate context found */ |
83 err_status_cant_check = 14, /**< unable to perform desired validation */ | 84 err_status_cant_check = 14, /**< unable to perform desired validation */ |
84 err_status_key_expired = 15, /**< can't use key any more */ | 85 err_status_key_expired = 15, /**< can't use key any more */ |
85 err_status_socket_err = 16, /**< error in use of socket */ | 86 err_status_socket_err = 16, /**< error in use of socket */ |
86 err_status_signal_err = 17, /**< error in use POSIX signals */ | 87 err_status_signal_err = 17, /**< error in use POSIX signals */ |
87 err_status_nonce_bad = 18, /**< nonce check failed */ | 88 err_status_nonce_bad = 18, /**< nonce check failed */ |
88 err_status_read_fail = 19, /**< couldn't read data */ | 89 err_status_read_fail = 19, /**< couldn't read data */ |
89 err_status_write_fail = 20, /**< couldn't write data */ | 90 err_status_write_fail = 20, /**< couldn't write data */ |
90 err_status_parse_err = 21, /**< error pasring data */ | 91 err_status_parse_err = 21, /**< error parsing data */ |
91 err_status_encode_err = 22, /**< error encoding data */ | 92 err_status_encode_err = 22, /**< error encoding data */ |
92 err_status_semaphore_err = 23,/**< error while using semaphores */ | 93 err_status_semaphore_err = 23,/**< error while using semaphores */ |
93 err_status_pfkey_err = 24 /**< error while using pfkey */ | 94 err_status_pfkey_err = 24 /**< error while using pfkey */ |
94 } err_status_t; | 95 } err_status_t; |
95 | 96 |
96 /** | 97 /** |
97 * @} | 98 * @} |
98 */ | 99 */ |
99 | 100 |
100 typedef enum { | 101 typedef enum { |
(...skipping 10 matching lines...) Expand all Loading... |
111 | 112 |
112 /* | 113 /* |
113 * err_reporting_init prepares the error system. If | 114 * err_reporting_init prepares the error system. If |
114 * ERR_REPORTING_SYSLOG is defined, it will open syslog. | 115 * ERR_REPORTING_SYSLOG is defined, it will open syslog. |
115 * | 116 * |
116 * The ident argument is a string that will be prepended to | 117 * The ident argument is a string that will be prepended to |
117 * all syslog messages. It is conventionally argv[0]. | 118 * all syslog messages. It is conventionally argv[0]. |
118 */ | 119 */ |
119 | 120 |
120 err_status_t | 121 err_status_t |
121 err_reporting_init(char *ident); | 122 err_reporting_init(const char *ident); |
122 | 123 |
123 #ifdef SRTP_KERNEL_LINUX | 124 #ifdef SRTP_KERNEL_LINUX |
124 extern err_reporting_level_t err_level; | 125 extern err_reporting_level_t err_level; |
125 #else | 126 #else |
126 | 127 |
127 /* | 128 /* |
128 * keydaemon_report_error reports a 'printf' formatted error | 129 * keydaemon_report_error reports a 'printf' formatted error |
129 * string, followed by a an arg list. The priority argument | 130 * string, followed by a an arg list. The priority argument |
130 * is equivalent to that defined for syslog. | 131 * is equivalent to that defined for syslog. |
131 * | 132 * |
132 * Errors will be reported to ERR_REPORTING_FILE, if defined, and to | 133 * Errors will be reported to ERR_REPORTING_FILE, if defined, and to |
133 * syslog, if ERR_REPORTING_SYSLOG is defined. | 134 * syslog, if ERR_REPORTING_SYSLOG is defined. |
134 * | 135 * |
135 */ | 136 */ |
136 | 137 |
137 void | 138 void |
138 err_report(int priority, char *format, ...); | 139 err_report(int priority, const char *format, ...); |
139 #endif /* ! SRTP_KERNEL_LINUX */ | 140 #endif /* ! SRTP_KERNEL_LINUX */ |
140 | 141 |
141 | 142 |
142 /* | 143 /* |
143 * debug_module_t defines a debug module | 144 * debug_module_t defines a debug module |
144 */ | 145 */ |
145 | 146 |
146 typedef struct { | 147 typedef struct { |
147 int on; /* 1 if debugging is on, 0 if it is off */ | 148 int on; /* 1 if debugging is on, 0 if it is off */ |
148 char *name; /* printable name for debug module */ | 149 const char *name; /* printable name for debug module */ |
149 } debug_module_t; | 150 } debug_module_t; |
150 | 151 |
151 #ifdef ENABLE_DEBUGGING | 152 #ifdef ENABLE_DEBUGGING |
152 | 153 |
153 #define debug_on(mod) (mod).on = 1 | 154 #define debug_on(mod) (mod).on = 1 |
154 | 155 |
155 #define debug_off(mod) (mod).on = 0 | 156 #define debug_off(mod) (mod).on = 0 |
156 | 157 |
157 /* use err_report() to report debug message */ | 158 /* use err_report() to report debug message */ |
158 #define debug_print(mod, format, arg) \ | 159 #define debug_print(mod, format, arg) \ |
159 if (mod.on) err_report(err_level_debug, ("%s: " format "\n"), mod.name, arg) | 160 if (mod.on) err_report(err_level_debug, ("%s: " format "\n"), mod.name, arg) |
160 #define debug_print2(mod, format, arg1,arg2) \ | 161 #define debug_print2(mod, format, arg1,arg2) \ |
161 if (mod.on) err_report(err_level_debug, ("%s: " format "\n"), mod.name, arg1,a
rg2) | 162 if (mod.on) err_report(err_level_debug, ("%s: " format "\n"), mod.name, arg1,a
rg2) |
162 | 163 |
163 #else | 164 #else |
164 | 165 |
165 /* define macros to do nothing */ | 166 /* define macros to do nothing */ |
166 #define debug_print(mod, format, arg) | 167 #define debug_print(mod, format, arg) |
167 | 168 |
168 #define debug_on(mod) | 169 #define debug_on(mod) |
169 | 170 |
170 #define debug_off(mod) | 171 #define debug_off(mod) |
171 | 172 |
172 #endif | 173 #endif |
173 | 174 |
174 #endif /* ERR_H */ | 175 #endif /* ERR_H */ |
OLD | NEW |