add netsimpcap, a network simulation device
[olsrd.git] / contrib / netsimpcap / src / debug.h
1 /*
2  * NetsimPcap - a userspace network bridge with simulated packet loss
3  *             Copyright 2008 H. Rogge (rogge@fgan.de)
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 as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef WLAN_DEBUG_H
20 #define WLAN_DEBUG_H
21
22 #define DPRINT(...)             if(debugMode) { printf(__VA_ARGS__); }
23
24 #define DHEXDUMP(purpose, data,length)  if (debugMode) {        \
25                 int i;                                                                          \
26                 printf("Hexdump: %s\n", purpose);                                               \
27                 for (i=0; i<length; i++) {                                      \
28                         if ((i & 31) == 0)      printf("%04x: ", i);\
29                         printf("%02x", ((int)data[i])  & 255);  \
30                         if ((i & 3) == 3) printf(" ");                  \
31                         if ((i & 31) == 31) printf("\n");               \
32                 }                                                                                       \
33                 printf("\n\n");                                                         \
34         }
35
36 extern int debugMode;
37
38 #endif