1 | /*
|
---|
2 | * TAP-Win32 -- A kernel driver to provide virtual tap device functionality
|
---|
3 | * on Windows. Originally derived from the CIPE-Win32
|
---|
4 | * project by Damion K. Wilson, with extensive modifications by
|
---|
5 | * James Yonan.
|
---|
6 | *
|
---|
7 | * All source code which derives from the CIPE-Win32 project is
|
---|
8 | * Copyright (C) Damion K. Wilson, 2003, and is released under the
|
---|
9 | * GPL version 2 (see below).
|
---|
10 | *
|
---|
11 | * All other source code is Copyright (C) 2002-2005 OpenVPN Solutions LLC,
|
---|
12 | * and is released under the GPL version 2 (see below).
|
---|
13 | *
|
---|
14 | * This program is free software; you can redistribute it and/or modify
|
---|
15 | * it under the terms of the GNU General Public License version 2
|
---|
16 | * as published by the Free Software Foundation.
|
---|
17 | *
|
---|
18 | * This program is distributed in the hope that it will be useful,
|
---|
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
21 | * GNU General Public License for more details.
|
---|
22 | *
|
---|
23 | * You should have received a copy of the GNU General Public License
|
---|
24 | * along with this program (see the file COPYING included with this
|
---|
25 | * distribution); if not, write to the Free Software Foundation, Inc.,
|
---|
26 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
27 | */
|
---|
28 |
|
---|
29 | //-----------------
|
---|
30 | // DEBUGGING OUTPUT
|
---|
31 | //-----------------
|
---|
32 |
|
---|
33 | #define NOTE_ERROR() \
|
---|
34 | { \
|
---|
35 | g_LastErrorFilename = __FILE__; \
|
---|
36 | g_LastErrorLineNumber = __LINE__; \
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | #ifdef DEBUG
|
---|
41 | #define DEBUGP(fmt) { DbgPrint fmt; }
|
---|
42 | #else
|
---|
43 | #define DEBUGP(fmt)
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | #if DBG
|
---|
47 |
|
---|
48 | typedef struct {
|
---|
49 | unsigned int in;
|
---|
50 | unsigned int out;
|
---|
51 | unsigned int capacity;
|
---|
52 | char *text;
|
---|
53 | BOOLEAN error;
|
---|
54 | MUTEX lock;
|
---|
55 | } DebugOutput;
|
---|
56 |
|
---|
57 | VOID MyDebugPrint (const unsigned char* format, ...);
|
---|
58 |
|
---|
59 | VOID MyAssert (const unsigned char *file, int line);
|
---|
60 |
|
---|
61 | VOID DumpPacket (const char *prefix,
|
---|
62 | const unsigned char *data,
|
---|
63 | unsigned int len);
|
---|
64 |
|
---|
65 | VOID DumpPacket2 (const char *prefix,
|
---|
66 | const ETH_HEADER *eth,
|
---|
67 | const unsigned char *data,
|
---|
68 | unsigned int len);
|
---|
69 |
|
---|
70 | #define CAN_WE_PRINT (DEBUGP_AT_DISPATCH || KeGetCurrentIrql () < DISPATCH_LEVEL)
|
---|
71 |
|
---|
72 | #if ALSO_DBGPRINT
|
---|
73 | #define DEBUGP(fmt) { DbgPrint fmt; if (CAN_WE_PRINT) DbgPrint fmt; }
|
---|
74 | #else
|
---|
75 | #define DEBUGP(fmt) { DbgPrint fmt; }
|
---|
76 | #endif
|
---|
77 |
|
---|
78 | #define MYASSERT(exp) \
|
---|
79 | { \
|
---|
80 | if (!(exp)) \
|
---|
81 | { \
|
---|
82 | MyAssert(__FILE__, __LINE__); \
|
---|
83 | } \
|
---|
84 | }
|
---|
85 |
|
---|
86 | #if DBG
|
---|
87 | #define DUMP_PACKET(prefix, data, len) \
|
---|
88 | DumpPacket (prefix, data, len)
|
---|
89 |
|
---|
90 | #define DUMP_PACKET2(prefix, eth, data, len) \
|
---|
91 | DumpPacket2 (prefix, eth, data, len)
|
---|
92 | #else
|
---|
93 | #define DUMP_PACKET(prefix, data, len)
|
---|
94 | #define DUMP_PACKET2(prefix, eth, data, len)
|
---|
95 | #endif
|
---|
96 |
|
---|
97 | #else
|
---|
98 |
|
---|
99 | #define MYASSERT(exp)
|
---|
100 | #define DUMP_PACKET(prefix, data, len)
|
---|
101 | #define DUMP_PACKET2(prefix, eth, data, len)
|
---|
102 |
|
---|
103 | #endif
|
---|