Go to the documentation of this file.
36 typedef struct PluginListNode_ {
54 if (plugin->
version != SC_API_VERSION) {
55 SCLogError(
"Suricata and plugin versions differ: plugin has %" PRIx64
56 " (%s) vs Suricata %" PRIx64
" (plugin was built with %s)",
65 PluginListNode *node =
SCCalloc(1,
sizeof(*node));
67 SCLogError(
"Failed to allocate memory for plugin");
70 node->plugin = plugin;
73 SCLogNotice(
"Initializing plugin %s; version= %s; author=%s; license=%s; built from %s",
80 static void InitPlugin(
char *path)
82 void *lib = dlopen(path, RTLD_NOW);
84 SCLogNotice(
"Failed to open %s as a plugin: %s", path, dlerror());
89 if (plugin_register == NULL) {
90 SCLogError(
"Plugin does not export SCPluginRegister function: %s", path);
96 SCLogError(
"Plugin registration failed: %s", path);
103 void SCPluginsLoad(
const char *capture_plugin_name,
const char *capture_plugin_args)
112 if (stat(plugin->
val, &statbuf) == -1) {
113 SCLogError(
"Bad plugin path: %s: %s", plugin->
val, strerror(errno));
116 if (S_ISDIR(statbuf.st_mode)) {
118 DIR *dir = opendir(plugin->
val);
120 SCLogError(
"Failed to open plugin directory %s: %s", plugin->
val, strerror(errno));
123 struct dirent *entry = NULL;
125 while ((entry = readdir(dir)) != NULL) {
126 if (strstr(entry->d_name,
".so") != NULL) {
127 snprintf(path,
sizeof(path),
"%s/%s", plugin->
val, entry->d_name);
133 InitPlugin(plugin->
val);
139 if (capture == NULL) {
140 FatalError(
"No capture plugin found with name %s", capture_plugin_name);
158 if (strcmp(
name, plugin->
name) == 0) {
int SCPluginRegisterCapture(SCCapturePlugin *)
struct HtpBodyChunk_ * next
bool(* Logger)(const void *tx, void *jb)
void(* Init)(const char *args, int plugin_slot, int receive_slot, int decode_slot)
#define TAILQ_FOREACH(var, head, field)
#define TAILQ_INSERT_TAIL(head, elm, field)
void(* KeywordsRegister)(void)
int SCSigTablePreRegister(void(*KeywordsRegister)(void))
#define TAILQ_ENTRY(type)
#define TAILQ_HEAD_INITIALIZER(head)
SCRunMode SCRunmodeGet(void)
Get the current run mode.
bool RegisterPlugin(SCPlugin *, void *)
const char * plugin_version
void SCPluginsLoad(const char *capture_plugin_name, const char *capture_plugin_args)
const char * suricata_version
int SCPluginRegisterAppLayer(SCAppLayerPlugin *)
int AppLayerParserPreRegister(void(*Register)(void))
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
#define SCLogError(...)
Macro used to log ERROR messages.
#define TAILQ_HEAD(name, type)
AppProto AppProtoNewProtoFromString(const char *proto_name)
#define SCLogNotice(...)
Macro used to log NOTICE messages.
int SCOutputEvePreRegisterLogger(EveJsonTxLoggerRegistrationData reg_data)
SCCapturePlugin * SCPluginFindCaptureByName(const char *name)
SCPlugin *(* SCPluginRegisterFunc)(void)