30 typedef struct PluginListNode_ {
53 PluginListNode *node =
SCCalloc(1,
sizeof(*node));
55 SCLogError(
"Failed to allocate memory for plugin");
58 node->plugin = plugin;
67 static void InitPlugin(
char *path)
69 void *lib = dlopen(path, RTLD_NOW);
71 SCLogNotice(
"Failed to open %s as a plugin: %s", path, dlerror());
76 if (plugin_register == NULL) {
77 SCLogError(
"Plugin does not export SCPluginRegister function: %s", path);
83 SCLogError(
"Plugin registration failed: %s", path);
90 void SCPluginsLoad(
const char *capture_plugin_name,
const char *capture_plugin_args)
99 if (stat(plugin->
val, &statbuf) == -1) {
100 SCLogError(
"Bad plugin path: %s: %s", plugin->
val, strerror(errno));
103 if (S_ISDIR(statbuf.st_mode)) {
105 DIR *dir = opendir(plugin->
val);
107 SCLogError(
"Failed to open plugin directory %s: %s", plugin->
val, strerror(errno));
110 struct dirent *entry = NULL;
112 while ((entry = readdir(dir)) != NULL) {
113 if (strstr(entry->d_name,
".so") != NULL) {
114 snprintf(path,
sizeof(path),
"%s/%s", plugin->
val, entry->d_name);
120 InitPlugin(plugin->
val);
126 if (capture == NULL) {
127 FatalError(
"No capture plugin found with name %s", capture_plugin_name);
145 if (strcmp(name, plugin->
name) == 0) {