1 /* $Id$ */
2 /*
3 ** Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved.
4 ** Copyright (C) 2002-2013 Sourcefire, Inc.
5 ** Copyright (C) 1998-2002 Martin Roesch <roesch@sourcefire.com>
6 **
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License Version 2 as
9 ** published by the Free Software Foundation.  You may not use, modify or
10 ** distribute this program under any other version of the GNU General
11 ** Public License.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; if not, write to the Free Software
20 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 */
22 
23 
24 #ifndef DEBUG_H
25 #define DEBUG_H
26 
27 #include <ctype.h>
28 #ifdef SF_WCHAR
29 /* ISOC99 is defined to get required prototypes */
30 #ifndef __USE_ISOC99
31 #define __USE_ISOC99
32 #endif
33 #include <wchar.h>
34 #endif
35 
36 /* this env var uses the lower 32 bits of the flags: */
37 #define DEBUG_VARIABLE "SNORT_DEBUG"
38 
39 #define DEBUG_INIT            0x0000000000000001LL
40 #define DEBUG_PARSER          0x0000000000000002LL
41 #define DEBUG_MSTRING         0x0000000000000004LL
42 #define DEBUG_PORTLISTS       0x0000000000000008LL
43 #define DEBUG_ATTRIBUTE       0x0000000000000010LL
44 #define DEBUG_PLUGIN          0x0000000000000020LL
45 #define DEBUG_PLUGBASE        0x0000000000000040LL
46 #define DEBUG_DECODE          0x0000000000000080LL
47 #define DEBUG_DATALINK        0x0000000000000100LL
48 #define DEBUG_CONFIGRULES     0x0000000000000200LL
49 #define DEBUG_RULES           0x0000000000000400LL
50 #define DEBUG_DETECT          0x0000000000000800LL
51 #define DEBUG_PATTERN_MATCH   0x0000000000001000LL
52 #define DEBUG_FLOW            0x0000000000002000LL
53 #define DEBUG_LOG             0x0000000000004000LL
54 #define DEBUG_FLOWBITS        0x0000000000008000LL
55 #define DEBUG_FILE            0x0000000000010000LL
56 #define DEBUG_CONTROL         0x0000000000020000LL
57 #define DEBUG_EXP             0x0000000080000000LL
58 
59 /* this env var uses the upper 32 bits of the flags: */
60 #define DEBUG_PP_VAR   "SNORT_PP_DEBUG"
61 
62 #define DEBUG_FRAG            0x0000000100000000LL
63 #define DEBUG_STREAM          0x0000000200000000LL
64 #define DEBUG_STREAM_STATE    0x0000000400000000LL
65 #define DEBUG_STREAM_PAF      0x0000000800000000LL
66 #define DEBUG_HTTP_DECODE     0x0000001000000000LL
67 #define DEBUG_HTTPINSPECT     0x0000002000000000LL
68 #define DEBUG_ASN1            0x0000004000000000LL
69 #define DEBUG_DNS             0x0000008000000000LL
70 #define DEBUG_FTPTELNET       0x0000010000000000LL
71 #define DEBUG_GTP             0x0000020000000000LL
72 #define DEBUG_IMAP            0x0000040000000000LL
73 #define DEBUG_POP             0x0000080000000000LL
74 #define DEBUG_RPC             0x0000100000000000LL
75 #define DEBUG_SIP             0x0000200000000000LL
76 #define DEBUG_SKYPE           0x0000400000000000LL
77 #define DEBUG_SSL             0x0000800000000000LL
78 #define DEBUG_SMTP            0x0001000000000000LL
79 #define DEBUG_APPID           0x0002000000000000LL
80 #define DEBUG_PP_EXP          0x8000000000000000LL
81 
82 void DebugMessageFunc(uint64_t dbg, const char *fmt, ...);
83 #ifdef SF_WCHAR
84 void DebugWideMessageFunc(uint64_t dbg, const wchar_t *fmt, ...);
85 #endif
86 
87 #ifdef DEBUG_MSGS
88 
89     extern char *DebugMessageFile;
90     extern int DebugMessageLine;
91 
92     #define    DebugMessage    DebugMessageFile = __FILE__; DebugMessageLine = __LINE__; DebugMessageFunc
93     #define    DebugWideMessage    DebugMessageFile = __FILE__; DebugMessageLine = __LINE__; DebugWideMessageFunc
94 
95     uint64_t GetDebugLevel (void);
96     int DebugThis(uint64_t level);
97 #else /* DEBUG_MSGS */
98 
99 #ifdef WIN32
100 /* Visual C++ uses the keyword "__inline" rather than "__inline__" */
101          #define __inline__ __inline
102 #endif
103 
104 #endif /* DEBUG_MSGS */
105 
106 
107 #ifdef DEBUG_MSGS
108 #define DEBUG_WRAP(code) code
109 void DebugMessageFunc(uint64_t dbg, const char *fmt, ...);
110 #ifdef SF_WCHAR
111 void DebugWideMessageFunc(uint64_t dbg, const wchar_t *fmt, ...);
112 #endif
113 #else /* DEBUG_MSGS */
114 #define DEBUG_WRAP(code)
115 /* I would use DebugMessage(dbt,fmt...) but that only works with GCC */
116 
117 #endif /* DEBUG_MSGS */
118 
119 #endif /* DEBUG_H */
120 
121