}
const SCPlugin PluginRegistration = {
+ .version = SC_API_VERSION,
+ .suricata_version = SC_PACKAGE_VERSION,
.name = "CustomLogger",
+ .plugin_version = "1.0.0",
.author = "Firstname Lastname",
.license = "GPLv2",
.Init = Init,
}
const SCPlugin PluginRegistration = {
+ .version = SC_API_VERSION,
+ .suricata_version = SC_PACKAGE_VERSION,
.name = FILETYPE_NAME,
+ .plugin_version = "0.1.0",
.author = "FirstName LastName <name@example.org>",
.license = "GPL-2.0-only",
.Init = PluginInit,
}
const SCPlugin PluginRegistration = {
+ .version = SC_API_VERSION,
+ .suricata_version = SC_PACKAGE_VERSION,
.name = "ci-capture",
+ .plugin_version = "0.1.0",
.author = "OISF Developer",
.license = "GPL-2.0-only",
.Init = SCPluginInit,
}
const SCPlugin PluginRegistration = {
+ .version = SC_API_VERSION,
+ .suricata_version = SC_PACKAGE_VERSION,
.name = "napatech",
+ .plugin_version = "1.0.0",
.author = "Open Information Security Foundation",
.license = "GPLv2",
.Init = SCPluginInit,
}
const SCPlugin PluginRegistration = {
+ .version = SC_API_VERSION,
+ .suricata_version = SC_PACKAGE_VERSION,
.name = "pfring",
+ .plugin_version = "1.0.0",
.author = "Open Information Security Foundation",
.license = "GPLv2",
.Init = SCPluginInit,
// This file is automatically generated. Do not edit.
+pub const SC_PACKAGE_VERSION: &[u8; 10] = b"8.0.0-dev\0";
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum AppProtoEnum {
alproto: AppProto, proto_name: *const ::std::os::raw::c_char,
);
}
+pub const SC_API_VERSION: u64 = 2048;
#[doc = " Structure to define a Suricata plugin."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SCPlugin_ {
+ pub version: u64,
+ pub suricata_version: *const ::std::os::raw::c_char,
pub name: *const ::std::os::raw::c_char,
+ pub plugin_version: *const ::std::os::raw::c_char,
pub license: *const ::std::os::raw::c_char,
pub author: *const ::std::os::raw::c_char,
pub Init: ::std::option::Option<unsafe extern "C" fn()>,
extern "C" {
pub fn SCPluginRegisterCapture(arg1: *mut SCCapturePlugin) -> ::std::os::raw::c_int;
}
-pub const SC_PLUGIN_API_VERSION: u64 = 8;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct SCAppLayerPlugin_ {
- pub version: u64,
pub name: *const ::std::os::raw::c_char,
pub Register: ::std::option::Option<unsafe extern "C" fn()>,
pub KeywordsRegister: ::std::option::Option<unsafe extern "C" fn()>,
#include <stdbool.h>
#include "queue.h"
+#include "autoconf.h"
/**
* The size of the data chunk inside each packet structure a plugin
*/
#define PLUGIN_VAR_SIZE 64
+// Do not reuse autoconf PACKAGE_VERSION which is a string
+// Defined as major version.minor version (no patch version)
+static const uint64_t SC_API_VERSION = 0x0800;
+#define SC_PACKAGE_VERSION PACKAGE_VERSION
+
/**
* Structure to define a Suricata plugin.
*/
typedef struct SCPlugin_ {
+ // versioning to check suricata/plugin API compatibility
+ uint64_t version;
+ const char *suricata_version;
const char *name;
+ const char *plugin_version;
const char *license;
const char *author;
void (*Init)(void);
int SCPluginRegisterCapture(SCCapturePlugin *);
-// Every change in the API used by plugins should change this number
-static const uint64_t SC_PLUGIN_API_VERSION = 8;
-
typedef struct SCAppLayerPlugin_ {
- // versioning to check suricata/plugin API compatibility
- uint64_t version;
const char *name;
void (*Register)(void);
void (*KeywordsRegister)(void);
bool RegisterPlugin(SCPlugin *plugin, void *lib)
{
+ if (plugin->version != SC_API_VERSION) {
+ SCLogError("Suricata and plugin versions differ: plugin has %" PRIx64
+ " (%s) vs Suricata %" PRIx64 " (plugin was built with %s)",
+ plugin->version, plugin->plugin_version, SC_API_VERSION, plugin->suricata_version);
+ return false;
+ }
BUG_ON(plugin->name == NULL);
BUG_ON(plugin->author == NULL);
BUG_ON(plugin->license == NULL);
node->plugin = plugin;
node->lib = lib;
TAILQ_INSERT_TAIL(&plugins, node, entries);
- SCLogNotice("Initializing plugin %s; author=%s; license=%s", plugin->name, plugin->author,
- plugin->license);
+ SCLogNotice("Initializing plugin %s; version= %s; author=%s; license=%s; built from %s",
+ plugin->name, plugin->plugin_version, plugin->author, plugin->license,
+ plugin->suricata_version);
(*plugin->Init)();
return true;
}
int SCPluginRegisterAppLayer(SCAppLayerPlugin *plugin)
{
- if (plugin->version != SC_PLUGIN_API_VERSION) {
- return 1;
- }
AppProto alproto = g_alproto_max;
AppProtoRegisterProtoString(alproto, plugin->name);
if (plugin->Register) {