suricata
plugin.c
Go to the documentation of this file.
1 /* Copyright (C) 2024 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 #include "suricata-plugin.h"
19 #include "suricata-common.h"
20 #include "util-debug.h"
21 
22 #include "runmode.h"
23 #include "source.h"
24 
25 static void InitCapturePlugin(const char *args, int plugin_slot, int receive_slot, int decode_slot)
26 {
27  SCLogNotice("...");
28  CiCaptureIdsRegister(plugin_slot);
31 }
32 
33 static void SCPluginInit(void)
34 {
35  SCLogNotice("...");
36  SCCapturePlugin *plugin = SCCalloc(1, sizeof(SCCapturePlugin));
37  if (plugin == NULL) {
38  FatalError("Failed to allocate memory for capture plugin");
39  }
40  plugin->name = "ci-capture";
41  plugin->Init = InitCapturePlugin;
44 }
45 
47  .version = SC_API_VERSION,
48  .suricata_version = SC_PACKAGE_VERSION,
49  .name = "ci-capture",
50  .plugin_version = "0.1.0",
51  .author = "OISF Developer",
52  .license = "GPL-2.0-only",
53  .Init = SCPluginInit,
54 };
55 
57 {
58  return &PluginRegistration;
59 }
suricata-plugin.h
SCPluginRegisterCapture
int SCPluginRegisterCapture(SCCapturePlugin *)
SCCapturePlugin_::Init
void(* Init)(const char *args, int plugin_slot, int receive_slot, int decode_slot)
Definition: suricata-plugin.h:56
SCPlugin_::version
uint64_t version
Definition: suricata-plugin.h:43
SCCapturePlugin_::GetDefaultMode
const char *(* GetDefaultMode)(void)
Definition: suricata-plugin.h:59
SCPluginRegister
const SCPlugin * SCPluginRegister()
Definition: plugin.c:56
source.h
util-debug.h
CiCaptureIdsRegister
void CiCaptureIdsRegister(int slot)
Definition: runmode.c:70
SCCapturePlugin_::name
char * name
Definition: suricata-plugin.h:55
SCCapturePlugin_
Definition: suricata-plugin.h:54
TmModuleDecodeCiCaptureRegister
void TmModuleDecodeCiCaptureRegister(int slot)
Definition: source.c:146
TmModuleReceiveCiCaptureRegister
void TmModuleReceiveCiCaptureRegister(int slot)
Definition: source.c:133
SCPlugin_
Definition: suricata-plugin.h:41
CiCaptureIdsGetDefaultRunMode
const char * CiCaptureIdsGetDefaultRunMode(void)
Definition: runmode.c:25
suricata-common.h
FatalError
#define FatalError(...)
Definition: util-debug.h:502
SC_PACKAGE_VERSION
#define SC_PACKAGE_VERSION
Definition: suricata-plugin.h:36
PluginRegistration
const SCPlugin PluginRegistration
Definition: plugin.c:46
runmode.h
SCLogNotice
#define SCLogNotice(...)
Macro used to log NOTICE messages.
Definition: util-debug.h:237
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53