00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PLUGBASE_H__
00021 #define __PLUGBASE_H__
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026
00027 #include "rules.h"
00028
00029 #ifndef WIN32
00030 #include <sys/ioctl.h>
00031 #endif
00032
00033
00034 #ifdef ENABLE_SSL
00035 #ifdef Free
00036
00037 #undef Free
00038 #endif
00039 #endif
00040
00041 #ifndef WIN32
00042 #include <net/route.h>
00043 #endif
00044 #ifdef ENABLE_SSL
00045 #undef Free
00046 #endif
00047
00048 #if defined(SOLARIS) || defined(FREEBSD) || defined(OPENBSD)
00049 #include <sys/param.h>
00050 #endif
00051
00052 #if defined(FREEBSD) || defined(OPENBSD) || defined(NETBSD) || defined(OSF1)
00053 #include <sys/mbuf.h>
00054 #endif
00055
00056 #ifndef IFNAMSIZ
00057 #include <net/if.h>
00058 #endif
00059
00060
00061 #define SMALLBUFFER 32
00062
00063 #define NT_OUTPUT_ALERT 0x1
00064 #define NT_OUTPUT_LOG 0x2
00065 #define NT_OUTPUT_SPECIAL 0x4
00066
00067 #define DETECTION_KEYWORD 0
00068 #define RESPONSE_KEYWORD 1
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 #define PP_ALL 0xffffffff
00084 #define PP_LOADBALANCING 0x00000001
00085 #define PP_PORTSCAN 0x00000002
00086 #define PP_HTTPINSPECT 0x00000004
00087 #define PP_PORTSCAN_IGNORE_HOSTS 0x00000008
00088 #define PP_RPCDECODE 0x00000010
00089 #define PP_BO 0x00000020
00090 #define PP_TELNEG 0x00000040
00091 #define PP_STREAM4 0x00000080
00092 #define PP_FRAG2 0x00000100
00093 #define PP_ARPSPOOF 0x00000200
00094 #define PP_ASN1DECODE 0x00000400
00095 #define PP_FNORD 0x00000800
00096 #define PP_CONVERSATION 0x00001000
00097 #define PP_PORTSCAN2 0x00002000
00098 #define PP_HTTPFLOW 0x00004000
00099 #define PP_PERFMONITOR 0x00008000
00100 #define PP_STREAM4_REASSEMBLE 0x00010000
00101 #define PP_FRAG3 0x00020000
00102 #define PP_SFPORTSCAN 0x00100000
00103
00104
00105
00106 typedef struct _KeywordXlate
00107 {
00108 char *keyword;
00109 void (*func)(char *, OptTreeNode *, int);
00110 } KeywordXlate;
00111
00112
00113 typedef struct _KeywordXlateList
00114 {
00115 KeywordXlate entry;
00116 struct _KeywordXlateList *next;
00117 } KeywordXlateList;
00118
00119 void InitPlugIns();
00120 void RegisterPlugin(char *, void (*func)(char *, OptTreeNode *, int));
00121 void DumpPlugIns();
00122 OptFpList *AddOptFuncToList(int (*func)(Packet *, struct _OptTreeNode*,
00123 struct _OptFpList*), OptTreeNode *);
00124 void AddRspFuncToList(int (*func) (Packet *, struct _RspFpList *),
00125 OptTreeNode *, void *);
00126
00127
00128
00129
00130
00131
00132 typedef struct _PreprocessKeywordNode
00133 {
00134 char *keyword;
00135 void (*func)(char *);
00136
00137 } PreprocessKeywordNode;
00138
00139 typedef struct _PreprocessKeywordList
00140 {
00141 PreprocessKeywordNode entry;
00142 struct _PreprocessKeywordList *next;
00143
00144 } PreprocessKeywordList;
00145
00146 typedef struct _PreprocessFuncNode
00147 {
00148 void *context;
00149 void (*func)(Packet *, void *);
00150 struct _PreprocessFuncNode *next;
00151
00152 } PreprocessFuncNode;
00153
00154 void InitPreprocessors();
00155 void RegisterPreprocessor(char *, void (*func)(u_char *));
00156 void DumpPreprocessors();
00157 PreprocessFuncNode *AddFuncToPreprocList(void (*func)(Packet *, void *));
00158
00159
00160
00161 typedef struct _PluginSignalFuncNode
00162 {
00163 void (*func)(int, void*);
00164 void *arg;
00165 struct _PluginSignalFuncNode *next;
00166
00167 } PluginSignalFuncNode;
00168
00169 int PacketIsIP(Packet *);
00170 int PacketIsTCP(Packet *);
00171 int PacketIsUDP(Packet *);
00172 int PacketIsICMP(Packet *);
00173 int DestinationIpIsHomenet(Packet *);
00174 int SourceIpIsHomenet(Packet *);
00175 int IsTcpSessionTraffic(Packet *);
00176 int CheckNet(struct in_addr *, struct in_addr *);
00177 void AddFuncToRestartList(void (*func)(int, void*), void*);
00178 void AddFuncToCleanExitList(void (*func)(int, void*), void*);
00179 void AddFuncToShutdownList(void (*func)(int, void*), void*);
00180 PluginSignalFuncNode *AddFuncToSignalList(void (*func)(int, void*), void*, PluginSignalFuncNode *);
00181
00182
00183
00184
00185 #define ENCODING_HEX 0
00186 #define ENCODING_BASE64 1
00187 #define ENCODING_ASCII 2
00188 #define DETAIL_FAST 0
00189 #define DETAIL_FULL 1
00190
00191 char *GetUniqueName(char *);
00192 char *GetIP(char *);
00193 char *GetHostname();
00194 int GetLocalTimezone();
00195
00196
00197
00198
00199
00200
00201
00202 char *GetTimestamp(register const struct timeval *, int);
00203 char *GetCurrentTimestamp();
00204 char *base64(u_char *, int);
00205 char *ascii(u_char *, int);
00206 char *hex(u_char *, int);
00207 char *fasthex(u_char *, int);
00208
00209
00210 #endif