~ubuntu-branches/ubuntu/hardy/wpasupplicant/hardy

« back to all changes in this revision

Viewing changes to src/utils/wpa_debug.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler, Alexander Sack
  • Date: 2007-08-26 16:06:57 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070826160657-2m8pxoweuxe8f93t
Tags: 0.6.0+0.5.8-0ubuntu1
* New upstream release
* remove patch 11_erroneous_manpage_ref, applied upstream
* remove patch 25_wpas_dbus_unregister_iface_fix, applied upstream

[ Alexander Sack ]
* bumping upstream version to replace development version 0.6.0 with
  this package from stable release branch.
* attempt to fix wierd timeout and high latency issues by going
  back to stable upstream version (0.5.9) (LP: #140763,
  LP: #141233).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * wpa_supplicant/hostapd / Debug prints
3
 
 * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License version 2 as
7
 
 * published by the Free Software Foundation.
8
 
 *
9
 
 * Alternatively, this software may be distributed under the terms of BSD
10
 
 * license.
11
 
 *
12
 
 * See README and COPYING for more details.
13
 
 */
14
 
 
15
 
#ifndef WPA_DEBUG_H
16
 
#define WPA_DEBUG_H
17
 
 
18
 
/* Debugging function - conditional printf and hex dump. Driver wrappers can
19
 
 * use these for debugging purposes. */
20
 
 
21
 
enum { MSG_MSGDUMP, MSG_DEBUG, MSG_INFO, MSG_WARNING, MSG_ERROR };
22
 
 
23
 
#ifdef CONFIG_NO_STDOUT_DEBUG
24
 
 
25
 
#define wpa_debug_print_timestamp() do { } while (0)
26
 
#define wpa_printf(args...) do { } while (0)
27
 
#define wpa_hexdump(l,t,b,le) do { } while (0)
28
 
#define wpa_hexdump_key(l,t,b,le) do { } while (0)
29
 
#define wpa_hexdump_ascii(l,t,b,le) do { } while (0)
30
 
#define wpa_hexdump_ascii_key(l,t,b,le) do { } while (0)
31
 
#define wpa_debug_open_file() do { } while (0)
32
 
#define wpa_debug_close_file() do { } while (0)
33
 
 
34
 
#else /* CONFIG_NO_STDOUT_DEBUG */
35
 
 
36
 
int wpa_debug_open_file(void);
37
 
void wpa_debug_close_file(void);
38
 
 
39
 
/**
40
 
 * wpa_debug_printf_timestamp - Print timestamp for debug output
41
 
 *
42
 
 * This function prints a timestamp in <seconds from 1970>.<microsoconds>
43
 
 * format if debug output has been configured to include timestamps in debug
44
 
 * messages.
45
 
 */
46
 
void wpa_debug_print_timestamp(void);
47
 
 
48
 
/**
49
 
 * wpa_printf - conditional printf
50
 
 * @level: priority level (MSG_*) of the message
51
 
 * @fmt: printf format string, followed by optional arguments
52
 
 *
53
 
 * This function is used to print conditional debugging and error messages. The
54
 
 * output may be directed to stdout, stderr, and/or syslog based on
55
 
 * configuration.
56
 
 *
57
 
 * Note: New line '\n' is added to the end of the text when printing to stdout.
58
 
 */
59
 
void wpa_printf(int level, char *fmt, ...)
60
 
PRINTF_FORMAT(2, 3);
61
 
 
62
 
/**
63
 
 * wpa_hexdump - conditional hex dump
64
 
 * @level: priority level (MSG_*) of the message
65
 
 * @title: title of for the message
66
 
 * @buf: data buffer to be dumped
67
 
 * @len: length of the buf
68
 
 *
69
 
 * This function is used to print conditional debugging and error messages. The
70
 
 * output may be directed to stdout, stderr, and/or syslog based on
71
 
 * configuration. The contents of buf is printed out has hex dump.
72
 
 */
73
 
void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len);
74
 
 
75
 
/**
76
 
 * wpa_hexdump_key - conditional hex dump, hide keys
77
 
 * @level: priority level (MSG_*) of the message
78
 
 * @title: title of for the message
79
 
 * @buf: data buffer to be dumped
80
 
 * @len: length of the buf
81
 
 *
82
 
 * This function is used to print conditional debugging and error messages. The
83
 
 * output may be directed to stdout, stderr, and/or syslog based on
84
 
 * configuration. The contents of buf is printed out has hex dump. This works
85
 
 * like wpa_hexdump(), but by default, does not include secret keys (passwords,
86
 
 * etc.) in debug output.
87
 
 */
88
 
void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len);
89
 
 
90
 
/**
91
 
 * wpa_hexdump_ascii - conditional hex dump
92
 
 * @level: priority level (MSG_*) of the message
93
 
 * @title: title of for the message
94
 
 * @buf: data buffer to be dumped
95
 
 * @len: length of the buf
96
 
 *
97
 
 * This function is used to print conditional debugging and error messages. The
98
 
 * output may be directed to stdout, stderr, and/or syslog based on
99
 
 * configuration. The contents of buf is printed out has hex dump with both
100
 
 * the hex numbers and ASCII characters (for printable range) are shown. 16
101
 
 * bytes per line will be shown.
102
 
 */
103
 
void wpa_hexdump_ascii(int level, const char *title, const u8 *buf,
104
 
                       size_t len);
105
 
 
106
 
/**
107
 
 * wpa_hexdump_ascii_key - conditional hex dump, hide keys
108
 
 * @level: priority level (MSG_*) of the message
109
 
 * @title: title of for the message
110
 
 * @buf: data buffer to be dumped
111
 
 * @len: length of the buf
112
 
 *
113
 
 * This function is used to print conditional debugging and error messages. The
114
 
 * output may be directed to stdout, stderr, and/or syslog based on
115
 
 * configuration. The contents of buf is printed out has hex dump with both
116
 
 * the hex numbers and ASCII characters (for printable range) are shown. 16
117
 
 * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
118
 
 * default, does not include secret keys (passwords, etc.) in debug output.
119
 
 */
120
 
void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
121
 
                           size_t len);
122
 
 
123
 
#endif /* CONFIG_NO_STDOUT_DEBUG */
124
 
 
125
 
 
126
 
#ifdef CONFIG_NO_WPA_MSG
127
 
#define wpa_msg(args...) do { } while (0)
128
 
#define wpa_msg_register_cb(f) do { } while (0)
129
 
#else /* CONFIG_NO_WPA_MSG */
130
 
/**
131
 
 * wpa_msg - Conditional printf for default target and ctrl_iface monitors
132
 
 * @ctx: Pointer to context data; this is the ctx variable registered
133
 
 *      with struct wpa_driver_ops::init()
134
 
 * @level: priority level (MSG_*) of the message
135
 
 * @fmt: printf format string, followed by optional arguments
136
 
 *
137
 
 * This function is used to print conditional debugging and error messages. The
138
 
 * output may be directed to stdout, stderr, and/or syslog based on
139
 
 * configuration. This function is like wpa_printf(), but it also sends the
140
 
 * same message to all attached ctrl_iface monitors.
141
 
 *
142
 
 * Note: New line '\n' is added to the end of the text when printing to stdout.
143
 
 */
144
 
void wpa_msg(void *ctx, int level, char *fmt, ...) PRINTF_FORMAT(3, 4);
145
 
 
146
 
typedef void (*wpa_msg_cb_func)(void *ctx, int level, const char *txt,
147
 
                                size_t len);
148
 
 
149
 
/**
150
 
 * wpa_msg_register_cb - Register callback function for wpa_msg() messages
151
 
 * @func: Callback function (%NULL to unregister)
152
 
 */
153
 
void wpa_msg_register_cb(wpa_msg_cb_func func);
154
 
#endif /* CONFIG_NO_WPA_MSG */
155
 
 
156
 
 
157
 
#ifdef CONFIG_NO_HOSTAPD_LOGGER
158
 
#define hostapd_logger(args...) do { } while (0)
159
 
#define hostapd_logger_register_cb(f) do { } while (0)
160
 
#else /* CONFIG_NO_HOSTAPD_LOGGER */
161
 
void hostapd_logger(void *ctx, const u8 *addr, unsigned int module, int level,
162
 
                    const char *fmt, ...) PRINTF_FORMAT(5, 6);
163
 
 
164
 
typedef void (*hostapd_logger_cb_func)(void *ctx, const u8 *addr,
165
 
                                       unsigned int module, int level,
166
 
                                       const char *txt, size_t len);
167
 
 
168
 
/**
169
 
 * hostapd_logger_register_cb - Register callback function for hostapd_logger()
170
 
 * @func: Callback function (%NULL to unregister)
171
 
 */
172
 
void hostapd_logger_register_cb(hostapd_logger_cb_func func);
173
 
#endif /* CONFIG_NO_HOSTAPD_LOGGER */
174
 
 
175
 
#define HOSTAPD_MODULE_IEEE80211        0x00000001
176
 
#define HOSTAPD_MODULE_IEEE8021X        0x00000002
177
 
#define HOSTAPD_MODULE_RADIUS           0x00000004
178
 
#define HOSTAPD_MODULE_WPA              0x00000008
179
 
#define HOSTAPD_MODULE_DRIVER           0x00000010
180
 
#define HOSTAPD_MODULE_IAPP             0x00000020
181
 
#define HOSTAPD_MODULE_MLME             0x00000040
182
 
 
183
 
enum hostapd_logger_level {
184
 
        HOSTAPD_LEVEL_DEBUG_VERBOSE = 0,
185
 
        HOSTAPD_LEVEL_DEBUG = 1,
186
 
        HOSTAPD_LEVEL_INFO = 2,
187
 
        HOSTAPD_LEVEL_NOTICE = 3,
188
 
        HOSTAPD_LEVEL_WARNING = 4
189
 
};
190
 
 
191
 
 
192
 
 
193
 
#ifdef EAPOL_TEST
194
 
#define WPA_ASSERT(a)                                                  \
195
 
        do {                                                           \
196
 
                if (!(a)) {                                            \
197
 
                        printf("WPA_ASSERT FAILED '" #a "' "           \
198
 
                               "%s %s:%d\n",                           \
199
 
                               __FUNCTION__, __FILE__, __LINE__);      \
200
 
                        exit(1);                                       \
201
 
                }                                                      \
202
 
        } while (0)
203
 
#else
204
 
#define WPA_ASSERT(a) do { } while (0)
205
 
#endif
206
 
 
207
 
#endif /* WPA_DEBUG_H */