30 typedef struct PluginListNode_ {
55 PluginListNode *node =
SCCalloc(1,
sizeof(*node));
57 SCLogError(
"Failed to allocate memory for plugin");
60 node->plugin = plugin;
69 static void InitPlugin(
char *path)
71 void *lib = dlopen(path, RTLD_NOW);
73 SCLogNotice(
"Failed to open %s as a plugin: %s", path, dlerror());
78 if (plugin_register == NULL) {
79 SCLogError(
"Plugin does not export SCPluginRegister function: %s", path);
85 SCLogError(
"Plugin registration failed: %s", path);
92 void SCPluginsLoad(
const char *capture_plugin_name,
const char *capture_plugin_args)
101 if (stat(plugin->
val, &statbuf) == -1) {
102 SCLogError(
"Bad plugin path: %s: %s", plugin->
val, strerror(errno));
105 if (S_ISDIR(statbuf.st_mode)) {
107 DIR *dir = opendir(plugin->
val);
109 SCLogError(
"Failed to open plugin directory %s: %s", plugin->
val, strerror(errno));
112 struct dirent *entry = NULL;
114 while ((entry = readdir(dir)) != NULL) {
115 if (strstr(entry->d_name,
".so") != NULL) {
116 snprintf(path,
sizeof(path),
"%s/%s", plugin->
val, entry->d_name);
122 InitPlugin(plugin->
val);
128 if (capture == NULL) {
129 FatalError(
"No capture plugin found with name %s", capture_plugin_name);
136 static bool IsBuiltinTypeName(
const char *name)
138 const char *builtin[] = {
145 for (
int i = 0;; i++) {
146 if (builtin[i] == NULL) {
149 if (strcmp(builtin[i], name) == 0) {
166 if (IsBuiltinTypeName(plugin->
name)) {
167 SCLogError(
"Eve file type name conflicts with built-in type: %s", plugin->
name);
174 if (strcmp(existing->
name, plugin->
name) == 0) {
175 SCLogError(
"Eve file type name conflicts with previously registered type: %s",
190 if (strcmp(name, plugin->
name) == 0) {
208 if (strcmp(name, plugin->
name) == 0) {