This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
/
plugbase.h
195 lines (151 loc) · 5.03 KB
/
plugbase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
** Copyright (C) 2002-2009 Sourcefire, Inc.
** Copyright (C) 1998-2002 Martin Roesch <roesch@sourcefire.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License Version 2 as
** published by the Free Software Foundation. You may not use, modify or
** distribute this program under any other version of the GNU General
** Public License.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id$ */
#ifndef __PLUGBASE_H__
#define __PLUGBASE_H__
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
//#include "rules.h"
#include "sf_types.h"
#include "debug.h"
#ifndef WIN32
# include <sys/ioctl.h>
#endif /* !WIN32 */
#ifdef ENABLE_SSL
# ifdef Free
/* Free macro in radix.h if defined, will conflict with OpenSSL definition */
# undef Free
# endif
#endif
#if defined(FREEBSD) || defined(OPENBSD)
# include <sys/socket.h>
#endif
#if !defined(__SOLARIS__) && !defined(__CYGWIN32__) && !defined(__CYGWIN__) && \
!defined( __CYGWIN64__)
#include <net/route.h>
#endif
#ifdef ENABLE_SSL
# undef Free
#endif
#if defined(SOLARIS) || defined(FREEBSD) || defined(OPENBSD)
# include <sys/param.h>
#endif
#if defined(FREEBSD) || defined(OPENBSD) || defined(NETBSD) || defined(OSF1)
# include <sys/mbuf.h>
#endif
#ifndef IFNAMSIZ /* IFNAMSIZ is defined in all platforms I checked.. */
# include <net/if.h>
#endif
#include "decode.h"
#define SMALLBUFFER 32
typedef enum _InputType
{
INPUT_TYPE__UNIFIED_LOG = 1,
INPUT_TYPE__UNIFIED_ALERT,
INPUT_TYPE__UNIFIED,
INPUT_TYPE__UNIFIED2,
INPUT_TYPE__MAX
} InputType;
typedef enum _OutputType
{
OUTPUT_TYPE__ALERT = 1,
OUTPUT_TYPE__LOG,
OUTPUT_TYPE__SPECIAL,
OUTPUT_TYPE__MAX
} OutputType;
typedef enum _OutputTypeFlag
{
OUTPUT_TYPE_FLAG__ALERT = 0x00000001,
OUTPUT_TYPE_FLAG__LOG = 0x00000002,
OUTPUT_TYPE_FLAG__ALL = 0x7fffffff
} OutputTypeFlag;
/***************************** Input Plugin API ******************************/
typedef void (*InputConfigFunc)(char *);
typedef int (*InputReadHeaderFunc)(void *);
typedef int (*InputReadRecordFunc)(void *);
typedef struct _InputConfigFuncNode
{
char *keyword;
InputConfigFunc func;
struct _InputConfigFuncNode *next;
} InputConfigFuncNode;
typedef struct _InputFuncNode
{
char *keyword;
int configured_flag;
void *arg;
int (*readRecordHeader)(void *);
int (*readRecord)(void *);
struct _InputFuncNode *next;
} InputFuncNode;
void RegisterInputPlugins(void);
void InitInputPlugins();
int ActivateInputPlugin(char *plugin_name, char *plugin_options);
void RegisterInputPlugin(char *, InputConfigFunc);
InputConfigFunc GetInputConfigFunc(char *);
InputFuncNode *GetInputPlugin(char *);
void DumpInputPlugins();
int AddArgToInputList(char *plugin_name, void *arg);
int AddReadRecordHeaderFuncToInputList(char *plugin_name, int (*readRecordHeader)(void *));
int AddReadRecordFuncToInputList(char *plugin_name, int (*readRecord)(void *));
int InputFuncNodeConfigured(InputFuncNode *ifn);
/***************************** Output Plugin API *****************************/
typedef void (*OutputConfigFunc)(char *);
typedef void (*OutputFunc)(Packet *, void *, uint32_t, void *);
typedef struct _OutputConfigFuncNode
{
char *keyword;
int output_type_flags;
OutputConfigFunc func;
struct _OutputConfigFuncNode *next;
} OutputConfigFuncNode;
typedef struct _OutputFuncNode
{
void *arg;
OutputFunc func;
struct _OutputFuncNode *next;
} OutputFuncNode;
void RegisterOutputPlugins(void);
void RegisterOutputPlugin(char *, int, OutputConfigFunc);
OutputConfigFunc GetOutputConfigFunc(char *);
int GetOutputTypeFlags(char *);
void DumpOutputPlugins(void);
void AddFuncToOutputList(OutputFunc, OutputType, void *);
void FreeOutputConfigFuncs(void);
void FreeOutputList(OutputFuncNode *);
void CallOutputPlugins(OutputType, Packet *, void *, uint32_t);
/*************************** Miscellaneous API ***************************/
typedef void (*PluginSignalFunc)(int, void *);
typedef struct _PluginSignalFuncNode
{
void *arg;
PluginSignalFunc func;
struct _PluginSignalFuncNode *next;
} PluginSignalFuncNode;
/* Used for both rule options and output. Preprocessors have their own */
void AddFuncToRestartList(PluginSignalFunc, void *);
void AddFuncToCleanExitList(PluginSignalFunc, void *);
void AddFuncToShutdownList(PluginSignalFunc, void *);
void AddFuncToPostConfigList(PluginSignalFunc, void *);
void AddFuncToSignalList(PluginSignalFunc, void *, PluginSignalFuncNode **);
void PostConfigInitPlugins(PluginSignalFuncNode *);
void FreePluginSigFuncs(PluginSignalFuncNode *);
#endif /* __PLUGBASE_H__ */