.. code-block:: c
- static ConfNode *ConfGetNodeOrCreate(char *name, int final)
+ static SCConfNode *SCConfGetNodeOrCreate(char *name, int final)
static vs non-static
^^^^^^^^^^^^^^^^^^^^
.. code-block:: c
- ConfNode *parent_node = root;
+ SCConfNode *parent_node = root;
Generally, use descriptive variable names.
* \retval The existing configuration node if it exists, or a newly
* created node for the provided name. On error, NULL will be returned.
*/
- static ConfNode *ConfGetNodeOrCreate(char *name, int final)
+ static SCConfNode *SCConfGetNodeOrCreate(char *name, int final)
General comments
^^^^^^^^^^^^^^^^
;
const char *value;
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- FAIL_IF(ConfYamlLoadString(config, strlen(config)) != 0);
- FAIL_IF_NOT(ConfGet("some-log-dir", &value));
+ FAIL_IF(SCConfYamlLoadString(config, strlen(config)) != 0);
+ FAIL_IF_NOT(SCConfGet("some-log-dir", &value));
FAIL_IF(strcmp(value, "/tmp") != 0);
/* Test that parent.child0 does not exist, but child1 does. */
- FAIL_IF_NOT_NULL(ConfGetNode("parent.child0"));
- FAIL_IF_NOT(ConfGet("parent.child1.key", &value));
+ FAIL_IF_NOT_NULL(SCConfGetNode("parent.child0"));
+ FAIL_IF_NOT(SCConfGet("parent.child1.key", &value));
FAIL_IF(strcmp(value, "value") != 0);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
}
/* Set "offline" runmode to replay a pcap in library mode. */
- if (!ConfSetFromString("runmode=offline", 1)) {
+ if (!SCConfSetFromString("runmode=offline", 1)) {
exit(EXIT_FAILURE);
}
/* Force logging to the current directory. */
- ConfSetFromString("default-log-dir=.", 1);
+ SCConfSetFromString("default-log-dir=.", 1);
if (LiveRegisterDevice("lib0") < 0) {
fprintf(stderr, "LiveRegisterDevice failed");
* configuration for the eve instance, not just a node named after the plugin.
* This allows the plugin to get more context about what it is logging.
*/
-static int FiletypeInit(const ConfNode *conf, const bool threaded, void **data)
+static int FiletypeInit(const SCConfNode *conf, const bool threaded, void **data)
{
SCLogNotice("Initializing template eve output plugin: threaded=%d", threaded);
Context *context = SCCalloc(1, sizeof(Context));
/* An example of how you can access configuration data from a
* plugin. */
- if (conf && (conf = ConfNodeLookupChild(conf, "eve-template")) != NULL) {
- if (!ConfGetChildValueBool(conf, "verbose", &verbose)) {
+ if (conf && (conf = SCConfNodeLookupChild(conf, "eve-template")) != NULL) {
+ if (!SCConfGetChildValueBool(conf, "verbose", &verbose)) {
verbose = 1;
} else {
SCLogNotice("Read verbose configuration value of %d", verbose);
/* Display the configuration mode */
int use_all_streams;
- if (ConfGetBool("napatech.use-all-streams", &use_all_streams) == 0) {
+ if (SCConfGetBool("napatech.use-all-streams", &use_all_streams) == 0) {
SCLogInfo("Could not find napatech.use-all-streams in config file. Defaulting to \"no\".");
use_all_streams = 0;
}
- if (ConfGetBool("napatech.auto-config", &auto_config) == 0) {
+ if (SCConfGetBool("napatech.auto-config", &auto_config) == 0) {
SCLogInfo("napatech.auto-config not found in config file. Defaulting to disabled.");
}
- if (ConfGetBool("napatech.hardware-bypass", &use_hw_bypass) == 0) {
+ if (SCConfGetBool("napatech.hardware-bypass", &use_hw_bypass) == 0) {
SCLogInfo("napatech.hardware-bypass not found in config file. Defaulting to disabled.");
}
FatalError("Failed to allocate memory for temporary buffer: %s", strerror(errno));
}
- if (ConfGetBool("threading.set-cpu-affinity", &set_cpu_affinity) != 1) {
+ if (SCConfGetBool("threading.set-cpu-affinity", &set_cpu_affinity) != 1) {
set_cpu_affinity = 0;
}
}
#endif
- if (ConfGetBool("napatech.auto-config", &is_autoconfig) == 0) {
+ if (SCConfGetBool("napatech.auto-config", &is_autoconfig) == 0) {
is_autoconfig = 0;
}
SC_ATOMIC_ADD(numa_detect[numa_node].count, 1);
}
- if (ConfGetBool("threading.set-cpu-affinity", &set_cpu_affinity) != 1) {
+ if (SCConfGetBool("threading.set-cpu-affinity", &set_cpu_affinity) != 1) {
set_cpu_affinity = 0;
}
RecommendNUMAConfig();
#ifdef NAPATECH_ENABLE_BYPASS
- if (ConfGetBool("napatech.inline", &is_inline) == 0) {
+ if (SCConfGetBool("napatech.inline", &is_inline) == 0) {
is_inline = 0;
}
int enable_stream_stats = 0;
PacketCounters stream_counters[MAX_STREAMS];
- if (ConfGetBool("napatech.inline", &is_inline) == 0) {
+ if (SCConfGetBool("napatech.inline", &is_inline) == 0) {
is_inline = 0;
}
- if (ConfGetBool("napatech.enable-stream-stats", &enable_stream_stats) == 0) {
+ if (SCConfGetBool("napatech.enable-stream-stats", &enable_stream_stats) == 0) {
/* default is "no" */
enable_stream_stats = 0;
}
{
int worker_count = 0;
- ConfNode *affinity;
- ConfNode *root = ConfGetNode("threading.cpu-affinity");
+ SCConfNode *affinity;
+ SCConfNode *root = SCConfGetNode("threading.cpu-affinity");
if (root != NULL) {
}
if (strcmp(affinity->val, "worker-cpu-set") == 0) {
- ConfNode *node = ConfNodeLookupChild(affinity->head.tqh_first, "cpu");
- ConfNode *lnode;
+ SCConfNode *node = SCConfNodeLookupChild(affinity->head.tqh_first, "cpu");
+ SCConfNode *lnode;
enum CONFIG_SPECIFIER cpu_spec = CONFIG_SPECIFIER_UNDEFINED;
uint16_t instance_cnt = 0;
int use_all_streams = 0;
int set_cpu_affinity = 0;
- ConfNode *ntstreams;
+ SCConfNode *ntstreams;
uint16_t stream_id = 0;
uint8_t start = 0;
uint8_t end = 0;
stream_config[i].initialized = false;
}
- if (ConfGetBool("napatech.use-all-streams", &use_all_streams) == 0) {
+ if (SCConfGetBool("napatech.use-all-streams", &use_all_streams) == 0) {
/* default is "no" */
use_all_streams = 0;
}
}
} else {
- (void)ConfGetBool("threading.set-cpu-affinity", &set_cpu_affinity);
+ (void)SCConfGetBool("threading.set-cpu-affinity", &set_cpu_affinity);
if (NapatechIsAutoConfigEnabled() && (set_cpu_affinity == 1)) {
start = 0;
end = CountWorkerThreads() - 1;
} else {
/* When not using the default streams we need to
* parse the array of streams from the conf */
- if ((ntstreams = ConfGetNode("napatech.streams")) == NULL) {
+ if ((ntstreams = SCConfGetNode("napatech.streams")) == NULL) {
SCLogError("Failed retrieving napatech.streams from Config");
if (NapatechIsAutoConfigEnabled() && (set_cpu_affinity == 0)) {
SCLogError("if set-cpu-affinity: no in conf then napatech.streams must be "
}
/* Loop through all stream numbers in the array and register the devices */
- ConfNode *stream;
+ SCConfNode *stream;
enum CONFIG_SPECIFIER stream_spec = CONFIG_SPECIFIER_UNDEFINED;
instance_cnt = 0;
uint32_t filter_id = 0;
/* Get the hashmode from the conf file. */
- ConfGet("napatech.hashmode", &hash_mode);
+ SCConfGet("napatech.hashmode", &hash_mode);
snprintf(ntpl_cmd, 64, "hashmode = %s", hash_mode);
ports_spec.all = false;
- ConfNode *ntports;
+ SCConfNode *ntports;
int iteration = 0;
int status = 0;
NtConfigStream_t hconfig;
char span_ports[128];
memset(span_ports, 0, sizeof(span_ports));
- if (ConfGetBool("napatech.inline", &is_inline) == 0) {
+ if (SCConfGetBool("napatech.inline", &is_inline) == 0) {
is_inline = 0;
}
/* When not using the default streams we need to parse
* the array of streams from the conf
*/
- if ((ntports = ConfGetNode("napatech.ports")) == NULL) {
+ if ((ntports = SCConfGetNode("napatech.ports")) == NULL) {
FatalError("Failed retrieving napatech.ports from Conf");
}
/* Loop through all ports in the array */
- ConfNode *port;
+ SCConfNode *port;
enum CONFIG_SPECIFIER stream_spec = CONFIG_SPECIFIER_UNDEFINED;
if (NapatechUseHWBypass()) {
(void)SC_ATOMIC_ADD(pfconf->ref, 1);
/* Find initial node */
- if (ConfGet("pfring.threads", &threadsstr) != 1) {
+ if (SCConfGet("pfring.threads", &threadsstr) != 1) {
pfconf->threads = 1;
} else {
if (threadsstr != NULL) {
SCLogInfo("%s: ZC interface detected, not setting cluster-id", pfconf->iface);
} else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
SCLogInfo("DNA interface detected, not setting cluster-id");
- } else if (ConfGet("pfring.cluster-id", &tmpclusterid) != 1) {
+ } else if (SCConfGet("pfring.cluster-id", &tmpclusterid) != 1) {
SCLogError("Could not get cluster-id from config");
} else {
if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) {
} else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
SCLogInfo(
"%s: DNA interface detected, not setting cluster type for PF_RING", pfconf->iface);
- } else if (ConfGet("pfring.cluster-type", &tmpctype) != 1) {
+ } else if (SCConfGet("pfring.cluster-type", &tmpctype) != 1) {
SCLogError("Could not get cluster-type from config");
} else if (strcmp(tmpctype, "cluster_round_robin") == 0) {
SCLogInfo("%s: Using round-robin cluster mode for PF_RING", pfconf->iface);
static void *ParsePfringConfig(const char *iface)
{
const char *threadsstr = NULL;
- ConfNode *if_root;
- ConfNode *if_default = NULL;
- ConfNode *pf_ring_node;
+ SCConfNode *if_root;
+ SCConfNode *if_default = NULL;
+ SCConfNode *pf_ring_node;
PfringIfaceConfig *pfconf = SCMalloc(sizeof(*pfconf));
const char *tmpclusterid;
const char *tmpctype = NULL;
(void)SC_ATOMIC_ADD(pfconf->ref, 1);
/* Find initial node */
- pf_ring_node = ConfGetNode("pfring");
+ pf_ring_node = SCConfGetNode("pfring");
if (pf_ring_node == NULL) {
SCLogInfo("Unable to find pfring config using default value");
return pfconf;
if (active_runmode && !strcmp("single", active_runmode)) {
pfconf->threads = 1;
- } else if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
+ } else if (SCConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
pfconf->threads = 1;
} else if (threadsstr != NULL) {
if (strcmp(threadsstr, "auto") == 0) {
(void)SC_ATOMIC_ADD(pfconf->ref, pfconf->threads);
/* command line value has precedence */
- if (ConfGet("pfring.cluster-id", &tmpclusterid) == 1) {
+ if (SCConfGet("pfring.cluster-id", &tmpclusterid) == 1) {
if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) {
SCLogWarning("Invalid value for "
"pfring.cluster-id: '%s'. Resetting to 1.",
} else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
SCLogInfo("%s: DNA interface detected, not setting cluster-id for PF_RING",
pfconf->iface);
- } else if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-id", &tmpclusterid) !=
+ } else if (SCConfGetChildValueWithDefault(if_root, if_default, "cluster-id", &tmpclusterid) !=
1) {
SCLogError("Could not get cluster-id from config");
} else {
FatalError("IPS mode not supported in PF_RING.");
}
- if (ConfGet("pfring.cluster-type", &tmpctype) == 1) {
+ if (SCConfGet("pfring.cluster-type", &tmpctype) == 1) {
SCLogDebug("Going to use command-line provided cluster-type");
getctype = 1;
} else {
} else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
SCLogInfo("%s: DNA interface detected, not setting cluster type for PF_RING",
pfconf->iface);
- } else if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-type", &tmpctype) !=
+ } else if (SCConfGetChildValueWithDefault(if_root, if_default, "cluster-type", &tmpctype) !=
1) {
SCLogError("Could not get cluster-type from config");
} else {
return NULL;
}
}
- if (ConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) {
if (strcmp(tmpctype, "auto") == 0) {
pfconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
- } else if (ConfValIsTrue(tmpctype)) {
+ } else if (SCConfValIsTrue(tmpctype)) {
pfconf->checksum_mode = CHECKSUM_VALIDATION_ENABLE;
- } else if (ConfValIsFalse(tmpctype)) {
+ } else if (SCConfValIsFalse(tmpctype)) {
pfconf->checksum_mode = CHECKSUM_VALIDATION_DISABLE;
} else if (strcmp(tmpctype, "rx-only") == 0) {
pfconf->checksum_mode = CHECKSUM_VALIDATION_RXONLY;
}
}
- if (ConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &bool_val) == 1) {
+ if (SCConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &bool_val) == 1) {
if (bool_val) {
#ifdef HAVE_PF_RING_FLOW_OFFLOAD
SCLogConfig("%s: Enabling bypass support in PF_RING (if supported by underlying hw)",
{
const char *def_dev = NULL;
/* 1.0 config should return a string */
- if (ConfGet("pfring.interface", &def_dev) != 1) {
+ if (SCConfGet("pfring.interface", &def_dev) != 1) {
return PFRING_CONF_V2;
} else {
return PFRING_CONF_V1;
static int GetDevAndParser(const char **live_dev, ConfigIfaceParserFunc *parser)
{
- ConfGet("pfring.live-interface", live_dev);
+ SCConfGet("pfring.live-interface", live_dev);
/* determine which config type we have */
if (PfringConfLevel() > PFRING_CONF_V1) {
*parser = OldParsePfringConfig;
/* In v1: try to get interface name from config */
if (*live_dev == NULL) {
- if (ConfGet("pfring.interface", live_dev) == 1) {
+ if (SCConfGet("pfring.interface", live_dev) == 1) {
SCLogInfo("Using interface %s", *live_dev);
LiveRegisterDevice(*live_dev);
} else {
/// cbindgen:ignore
extern {
- fn ConfGet(key: *const c_char, res: *mut *const c_char) -> i8;
- fn ConfGetChildValue(conf: *const c_void, key: *const c_char,
+ fn SCConfGet(key: *const c_char, res: *mut *const c_char) -> i8;
+ fn SCConfGetChildValue(conf: *const c_void, key: *const c_char,
vptr: *mut *const c_char) -> i8;
- fn ConfGetChildValueBool(conf: *const c_void, key: *const c_char,
+ fn SCConfGetChildValueBool(conf: *const c_void, key: *const c_char,
vptr: *mut c_int) -> i8;
- fn ConfGetNode(key: *const c_char) -> *const c_void;
+ fn SCConfGetNode(key: *const c_char) -> *const c_void;
}
pub fn conf_get_node(key: &str) -> Option<ConfNode> {
return None;
};
- let node = unsafe { ConfGetNode(key.as_ptr()) };
+ let node = unsafe { SCConfGetNode(key.as_ptr()) };
if node.is_null() {
None
} else {
unsafe {
let s = CString::new(key).unwrap();
- if ConfGet(s.as_ptr(), &mut vptr) != 1 {
+ if SCConfGet(s.as_ptr(), &mut vptr) != 1 {
SCLogDebug!("Failed to find value for key {}", key);
return None;
}
unsafe {
let s = CString::new(key).unwrap();
- if ConfGetChildValue(self.conf,
+ if SCConfGetChildValue(self.conf,
s.as_ptr(),
&mut vptr) != 1 {
return None;
unsafe {
let s = CString::new(key).unwrap();
- if ConfGetChildValueBool(self.conf,
+ if SCConfGetChildValueBool(self.conf,
s.as_ptr(),
&mut vptr) != 1 {
return false;
/**
* \brief Create a new LogFileCtx for alert debug logging.
*
- * \param ConfNode containing configuration for this logger.
+ * \param SCConfNode containing configuration for this logger.
*
* \return output_ctx if succesful, NULL otherwise
*/
-static OutputInitResult AlertDebugLogInitCtx(ConfNode *conf)
+static OutputInitResult AlertDebugLogInitCtx(SCConfNode *conf)
{
OutputInitResult result = { NULL, false };
LogFileCtx *file_ctx = NULL;
* \param conf The configuration node for this output.
* \return A LogFileCtx pointer on success, NULL on failure.
*/
-OutputInitResult AlertFastLogInitCtx(ConfNode *conf)
+OutputInitResult AlertFastLogInitCtx(SCConfNode *conf)
{
OutputInitResult result = { NULL, false };
LogFileCtx *logfile_ctx = LogFileNewCtx();
#define SURICATA_ALERT_FASTLOG_H
void AlertFastLogRegister(void);
-OutputInitResult AlertFastLogInitCtx(ConfNode *);
+OutputInitResult AlertFastLogInitCtx(SCConfNode *);
#endif /* SURICATA_ALERT_FASTLOG_H */
* \param conf The configuration node for this output.
* \return A OutputCtx pointer on success, NULL on failure.
*/
-static OutputInitResult AlertSyslogInitCtx(ConfNode *conf)
+static OutputInitResult AlertSyslogInitCtx(SCConfNode *conf)
{
SCLogWarning("The syslog output has been deprecated and will be removed in Suricata 9.0.");
OutputInitResult result = { NULL, false };
- const char *facility_s = ConfNodeLookupChildValue(conf, "facility");
+ const char *facility_s = SCConfNodeLookupChildValue(conf, "facility");
if (facility_s == NULL) {
facility_s = DEFAULT_ALERT_SYSLOG_FACILITY_STR;
}
facility = DEFAULT_ALERT_SYSLOG_FACILITY;
}
- const char *level_s = ConfNodeLookupChildValue(conf, "level");
+ const char *level_s = SCConfNodeLookupChildValue(conf, "level");
if (level_s != NULL) {
int level = SCMapEnumNameToValue(level_s, SCSyslogGetLogLevelMap());
if (level != -1) {
}
}
- const char *ident = ConfNodeLookupChildValue(conf, "identity");
+ const char *ident = SCConfNodeLookupChildValue(conf, "identity");
/* if null we just pass that to openlog, which will then
* figure it out by itself. */
char param[100];
int r;
- ConfNode *node;
- ConfNode *port_node = NULL;
+ SCConfNode *node;
+ SCConfNode *port_node = NULL;
int config = 0;
r = snprintf(param, sizeof(param), "%s%s%s", "app-layer.protocols.",
} else if (r > (int)sizeof(param)) {
FatalError("buffer not big enough to write param.");
}
- node = ConfGetNode(param);
+ node = SCConfGetNode(param);
if (node == NULL) {
SCLogDebug("Entry for %s not found.", param);
r = snprintf(param, sizeof(param), "%s%s%s%s%s", "app-layer.protocols.",
} else if (r > (int)sizeof(param)) {
FatalError("buffer not big enough to write param.");
}
- node = ConfGetNode(param);
+ node = SCConfGetNode(param);
if (node == NULL)
goto end;
}
/* detect by destination port of the flow (e.g. port 53 for DNS) */
- port_node = ConfNodeLookupChild(node, "dp");
+ port_node = SCConfNodeLookupChild(node, "dp");
if (port_node == NULL)
- port_node = ConfNodeLookupChild(node, "toserver");
+ port_node = SCConfNodeLookupChild(node, "toserver");
if (port_node != NULL && port_node->val != NULL) {
AppLayerProtoDetectPPRegister(ipproto,
}
/* detect by source port of flow */
- port_node = ConfNodeLookupChild(node, "sp");
+ port_node = SCConfNodeLookupChild(node, "sp");
if (port_node == NULL)
- port_node = ConfNodeLookupChild(node, "toclient");
+ port_node = SCConfNodeLookupChild(node, "toclient");
if (port_node != NULL && port_node->val != NULL) {
AppLayerProtoDetectPPRegister(ipproto,
int enabled = 1;
char param[100];
- ConfNode *node;
+ SCConfNode *node;
int r;
if (RunmodeIsUnittests())
FatalError("buffer not big enough to write param.");
}
- node = ConfGetNode(param);
+ node = SCConfGetNode(param);
if (node == NULL) {
SCLogDebug("Entry for %s not found.", param);
r = snprintf(param, sizeof(param), "%s%s%s%s%s", "app-layer.protocols.",
FatalError("buffer not big enough to write param.");
}
- node = ConfGetNode(param);
+ node = SCConfGetNode(param);
if (node == NULL) {
SCLogDebug("Entry for %s not found.", param);
if (default_enabled) {
}
if (node->val) {
- if (ConfValIsTrue(node->val)) {
+ if (SCConfValIsTrue(node->val)) {
goto enabled;
- } else if (ConfValIsFalse(node->val)) {
+ } else if (SCConfValIsFalse(node->val)) {
goto disabled;
} else if (strcasecmp(node->val, "detection-only") == 0) {
goto enabled;
/** set config values for memcap, prealloc and hash_size */
uint64_t memcap;
- if ((ConfGet("app-layer.protocols.http.memcap", &conf_val)) == 1)
- {
+ if ((SCConfGet("app-layer.protocols.http.memcap", &conf_val)) == 1) {
if (ParseSizeStringU64(conf_val, &memcap) < 0) {
SCLogError("Error parsing http.memcap "
"from conf file - %s. Killing engine",
const char *str = NULL;
uint64_t memcap = HTTP_RANGE_DEFAULT_MEMCAP;
uint32_t timeout = HTTP_RANGE_DEFAULT_TIMEOUT;
- if (ConfGet("app-layer.protocols.http.byterange.memcap", &str) == 1) {
+ if (SCConfGet("app-layer.protocols.http.byterange.memcap", &str) == 1) {
if (ParseSizeStringU64(str, &memcap) < 0) {
SCLogWarning("memcap value cannot be deduced: %s,"
" resetting to default",
memcap = 0;
}
}
- if (ConfGet("app-layer.protocols.http.byterange.timeout", &str) == 1) {
+ if (SCConfGet("app-layer.protocols.http.byterange.timeout", &str) == 1) {
size_t slen = strlen(str);
if (slen > UINT16_MAX || StringParseUint32(&timeout, 10, (uint16_t)slen, str) <= 0) {
SCLogWarning("timeout value cannot be deduced: %s,"
/**
* \brief Function to return XFF configuration from a configuration node.
*/
-void HttpXFFGetCfg(ConfNode *conf, HttpXFFCfg *result)
+void HttpXFFGetCfg(SCConfNode *conf, HttpXFFCfg *result)
{
BUG_ON(result == NULL);
- ConfNode *xff_node = NULL;
+ SCConfNode *xff_node = NULL;
if (conf != NULL)
- xff_node = ConfNodeLookupChild(conf, "xff");
+ xff_node = SCConfNodeLookupChild(conf, "xff");
- if (xff_node != NULL && ConfNodeChildValueIsTrue(xff_node, "enabled")) {
- const char *xff_mode = ConfNodeLookupChildValue(xff_node, "mode");
+ if (xff_node != NULL && SCConfNodeChildValueIsTrue(xff_node, "enabled")) {
+ const char *xff_mode = SCConfNodeLookupChildValue(xff_node, "mode");
if (xff_mode != NULL && strcasecmp(xff_mode, "overwrite") == 0) {
result->flags |= XFF_OVERWRITE;
result->flags |= XFF_EXTRADATA;
}
- const char *xff_deployment = ConfNodeLookupChildValue(xff_node, "deployment");
+ const char *xff_deployment = SCConfNodeLookupChildValue(xff_node, "deployment");
if (xff_deployment != NULL && strcasecmp(xff_deployment, "forward") == 0) {
result->flags |= XFF_FORWARD;
result->flags |= XFF_REVERSE;
}
- const char *xff_header = ConfNodeLookupChildValue(xff_node, "header");
+ const char *xff_header = SCConfNodeLookupChildValue(xff_node, "header");
if (xff_header != NULL) {
result->header = (char *) xff_header;
SCLogWarning("The XFF header hasn't been defined, using the default %s", XFF_DEFAULT);
result->header = XFF_DEFAULT;
}
- }
- else {
+ } else {
result->flags = XFF_DISABLED;
}
}
const char *header; /**< XFF header name */
} HttpXFFCfg;
-void HttpXFFGetCfg(ConfNode *conf, HttpXFFCfg *result);
+void HttpXFFGetCfg(SCConfNode *conf, HttpXFFCfg *result);
int HttpXFFGetIPFromTx(const Flow *f, uint64_t tx_id, HttpXFFCfg *xff_cfg, char *dstbuf, int dstbuflen);
htp_config_register_request_line(cfg_prec->cfg, HTPCallbackRequestLine);
}
-static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, struct HTPConfigTree *tree)
+static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, SCConfNode *s, struct HTPConfigTree *tree)
{
if (cfg_prec == NULL || s == NULL || tree == NULL)
return;
- ConfNode *p = NULL;
+ SCConfNode *p = NULL;
/* Default Parameters */
TAILQ_FOREACH (p, &s->head, next) {
if (strcasecmp("address", p->name) == 0) {
- ConfNode *pval;
+ SCConfNode *pval;
/* Addresses */
TAILQ_FOREACH(pval, &p->head, next) {
SCLogDebug("LIBHTP server %s: %s=%s", s->name, p->name, pval->val);
}
} else if (strcasecmp("double-decode-query", p->name) == 0) {
- if (ConfValIsTrue(p->val)) {
+ if (SCConfValIsTrue(p->val)) {
htp_config_register_request_line(cfg_prec->cfg,
HTPCallbackDoubleDecodeQuery);
}
} else if (strcasecmp("double-decode-path", p->name) == 0) {
- if (ConfValIsTrue(p->val)) {
+ if (SCConfValIsTrue(p->val)) {
htp_config_register_request_line(cfg_prec->cfg,
HTPCallbackDoubleDecodePath);
}
value);
#endif
} else if (strcasecmp("path-convert-backslash-separators", p->name) == 0) {
- htp_config_set_backslash_convert_slashes(cfg_prec->cfg,
- HTP_DECODER_URL_PATH,
- ConfValIsTrue(p->val));
+ htp_config_set_backslash_convert_slashes(
+ cfg_prec->cfg, HTP_DECODER_URL_PATH, SCConfValIsTrue(p->val));
} else if (strcasecmp("path-bestfit-replacement-char", p->name) == 0) {
if (strlen(p->val) == 1) {
htp_config_set_bestfit_replacement_byte(cfg_prec->cfg,
"for libhtp param path-bestfit-replacement-char");
}
} else if (strcasecmp("path-convert-lowercase", p->name) == 0) {
- htp_config_set_convert_lowercase(cfg_prec->cfg,
- HTP_DECODER_URL_PATH,
- ConfValIsTrue(p->val));
+ htp_config_set_convert_lowercase(
+ cfg_prec->cfg, HTP_DECODER_URL_PATH, SCConfValIsTrue(p->val));
} else if (strcasecmp("path-nul-encoded-terminates", p->name) == 0) {
- htp_config_set_nul_encoded_terminates(cfg_prec->cfg,
- HTP_DECODER_URL_PATH,
- ConfValIsTrue(p->val));
+ htp_config_set_nul_encoded_terminates(
+ cfg_prec->cfg, HTP_DECODER_URL_PATH, SCConfValIsTrue(p->val));
} else if (strcasecmp("path-nul-raw-terminates", p->name) == 0) {
- htp_config_set_nul_raw_terminates(cfg_prec->cfg,
- HTP_DECODER_URL_PATH,
- ConfValIsTrue(p->val));
+ htp_config_set_nul_raw_terminates(
+ cfg_prec->cfg, HTP_DECODER_URL_PATH, SCConfValIsTrue(p->val));
} else if (strcasecmp("path-separators-compress", p->name) == 0) {
- htp_config_set_path_separators_compress(cfg_prec->cfg,
- HTP_DECODER_URL_PATH,
- ConfValIsTrue(p->val));
+ htp_config_set_path_separators_compress(
+ cfg_prec->cfg, HTP_DECODER_URL_PATH, SCConfValIsTrue(p->val));
} else if (strcasecmp("path-separators-decode", p->name) == 0) {
- htp_config_set_path_separators_decode(cfg_prec->cfg,
- HTP_DECODER_URL_PATH,
- ConfValIsTrue(p->val));
+ htp_config_set_path_separators_decode(
+ cfg_prec->cfg, HTP_DECODER_URL_PATH, SCConfValIsTrue(p->val));
} else if (strcasecmp("path-u-encoding-decode", p->name) == 0) {
- htp_config_set_u_encoding_decode(cfg_prec->cfg,
- HTP_DECODER_URL_PATH,
- ConfValIsTrue(p->val));
+ htp_config_set_u_encoding_decode(
+ cfg_prec->cfg, HTP_DECODER_URL_PATH, SCConfValIsTrue(p->val));
} else if (strcasecmp("path-url-encoding-invalid-handling", p->name) == 0) {
enum htp_url_encoding_handling_t handling;
if (strcasecmp(p->val, "preserve_percent") == 0) {
HTP_DECODER_URL_PATH,
handling);
} else if (strcasecmp("path-utf8-convert-bestfit", p->name) == 0) {
- htp_config_set_utf8_convert_bestfit(cfg_prec->cfg,
- HTP_DECODER_URL_PATH,
- ConfValIsTrue(p->val));
+ htp_config_set_utf8_convert_bestfit(
+ cfg_prec->cfg, HTP_DECODER_URL_PATH, SCConfValIsTrue(p->val));
} else if (strcasecmp("uri-include-all", p->name) == 0) {
- cfg_prec->uri_include_all = (1 == ConfValIsTrue(p->val));
+ cfg_prec->uri_include_all = (1 == SCConfValIsTrue(p->val));
SCLogDebug("uri-include-all %s",
cfg_prec->uri_include_all ? "enabled" : "disabled");
} else if (strcasecmp("query-plusspace-decode", p->name) == 0) {
- htp_config_set_plusspace_decode(cfg_prec->cfg,
- HTP_DECODER_URLENCODED,
- ConfValIsTrue(p->val));
+ htp_config_set_plusspace_decode(
+ cfg_prec->cfg, HTP_DECODER_URLENCODED, SCConfValIsTrue(p->val));
} else if (strcasecmp("meta-field-limit", p->name) == 0) {
uint32_t limit = 0;
if (ParseSizeStringU32(p->val, &limit) < 0) {
#endif
#ifdef HAVE_HTP_CONFIG_SET_LZMA_LAYERS
} else if (strcasecmp("lzma-enabled", p->name) == 0) {
- if (ConfValIsTrue(p->val)) {
+ if (SCConfValIsTrue(p->val)) {
htp_config_set_lzma_layers(cfg_prec->cfg, 1);
- } else if (!ConfValIsFalse(p->val)) {
+ } else if (!SCConfValIsFalse(p->val)) {
int8_t limit;
if (StringParseInt8(&limit, 10, 0, (const char *)p->val) < 0) {
FatalError("failed to parse 'lzma-enabled' "
#endif
} else if (strcasecmp("randomize-inspection-sizes", p->name) == 0) {
if (!g_disable_randomness) {
- cfg_prec->randomize = ConfValIsTrue(p->val);
+ cfg_prec->randomize = SCConfValIsTrue(p->val);
}
} else if (strcasecmp("randomize-inspection-range", p->name) == 0) {
uint32_t range;
}
cfg_prec->randomize_range = range;
} else if (strcasecmp("http-body-inline", p->name) == 0) {
- if (ConfValIsTrue(p->val)) {
+ if (SCConfValIsTrue(p->val)) {
cfg_prec->http_body_inline = 1;
- } else if (ConfValIsFalse(p->val)) {
+ } else if (SCConfValIsFalse(p->val)) {
cfg_prec->http_body_inline = 0;
} else {
if (strcmp("auto", p->val) != 0) {
}
}
} else if (strcasecmp("swf-decompression", p->name) == 0) {
- ConfNode *pval;
+ SCConfNode *pval;
TAILQ_FOREACH(pval, &p->head, next) {
if (strcasecmp("enabled", pval->name) == 0) {
- if (ConfValIsTrue(pval->val)) {
+ if (SCConfValIsTrue(pval->val)) {
cfg_prec->swf_decompression_enabled = 1;
- } else if (ConfValIsFalse(pval->val)) {
+ } else if (SCConfValIsFalse(pval->val)) {
cfg_prec->swf_decompression_enabled = 0;
} else {
WarnInvalidConfEntry("swf-decompression.enabled", "%s", "no");
}
SCLogDebug("LIBHTP default config: %p", cfglist.cfg);
HTPConfigSetDefaultsPhase1(&cfglist);
- if (ConfGetNode("app-layer.protocols.http.libhtp") == NULL) {
- HTPConfigParseParameters(&cfglist, ConfGetNode("libhtp.default-config"), &cfgtree);
+ if (SCConfGetNode("app-layer.protocols.http.libhtp") == NULL) {
+ HTPConfigParseParameters(&cfglist, SCConfGetNode("libhtp.default-config"), &cfgtree);
} else {
- HTPConfigParseParameters(
- &cfglist, ConfGetNode("app-layer.protocols.http.libhtp.default-config"), &cfgtree);
+ HTPConfigParseParameters(&cfglist,
+ SCConfGetNode("app-layer.protocols.http.libhtp.default-config"), &cfgtree);
}
HTPConfigSetDefaultsPhase2("default", &cfglist);
HTPParseMemcap();
/* Read server config and create a parser for each IP in radix tree */
- ConfNode *server_config = ConfGetNode("app-layer.protocols.http.libhtp.server-config");
+ SCConfNode *server_config = SCConfGetNode("app-layer.protocols.http.libhtp.server-config");
if (server_config == NULL) {
- server_config = ConfGetNode("libhtp.server-config");
+ server_config = SCConfGetNode("libhtp.server-config");
if (server_config == NULL) {
SCLogDebug("LIBHTP Configuring %p", server_config);
SCReturn;
}
SCLogDebug("LIBHTP Configuring %p", server_config);
- ConfNode *si;
+ SCConfNode *si;
/* Server Nodes */
TAILQ_FOREACH(si, &server_config->head, next) {
/* Need the named node, not the index */
- ConfNode *s = TAILQ_FIRST(&si->head);
+ SCConfNode *s = TAILQ_FIRST(&si->head);
if (NULL == s) {
SCLogDebug("LIBHTP s NULL");
continue;
personality: IDS\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
HtpState *htp_state = NULL;
AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(true);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
UTHFreeFlow(f);
PASS;
personality: Apache_2_2\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
HtpState *htp_state = NULL;
AppLayerParserThreadCtxFree(alp_tctx);
StreamTcpFreeConfig(true);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
UTHFreeFlow(f);
PASS;
personality: IIS_7_0\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
- ConfNode *outputs;
- outputs = ConfGetNode("libhtp.default-config.personality");
+ SCConfNode *outputs;
+ outputs = SCConfGetNode("libhtp.default-config.personality");
FAIL_IF_NULL(outputs);
- outputs = ConfGetNode("libhtp.server-config");
+ outputs = SCConfGetNode("libhtp.server-config");
FAIL_IF_NULL(outputs);
- ConfNode *node = TAILQ_FIRST(&outputs->head);
+ SCConfNode *node = TAILQ_FIRST(&outputs->head);
FAIL_IF_NULL(node);
FAIL_IF(strcmp(node->name, "0") != 0);
node = TAILQ_FIRST(&node->head);
FAIL_IF(strcmp(node->name, "apache-tomcat") != 0);
int i = 0;
- ConfNode *n;
+ SCConfNode *n;
- ConfNode *node2 = ConfNodeLookupChild(node, "personality");
+ SCConfNode *node2 = SCConfNodeLookupChild(node, "personality");
FAIL_IF_NULL(node2);
FAIL_IF(strcmp(node2->val, "Tomcat_6_0") != 0);
- node = ConfNodeLookupChild(node, "address");
+ node = SCConfNodeLookupChild(node, "address");
FAIL_IF_NULL(node);
TAILQ_FOREACH (n, &node->head, next) {
i++;
}
- outputs = ConfGetNode("libhtp.server-config");
+ outputs = SCConfGetNode("libhtp.server-config");
FAIL_IF_NULL(outputs);
node = TAILQ_FIRST(&outputs->head);
node = TAILQ_NEXT(node, next);
FAIL_IF_NULL(node);
FAIL_IF(strcmp(node->name, "iis7") != 0);
- node2 = ConfNodeLookupChild(node, "personality");
+ node2 = SCConfNodeLookupChild(node, "personality");
FAIL_IF_NULL(node2);
FAIL_IF(strcmp(node2->val, "IIS_7_0") != 0);
- node = ConfNodeLookupChild(node, "address");
+ node = SCConfNodeLookupChild(node, "address");
FAIL_IF_NULL(node);
i = 0;
i++;
}
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
personality: IIS_7_0\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
FAIL_IF_NULL(cfglist.cfg);
FAIL_IF_NULL(cfgtree.ipv4.head);
SCLogDebug("LIBHTP using config: %p", htp);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
PASS;
personality: IIS_7_0\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
personality: Apache_2\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
personality: Apache_2\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
double-decode-query: no\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
double-decode-query: yes\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
double-decode-query: yes\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
double-decode-query: yes\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
double-decode-query: yes\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
query-plusspace-decode: yes\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
personality: IDS\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
uri-include-all: true\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
const char *addr = "4.3.2.1";
memset(&ssn, 0, sizeof(ssn));
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
response-body-limit: 0\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
TcpSession ssn;
AppLayerParserThreadCtxFree(alp_tctx);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
StreamTcpFreeConfig(true);
UTHFreeFlow(f);
memset(&ssn, 0, sizeof(ssn));
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
char *httpbuf = SCMalloc(len);
UTHFreeFlow(f);
SCFree(httpbuf);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
PASS;
}
memset(&ssn, 0, sizeof(ssn));
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
httpbuf = SCMalloc(len);
UTHFreeFlow(f);
SCFree(httpbuf);
HTPFreeConfig();
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
PASS;
}
request-body-limit: 1\n\
response-body-limit: 1\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
HTPConfigure();
Packet *p1 = NULL;
FLOW_DESTROY(&f);
UTHFreePackets(&p1, 1);
UTHFreePackets(&p2, 1);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
HtpConfigRestoreBackup();
PASS;
}
int enabled = 1;
char param[100];
- ConfNode *node;
+ SCConfNode *node;
int r;
if (RunmodeIsUnittests())
FatalError("buffer not big enough to write param.");
}
- node = ConfGetNode(param);
+ node = SCConfGetNode(param);
if (node == NULL) {
SCLogDebug("Entry for %s not found.", param);
r = snprintf(param, sizeof(param), "%s%s%s%s%s", "app-layer.protocols.",
FatalError("buffer not big enough to write param.");
}
- node = ConfGetNode(param);
+ node = SCConfGetNode(param);
if (node == NULL) {
SCLogDebug("Entry for %s not found.", param);
goto enabled;
}
}
- if (ConfValIsTrue(node->val)) {
+ if (SCConfValIsTrue(node->val)) {
goto enabled;
- } else if (ConfValIsFalse(node->val)) {
+ } else if (SCConfValIsFalse(node->val)) {
goto disabled;
} else if (strcasecmp(node->val, "detection-only") == 0) {
goto disabled;
uint32_t content_inspect_min_size = 0;
uint32_t content_inspect_window = 0;
- ConfNode *config = ConfGetNode("app-layer.protocols.smtp.mime");
+ SCConfNode *config = SCConfGetNode("app-layer.protocols.smtp.mime");
if (config != NULL) {
- ConfNode *extract_urls_schemes = NULL;
+ SCConfNode *extract_urls_schemes = NULL;
int val;
- int ret = ConfGetChildValueBool(config, "decode-mime", &val);
+ int ret = SCConfGetChildValueBool(config, "decode-mime", &val);
if (ret) {
smtp_config.decode_mime = val;
}
- ret = ConfGetChildValueBool(config, "decode-base64", &val);
+ ret = SCConfGetChildValueBool(config, "decode-base64", &val);
if (ret) {
SCMimeSmtpConfigDecodeBase64(val);
}
- ret = ConfGetChildValueBool(config, "decode-quoted-printable", &val);
+ ret = SCConfGetChildValueBool(config, "decode-quoted-printable", &val);
if (ret) {
SCMimeSmtpConfigDecodeQuoted(val);
}
- ret = ConfGetChildValueInt(config, "header-value-depth", &imval);
+ ret = SCConfGetChildValueInt(config, "header-value-depth", &imval);
if (ret) {
if (imval < 0 || imval > UINT32_MAX) {
FatalError("Invalid value for header-value-depth");
SCMimeSmtpConfigHeaderValueDepth((uint32_t)imval);
}
- ret = ConfGetChildValueBool(config, "extract-urls", &val);
+ ret = SCConfGetChildValueBool(config, "extract-urls", &val);
if (ret) {
SCMimeSmtpConfigExtractUrls(val);
}
/* Parse extract-urls-schemes from mime config, add '://' suffix to found schemes,
* and provide a default value of 'http' for the schemes to be extracted
* if no schemes are found in the config */
- extract_urls_schemes = ConfNodeLookupChild(config, "extract-urls-schemes");
+ extract_urls_schemes = SCConfNodeLookupChild(config, "extract-urls-schemes");
if (extract_urls_schemes) {
- ConfNode *scheme = NULL;
+ SCConfNode *scheme = NULL;
TAILQ_FOREACH (scheme, &extract_urls_schemes->head, next) {
size_t scheme_len = strlen(scheme->val);
SCMimeSmtpConfigExtractUrlsSchemeAdd("http://");
}
- ret = ConfGetChildValueBool(config, "log-url-scheme", &val);
+ ret = SCConfGetChildValueBool(config, "log-url-scheme", &val);
if (ret) {
SCMimeSmtpConfigLogUrlScheme(val);
}
- ret = ConfGetChildValueBool(config, "body-md5", &val);
+ ret = SCConfGetChildValueBool(config, "body-md5", &val);
if (ret) {
SCMimeSmtpConfigBodyMd5(val);
}
}
- ConfNode *t = ConfGetNode("app-layer.protocols.smtp.inspected-tracker");
- ConfNode *p = NULL;
+ SCConfNode *t = SCConfGetNode("app-layer.protocols.smtp.inspected-tracker");
+ SCConfNode *p = NULL;
if (t != NULL) {
TAILQ_FOREACH(p, &t->head, next) {
smtp_config.sbcfg.buf_size = content_limit ? content_limit : 256;
- if (ConfGetBool("app-layer.protocols.smtp.raw-extraction",
+ if (SCConfGetBool("app-layer.protocols.smtp.raw-extraction",
(int *)&smtp_config.raw_extraction) != 1) {
smtp_config.raw_extraction = SMTP_RAW_EXTRACTION_DEFAULT_VALUE;
}
uint64_t value = SMTP_DEFAULT_MAX_TX;
smtp_config.max_tx = SMTP_DEFAULT_MAX_TX;
const char *str = NULL;
- if (ConfGet("app-layer.protocols.smtp.max-tx", &str) == 1) {
+ if (SCConfGet("app-layer.protocols.smtp.max-tx", &str) == 1) {
if (ParseSizeStringU64(str, &value) < 0) {
SCLogWarning("max-tx value cannot be deduced: %s,"
" keeping default",
/* Check if we should generate Hassh fingerprints */
int enable_hassh = SSH_CONFIG_DEFAULT_HASSH;
const char *strval = NULL;
- if (ConfGet("app-layer.protocols.ssh.hassh", &strval) != 1) {
+ if (SCConfGet("app-layer.protocols.ssh.hassh", &strval) != 1) {
enable_hassh = SSH_CONFIG_DEFAULT_HASSH;
} else if (strcmp(strval, "auto") == 0) {
enable_hassh = SSH_CONFIG_DEFAULT_HASSH;
- } else if (ConfValIsFalse(strval)) {
+ } else if (SCConfValIsFalse(strval)) {
enable_hassh = SSH_CONFIG_DEFAULT_HASSH;
- } else if (ConfValIsTrue(strval)) {
+ } else if (SCConfValIsTrue(strval)) {
enable_hassh = true;
}
const char *strval = NULL;
/* Check if we should generate JA3 fingerprints */
int enable_ja3 = SSL_CONFIG_DEFAULT_JA3;
- if (ConfGet("app-layer.protocols.tls.ja3-fingerprints", &strval) != 1) {
+ if (SCConfGet("app-layer.protocols.tls.ja3-fingerprints", &strval) != 1) {
enable_ja3 = SSL_CONFIG_DEFAULT_JA3;
} else if (strcmp(strval, "auto") == 0) {
enable_ja3 = SSL_CONFIG_DEFAULT_JA3;
- } else if (ConfValIsFalse(strval)) {
+ } else if (SCConfValIsFalse(strval)) {
enable_ja3 = 0;
ssl_config.disable_ja3 = true;
- } else if (ConfValIsTrue(strval)) {
+ } else if (SCConfValIsTrue(strval)) {
enable_ja3 = true;
}
SC_ATOMIC_SET(ssl_config.enable_ja3, enable_ja3);
const char *strval = NULL;
/* Check if we should generate JA4 fingerprints */
int enable_ja4 = SSL_CONFIG_DEFAULT_JA4;
- if (ConfGet("app-layer.protocols.tls.ja4-fingerprints", &strval) != 1) {
+ if (SCConfGet("app-layer.protocols.tls.ja4-fingerprints", &strval) != 1) {
enable_ja4 = SSL_CONFIG_DEFAULT_JA4;
} else if (strcmp(strval, "auto") == 0) {
enable_ja4 = SSL_CONFIG_DEFAULT_JA4;
- } else if (ConfValIsFalse(strval)) {
+ } else if (SCConfValIsFalse(strval)) {
enable_ja4 = 0;
ssl_config.disable_ja4 = true;
- } else if (ConfValIsTrue(strval)) {
+ } else if (SCConfValIsTrue(strval)) {
enable_ja4 = true;
}
SC_ATOMIC_SET(ssl_config.enable_ja4, enable_ja4);
AppLayerParserRegisterStateProgressCompletionStatus(
ALPROTO_TLS, TLS_STATE_FINISHED, TLS_STATE_FINISHED);
- ConfNode *enc_handle = ConfGetNode("app-layer.protocols.tls.encryption-handling");
+ SCConfNode *enc_handle = SCConfGetNode("app-layer.protocols.tls.encryption-handling");
if (enc_handle != NULL && enc_handle->val != NULL) {
SCLogDebug("have app-layer.protocols.tls.encryption-handling = %s", enc_handle->val);
if (strcmp(enc_handle->val, "full") == 0) {
}
} else {
/* Get the value of no reassembly option from the config file */
- if (ConfGetNode("app-layer.protocols.tls.no-reassemble") == NULL) {
+ if (SCConfGetNode("app-layer.protocols.tls.no-reassemble") == NULL) {
int value = 0;
- if (ConfGetBool("tls.no-reassemble", &value) == 1 && value == 1)
+ if (SCConfGetBool("tls.no-reassemble", &value) == 1 && value == 1)
ssl_config.encrypt_mode = SSL_CNF_ENC_HANDLE_BYPASS;
} else {
int value = 0;
- if (ConfGetBool("app-layer.protocols.tls.no-reassemble", &value) == 1 && value == 1)
+ if (SCConfGetBool("app-layer.protocols.tls.no-reassemble", &value) == 1 &&
+ value == 1)
ssl_config.encrypt_mode = SSL_CNF_ENC_HANDLE_BYPASS;
}
}
static char *conf_dirname = NULL;
-static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int rlevel, int state);
+static int ConfYamlParse(
+ yaml_parser_t *parser, SCConfNode *parent, int inseq, int rlevel, int state);
/* Configuration processing states. */
enum conf_state {
*
* \retval 0 on success, -1 on failure.
*/
-int ConfYamlHandleInclude(ConfNode *parent, const char *filename)
+int SCConfYamlHandleInclude(SCConfNode *parent, const char *filename)
{
yaml_parser_t parser;
char include_filename[PATH_MAX];
*
* \retval 0 on success, -1 on failure.
*/
-static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int rlevel, int state)
+static int ConfYamlParse(
+ yaml_parser_t *parser, SCConfNode *parent, int inseq, int rlevel, int state)
{
- ConfNode *node = parent;
+ SCConfNode *node = parent;
yaml_event_t event;
memset(&event, 0, sizeof(event));
int done = 0;
if (state == CONF_INCLUDE) {
if (value != NULL) {
SCLogInfo("Including configuration file %s.", value);
- if (ConfYamlHandleInclude(parent, value) != 0) {
+ if (SCConfYamlHandleInclude(parent, value) != 0) {
goto fail;
}
}
}
char sequence_node_name[DEFAULT_NAME_LEN];
snprintf(sequence_node_name, DEFAULT_NAME_LEN, "%d", seq_idx++);
- ConfNode *seq_node = NULL;
+ SCConfNode *seq_node = NULL;
if (was_empty < 0) {
// initialize was_empty
if (TAILQ_EMPTY(&parent->head)) {
}
// we only check if the node's list was not empty at first
if (was_empty == 0) {
- seq_node = ConfNodeLookupChild(parent, sequence_node_name);
+ seq_node = SCConfNodeLookupChild(parent, sequence_node_name);
}
if (seq_node != NULL) {
/* The sequence node has already been set, probably
TAILQ_REMOVE(&parent->head, seq_node, next);
}
else {
- seq_node = ConfNodeNew();
+ seq_node = SCConfNodeNew();
if (unlikely(seq_node == NULL)) {
goto fail;
}
else {
if (state == CONF_INCLUDE) {
SCLogInfo("Including configuration file %s.", value);
- if (ConfYamlHandleInclude(parent, value) != 0) {
+ if (SCConfYamlHandleInclude(parent, value) != 0) {
goto fail;
}
state = CONF_KEY;
}
if (strchr(value, '.') != NULL) {
- node = ConfNodeGetNodeOrCreate(parent, value, 0);
+ node = SCConfNodeGetNodeOrCreate(parent, value, 0);
if (node == NULL) {
/* Error message already logged. */
goto fail;
}
} else {
- ConfNode *existing = ConfNodeLookupChild(parent, value);
+ SCConfNode *existing = SCConfNodeLookupChild(parent, value);
if (existing != NULL) {
if (!existing->final) {
SCLogInfo("Configuration node '%s' redefined.", existing->name);
- ConfNodePrune(existing);
+ SCConfNodePrune(existing);
}
node = existing;
} else {
- node = ConfNodeNew();
+ node = SCConfNodeNew();
if (unlikely(node == NULL)) {
goto fail;
}
if (value != NULL && (tag != NULL) && (strcmp(tag, "!include") == 0)) {
SCLogInfo("Including configuration file %s at "
"parent node %s.", value, node->name);
- if (ConfYamlHandleInclude(node, value) != 0)
+ if (SCConfYamlHandleInclude(node, value) != 0)
goto fail;
} else if (!node->final && value != NULL) {
if (node->val != NULL)
if (inseq) {
char sequence_node_name[DEFAULT_NAME_LEN];
snprintf(sequence_node_name, DEFAULT_NAME_LEN, "%d", seq_idx++);
- ConfNode *seq_node = NULL;
+ SCConfNode *seq_node = NULL;
if (was_empty < 0) {
// initialize was_empty
if (TAILQ_EMPTY(&node->head)) {
}
// we only check if the node's list was not empty at first
if (was_empty == 0) {
- seq_node = ConfNodeLookupChild(node, sequence_node_name);
+ seq_node = SCConfNodeLookupChild(node, sequence_node_name);
}
if (seq_node != NULL) {
/* The sequence node has already been set, probably
TAILQ_REMOVE(&node->head, seq_node, next);
}
else {
- seq_node = ConfNodeNew();
+ seq_node = SCConfNodeNew();
if (unlikely(seq_node == NULL)) {
goto fail;
}
*
* \retval 0 on success, -1 on failure.
*/
-int
-ConfYamlLoadFile(const char *filename)
+int SCConfYamlLoadFile(const char *filename)
{
FILE *infile;
yaml_parser_t parser;
int ret;
- ConfNode *root = ConfGetRootNode();
+ SCConfNode *root = SCConfGetRootNode();
if (yaml_parser_initialize(&parser) != 1) {
SCLogError("failed to initialize yaml parser.");
/**
* \brief Load configuration from a YAML string.
*/
-int
-ConfYamlLoadString(const char *string, size_t len)
+int SCConfYamlLoadString(const char *string, size_t len)
{
- ConfNode *root = ConfGetRootNode();
+ SCConfNode *root = SCConfGetRootNode();
yaml_parser_t parser;
int ret;
*
* \retval 0 on success, -1 on failure.
*/
-int
-ConfYamlLoadFileWithPrefix(const char *filename, const char *prefix)
+int SCConfYamlLoadFileWithPrefix(const char *filename, const char *prefix)
{
FILE *infile;
yaml_parser_t parser;
int ret;
- ConfNode *root = ConfGetNode(prefix);
+ SCConfNode *root = SCConfGetNode(prefix);
struct stat stat_buf;
/* coverity[toctou] */
if (root == NULL) {
/* if node at 'prefix' doesn't yet exist, add a place holder */
- ConfSet(prefix, "<prefix root node>");
- root = ConfGetNode(prefix);
+ SCConfSet(prefix, "<prefix root node>");
+ root = SCConfGetNode(prefix);
if (root == NULL) {
fclose(infile);
yaml_parser_delete(&parser);
default-log-dir: /tmp\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
- ConfNode *node;
- node = ConfGetNode("rule-files");
+ SCConfNode *node;
+ node = SCConfGetNode("rule-files");
FAIL_IF_NULL(node);
- FAIL_IF_NOT(ConfNodeIsSequence(node));
+ FAIL_IF_NOT(SCConfNodeIsSequence(node));
FAIL_IF(TAILQ_EMPTY(&node->head));
int i = 0;
- ConfNode *filename;
+ SCConfNode *filename;
TAILQ_FOREACH(filename, &node->head, next) {
if (i == 0) {
FAIL_IF(strcmp(filename->val, "netbios.rules") != 0);
- FAIL_IF(ConfNodeIsSequence(filename));
+ FAIL_IF(SCConfNodeIsSequence(filename));
FAIL_IF(filename->is_seq != 0);
}
else if (i == 1) {
FAIL_IF(strcmp(filename->val, "x11.rules") != 0);
- FAIL_IF(ConfNodeIsSequence(filename));
+ FAIL_IF(SCConfNodeIsSequence(filename));
}
FAIL_IF(i > 1);
i++;
}
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
log-level: info\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- ConfYamlLoadString(input, strlen(input));
+ SCConfYamlLoadString(input, strlen(input));
- ConfNode *outputs;
- outputs = ConfGetNode("logging.output");
+ SCConfNode *outputs;
+ outputs = SCConfGetNode("logging.output");
FAIL_IF_NULL(outputs);
- ConfNode *output;
- ConfNode *output_param;
+ SCConfNode *output;
+ SCConfNode *output_param;
output = TAILQ_FIRST(&outputs->head);
FAIL_IF_NULL(output);
FAIL_IF(strcmp(output_param->name, "log-level") != 0);
FAIL_IF(strcmp(output_param->val, "info") != 0);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int
ConfYamlNonYamlFileTest(void)
{
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- FAIL_IF(ConfYamlLoadFile("/etc/passwd") != -1);
+ FAIL_IF(SCConfYamlLoadFile("/etc/passwd") != -1);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
log-level: info\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- FAIL_IF(ConfYamlLoadString(input, strlen(input)) != -1);
+ FAIL_IF(SCConfYamlLoadString(input, strlen(input)) != -1);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
- compress_separators\n\
";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- FAIL_IF(ConfYamlLoadString(input, strlen(input)) != 0);
+ FAIL_IF(SCConfYamlLoadString(input, strlen(input)) != 0);
- ConfNode *outputs;
- outputs = ConfGetNode("libhtp.server-config");
+ SCConfNode *outputs;
+ outputs = SCConfGetNode("libhtp.server-config");
FAIL_IF_NULL(outputs);
- ConfNode *node;
+ SCConfNode *node;
node = TAILQ_FIRST(&outputs->head);
FAIL_IF_NULL(node);
FAIL_IF_NULL(node);
FAIL_IF(strcmp(node->name, "apache-php") != 0);
- node = ConfNodeLookupChild(node, "address");
+ node = SCConfNodeLookupChild(node, "address");
FAIL_IF_NULL(node);
node = TAILQ_FIRST(&node->head);
FAIL_IF(strcmp(node->name, "0") != 0);
FAIL_IF(strcmp(node->val, "192.168.1.0/24") != 0);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
"unix-command:\n"
" enabled: no\n";
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
/* Write out the test files. */
FAIL_IF_NULL((config_file = fopen(config_filename, "w")));
conf_dirname = NULL;
}
- FAIL_IF(ConfYamlLoadFile("ConfYamlFileIncludeTest-config.yaml") != 0);
+ FAIL_IF(SCConfYamlLoadFile("ConfYamlFileIncludeTest-config.yaml") != 0);
/* Check values that should have been loaded into the root of the
* configuration. */
- ConfNode *node;
- node = ConfGetNode("host-mode");
+ SCConfNode *node;
+ node = SCConfGetNode("host-mode");
FAIL_IF_NULL(node);
FAIL_IF(strcmp(node->val, "auto") != 0);
- node = ConfGetNode("unix-command.enabled");
+ node = SCConfGetNode("unix-command.enabled");
FAIL_IF_NULL(node);
FAIL_IF(strcmp(node->val, "no") != 0);
/* Check for values that were included under a mapping. */
- node = ConfGetNode("mapping.host-mode");
+ node = SCConfGetNode("mapping.host-mode");
FAIL_IF_NULL(node);
FAIL_IF(strcmp(node->val, "auto") != 0);
- node = ConfGetNode("mapping.unix-command.enabled");
+ node = SCConfGetNode("mapping.unix-command.enabled");
FAIL_IF_NULL(node);
FAIL_IF(strcmp(node->val, "no") != 0);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
unlink(config_filename);
unlink(include_filename);
"vars.address-groups.HOME_NET: \"10.10.10.10/32\"\n";
const char *value;
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- FAIL_IF(ConfYamlLoadString(config, strlen(config)) != 0);
- FAIL_IF_NOT(ConfGet("some-log-dir", &value));
+ FAIL_IF(SCConfYamlLoadString(config, strlen(config)) != 0);
+ FAIL_IF_NOT(SCConfGet("some-log-dir", &value));
FAIL_IF(strcmp(value, "/tmp") != 0);
/* Test that parent.child0 does not exist, but child1 does. */
- FAIL_IF_NOT_NULL(ConfGetNode("parent.child0"));
- FAIL_IF_NOT(ConfGet("parent.child1.key", &value));
+ FAIL_IF_NOT_NULL(SCConfGetNode("parent.child0"));
+ FAIL_IF_NOT(SCConfGet("parent.child1.key", &value));
FAIL_IF(strcmp(value, "value") != 0);
/* First check that vars.address-groups.EXTERNAL_NET has the
* expected parent of vars.address-groups and save this
* pointer. We want to make sure that the overrided value has the
* same parent later on. */
- ConfNode *vars_address_groups = ConfGetNode("vars.address-groups");
+ SCConfNode *vars_address_groups = SCConfGetNode("vars.address-groups");
FAIL_IF_NULL(vars_address_groups);
- ConfNode *vars_address_groups_external_net = ConfGetNode("vars.address-groups.EXTERNAL_NET");
+ SCConfNode *vars_address_groups_external_net =
+ SCConfGetNode("vars.address-groups.EXTERNAL_NET");
FAIL_IF_NULL(vars_address_groups_external_net);
FAIL_IF_NOT(vars_address_groups_external_net->parent == vars_address_groups);
/* Now check that HOME_NET has the overrided value. */
- ConfNode *vars_address_groups_home_net = ConfGetNode("vars.address-groups.HOME_NET");
+ SCConfNode *vars_address_groups_home_net = SCConfGetNode("vars.address-groups.HOME_NET");
FAIL_IF_NULL(vars_address_groups_home_net);
FAIL_IF(strcmp(vars_address_groups_home_net->val, "10.10.10.10/32") != 0);
/* And check that it has the correct parent. */
FAIL_IF_NOT(vars_address_groups_home_net->parent == vars_address_groups);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int
ConfYamlOverrideFinalTest(void)
{
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
char config[] =
"%YAML 1.1\n"
"default-log-dir: /var/log\n";
/* Set the log directory as if it was set on the command line. */
- FAIL_IF_NOT(ConfSetFinal("default-log-dir", "/tmp"));
- FAIL_IF(ConfYamlLoadString(config, strlen(config)) != 0);
+ FAIL_IF_NOT(SCConfSetFinal("default-log-dir", "/tmp"));
+ FAIL_IF(SCConfYamlLoadString(config, strlen(config)) != 0);
const char *default_log_dir;
- FAIL_IF_NOT(ConfGet("default-log-dir", &default_log_dir));
+ FAIL_IF_NOT(SCConfGet("default-log-dir", &default_log_dir));
FAIL_IF(strcmp(default_log_dir, "/tmp") != 0);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int ConfYamlNull(void)
{
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
char config[] = "%YAML 1.1\n"
"---\n"
"empty-quoted: \"\"\n"
"empty-unquoted: \n"
"list: [\"null\", null, \"Null\", Null, \"NULL\", NULL, \"~\", ~]\n";
- FAIL_IF(ConfYamlLoadString(config, strlen(config)) != 0);
+ FAIL_IF(SCConfYamlLoadString(config, strlen(config)) != 0);
const char *val;
- FAIL_IF_NOT(ConfGet("quoted-tilde", &val));
+ FAIL_IF_NOT(SCConfGet("quoted-tilde", &val));
FAIL_IF_NULL(val);
- FAIL_IF_NOT(ConfGet("unquoted-tilde", &val));
+ FAIL_IF_NOT(SCConfGet("unquoted-tilde", &val));
FAIL_IF_NOT_NULL(val);
- FAIL_IF_NOT(ConfGet("quoted-null", &val));
+ FAIL_IF_NOT(SCConfGet("quoted-null", &val));
FAIL_IF_NULL(val);
- FAIL_IF_NOT(ConfGet("unquoted-null", &val));
+ FAIL_IF_NOT(SCConfGet("unquoted-null", &val));
FAIL_IF_NOT_NULL(val);
- FAIL_IF_NOT(ConfGet("quoted-Null", &val));
+ FAIL_IF_NOT(SCConfGet("quoted-Null", &val));
FAIL_IF_NULL(val);
- FAIL_IF_NOT(ConfGet("unquoted-Null", &val));
+ FAIL_IF_NOT(SCConfGet("unquoted-Null", &val));
FAIL_IF_NOT_NULL(val);
- FAIL_IF_NOT(ConfGet("quoted-NULL", &val));
+ FAIL_IF_NOT(SCConfGet("quoted-NULL", &val));
FAIL_IF_NULL(val);
- FAIL_IF_NOT(ConfGet("unquoted-NULL", &val));
+ FAIL_IF_NOT(SCConfGet("unquoted-NULL", &val));
FAIL_IF_NOT_NULL(val);
- FAIL_IF_NOT(ConfGet("empty-quoted", &val));
+ FAIL_IF_NOT(SCConfGet("empty-quoted", &val));
FAIL_IF_NULL(val);
- FAIL_IF_NOT(ConfGet("empty-unquoted", &val));
+ FAIL_IF_NOT(SCConfGet("empty-unquoted", &val));
FAIL_IF_NOT_NULL(val);
- FAIL_IF_NOT(ConfGet("list.0", &val));
+ FAIL_IF_NOT(SCConfGet("list.0", &val));
FAIL_IF_NULL(val);
- FAIL_IF_NOT(ConfGet("list.1", &val));
+ FAIL_IF_NOT(SCConfGet("list.1", &val));
FAIL_IF_NOT_NULL(val);
- FAIL_IF_NOT(ConfGet("list.2", &val));
+ FAIL_IF_NOT(SCConfGet("list.2", &val));
FAIL_IF_NULL(val);
- FAIL_IF_NOT(ConfGet("list.3", &val));
+ FAIL_IF_NOT(SCConfGet("list.3", &val));
FAIL_IF_NOT_NULL(val);
- FAIL_IF_NOT(ConfGet("list.4", &val));
+ FAIL_IF_NOT(SCConfGet("list.4", &val));
FAIL_IF_NULL(val);
- FAIL_IF_NOT(ConfGet("list.5", &val));
+ FAIL_IF_NOT(SCConfGet("list.5", &val));
FAIL_IF_NOT_NULL(val);
- FAIL_IF_NOT(ConfGet("list.6", &val));
+ FAIL_IF_NOT(SCConfGet("list.6", &val));
FAIL_IF_NULL(val);
- FAIL_IF_NOT(ConfGet("list.7", &val));
+ FAIL_IF_NOT(SCConfGet("list.7", &val));
FAIL_IF_NOT_NULL(val);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
#endif /* UNITTESTS */
-void
-ConfYamlRegisterTests(void)
+void SCConfYamlRegisterTests(void)
{
#ifdef UNITTESTS
UtRegisterTest("ConfYamlSequenceTest", ConfYamlSequenceTest);
#include "conf.h"
-int ConfYamlLoadFile(const char *);
-int ConfYamlLoadString(const char *, size_t);
-int ConfYamlLoadFileWithPrefix(const char *filename, const char *prefix);
-int ConfYamlHandleInclude(ConfNode *parent, const char *filename);
+int SCConfYamlLoadFile(const char *);
+int SCConfYamlLoadString(const char *, size_t);
+int SCConfYamlLoadFileWithPrefix(const char *filename, const char *prefix);
+int SCConfYamlHandleInclude(SCConfNode *parent, const char *filename);
-void ConfYamlRegisterTests(void);
+void SCConfYamlRegisterTests(void);
#endif /* !SURICATA_CONF_YAML_LOADER_H */
/** Maximum size of a complete domain name. */
#define NODE_NAME_MAX 1024
-static ConfNode *root = NULL;
-static ConfNode *root_backup = NULL;
+static SCConfNode *root = NULL;
+static SCConfNode *root_backup = NULL;
/**
* \brief Helper function to get a node, creating it if it does not
* \retval The existing configuration node if it exists, or a newly
* created node for the provided name. On error, NULL will be returned.
*/
-ConfNode *ConfNodeGetNodeOrCreate(ConfNode *parent, const char *name, int final)
+SCConfNode *SCConfNodeGetNodeOrCreate(SCConfNode *parent, const char *name, int final)
{
- ConfNode *node = NULL;
+ SCConfNode *node = NULL;
char node_name[NODE_NAME_MAX];
char *key;
char *next;
do {
if ((next = strchr(key, '.')) != NULL)
*next++ = '\0';
- if ((node = ConfNodeLookupChild(parent, key)) == NULL) {
- node = ConfNodeNew();
+ if ((node = SCConfNodeLookupChild(parent, key)) == NULL) {
+ node = SCConfNodeNew();
if (unlikely(node == NULL)) {
SCLogWarning("Failed to allocate memory for configuration.");
goto end;
}
node->name = SCStrdup(key);
if (unlikely(node->name == NULL)) {
- ConfNodeFree(node);
+ SCConfNodeFree(node);
node = NULL;
SCLogWarning("Failed to allocate memory for configuration.");
goto end;
}
/**
- * \brief Wrapper function for ConfNodeGetNodeOrCreate that operates
+ * \brief Wrapper function for SCConfNodeGetNodeOrCreate that operates
* on the current root node.
*/
-static ConfNode *ConfGetNodeOrCreate(const char *name, int final)
+static SCConfNode *SCConfGetNodeOrCreate(const char *name, int final)
{
- return ConfNodeGetNodeOrCreate(root, name, final);
+ return SCConfNodeGetNodeOrCreate(root, name, final);
}
/**
* \brief Initialize the configuration system.
*/
-void ConfInit(void)
+void SCConfInit(void)
{
if (root != NULL) {
SCLogDebug("already initialized");
return;
}
- root = ConfNodeNew();
+ root = SCConfNodeNew();
if (root == NULL) {
FatalError("ERROR: Failed to allocate memory for root configuration node, "
"aborting.");
*
* \retval An allocated configuration node on success, NULL on failure.
*/
-ConfNode *ConfNodeNew(void)
+SCConfNode *SCConfNodeNew(void)
{
- ConfNode *new;
+ SCConfNode *new;
new = SCCalloc(1, sizeof(*new));
if (unlikely(new == NULL)) {
}
/**
- * \brief Free a ConfNode and all of its children.
+ * \brief Free a SCConfNode and all of its children.
*
* \param node The configuration node to SCFree.
*/
-void ConfNodeFree(ConfNode *node)
+void SCConfNodeFree(SCConfNode *node)
{
- ConfNode *tmp;
+ SCConfNode *tmp;
while ((tmp = TAILQ_FIRST(&node->head))) {
TAILQ_REMOVE(&node->head, tmp, next);
- ConfNodeFree(tmp);
+ SCConfNodeFree(tmp);
}
if (node->name != NULL)
}
/**
- * \brief Get a ConfNode by name.
+ * \brief Get a SCConfNode by name.
*
* \param name The full name of the configuration node to lookup.
*
- * \retval A pointer to ConfNode is found or NULL if the configuration
+ * \retval A pointer to SCConfNode is found or NULL if the configuration
* node does not exist.
*/
-ConfNode *ConfGetNode(const char *name)
+SCConfNode *SCConfGetNode(const char *name)
{
- ConfNode *node = root;
+ SCConfNode *node = root;
char node_name[NODE_NAME_MAX];
char *key;
char *next;
do {
if ((next = strchr(key, '.')) != NULL)
*next++ = '\0';
- node = ConfNodeLookupChild(node, key);
+ node = SCConfNodeLookupChild(node, key);
key = next;
} while (next != NULL && node != NULL);
/**
* \brief Get the root configuration node.
*/
-ConfNode *ConfGetRootNode(void)
+SCConfNode *SCConfGetRootNode(void)
{
return root;
}
*
* \retval 1 if the value was set otherwise 0.
*/
-int ConfSet(const char *name, const char *val)
+int SCConfSet(const char *name, const char *val)
{
- ConfNode *node = ConfGetNodeOrCreate(name, 0);
+ SCConfNode *node = SCConfGetNodeOrCreate(name, 0);
if (node == NULL || node->final) {
return 0;
}
*
* \retval 1 if the value of set, otherwise 0.
*/
-int ConfSetFromString(const char *input, int final)
+int SCConfSetFromString(const char *input, int final)
{
int retval = 0;
char *name = SCStrdup(input), *val = NULL;
}
if (final) {
- if (!ConfSetFinal(name, val)) {
+ if (!SCConfSetFinal(name, val)) {
goto done;
}
}
else {
- if (!ConfSet(name, val)) {
+ if (!SCConfSet(name, val)) {
goto done;
}
}
*
* \retval 1 if the value was set otherwise 0.
*/
-int ConfSetFinal(const char *name, const char *val)
+int SCConfSetFinal(const char *name, const char *val)
{
- ConfNode *node = ConfGetNodeOrCreate(name, 1);
+ SCConfNode *node = SCConfGetNodeOrCreate(name, 1);
if (node == NULL) {
return 0;
}
* on the full name of the node. It is possible that the value
* returned could be NULL, this could happen if the requested node
* does exist but is not a node that contains a value, but contains
- * children ConfNodes instead.
+ * children SCConfNodes instead.
*
* \param name Name of configuration parameter to get.
* \param vptr Pointer that will be set to the configuration value parameter.
* \retval 1 will be returned if the name is found, otherwise 0 will
* be returned.
*/
-int ConfGet(const char *name, const char **vptr)
+int SCConfGet(const char *name, const char **vptr)
{
- ConfNode *node = ConfGetNode(name);
+ SCConfNode *node = SCConfGetNode(name);
if (node == NULL) {
SCLogDebug("failed to lookup configuration parameter '%s'", name);
return 0;
}
}
-int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr)
+int SCConfGetChildValue(const SCConfNode *base, const char *name, const char **vptr)
{
- ConfNode *node = ConfNodeLookupChild(base, name);
+ SCConfNode *node = SCConfNodeLookupChild(base, name);
if (node == NULL) {
SCLogDebug("failed to lookup configuration parameter '%s'", name);
}
}
-ConfNode *ConfGetChildWithDefault(const ConfNode *base, const ConfNode *dflt,
- const char *name)
+SCConfNode *SCConfGetChildWithDefault(
+ const SCConfNode *base, const SCConfNode *dflt, const char *name)
{
- ConfNode *node = ConfNodeLookupChild(base, name);
+ SCConfNode *node = SCConfNodeLookupChild(base, name);
if (node != NULL)
return node;
/* Get 'default' value */
if (dflt) {
- return ConfNodeLookupChild(dflt, name);
+ return SCConfNodeLookupChild(dflt, name);
}
return NULL;
}
-int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt,
- const char *name, const char **vptr)
+int SCConfGetChildValueWithDefault(
+ const SCConfNode *base, const SCConfNode *dflt, const char *name, const char **vptr)
{
- int ret = ConfGetChildValue(base, name, vptr);
+ int ret = SCConfGetChildValue(base, name, vptr);
/* Get 'default' value */
if (ret == 0 && dflt) {
- return ConfGetChildValue(dflt, name, vptr);
+ return SCConfGetChildValue(dflt, name, vptr);
}
return ret;
}
* \retval 1 will be returned if the name is found and was properly
* converted to an integer, otherwise 0 will be returned.
*/
-int ConfGetInt(const char *name, intmax_t *val)
+int SCConfGetInt(const char *name, intmax_t *val)
{
const char *strval = NULL;
intmax_t tmpint;
char *endptr;
- if (ConfGet(name, &strval) == 0)
+ if (SCConfGet(name, &strval) == 0)
return 0;
if (strval == NULL) {
return 1;
}
-int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val)
+int SCConfGetChildValueInt(const SCConfNode *base, const char *name, intmax_t *val)
{
const char *strval = NULL;
intmax_t tmpint;
char *endptr;
- if (ConfGetChildValue(base, name, &strval) == 0)
+ if (SCConfGetChildValue(base, name, &strval) == 0)
return 0;
errno = 0;
tmpint = strtoimax(strval, &endptr, 0);
return 1;
}
-int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt,
- const char *name, intmax_t *val)
+int SCConfGetChildValueIntWithDefault(
+ const SCConfNode *base, const SCConfNode *dflt, const char *name, intmax_t *val)
{
- int ret = ConfGetChildValueInt(base, name, val);
+ int ret = SCConfGetChildValueInt(base, name, val);
/* Get 'default' value */
if (ret == 0 && dflt) {
- return ConfGetChildValueInt(dflt, name, val);
+ return SCConfGetChildValueInt(dflt, name, val);
}
return ret;
}
* \retval 1 will be returned if the name is found and was properly
* converted to a boolean, otherwise 0 will be returned.
*/
-int ConfGetBool(const char *name, int *val)
+int SCConfGetBool(const char *name, int *val)
{
const char *strval = NULL;
*val = 0;
- if (ConfGet(name, &strval) != 1)
+ if (SCConfGet(name, &strval) != 1)
return 0;
- *val = ConfValIsTrue(strval);
+ *val = SCConfValIsTrue(strval);
return 1;
}
/**
- * Get a boolean value from the provided ConfNode.
+ * Get a boolean value from the provided SCConfNode.
*
* \retval 1 If the value exists, 0 if not.
*/
-int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val)
+int SCConfGetChildValueBool(const SCConfNode *base, const char *name, int *val)
{
const char *strval = NULL;
*val = 0;
- if (ConfGetChildValue(base, name, &strval) == 0)
+ if (SCConfGetChildValue(base, name, &strval) == 0)
return 0;
- *val = ConfValIsTrue(strval);
+ *val = SCConfValIsTrue(strval);
return 1;
}
-int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt,
- const char *name, int *val)
+int SCConfGetChildValueBoolWithDefault(
+ const SCConfNode *base, const SCConfNode *dflt, const char *name, int *val)
{
- int ret = ConfGetChildValueBool(base, name, val);
+ int ret = SCConfGetChildValueBool(base, name, val);
/* Get 'default' value */
if (ret == 0 && dflt) {
- return ConfGetChildValueBool(dflt, name, val);
+ return SCConfGetChildValueBool(dflt, name, val);
}
return ret;
}
*
* \retval 1 If the value is true, 0 if not.
*/
-int ConfValIsTrue(const char *val)
+int SCConfValIsTrue(const char *val)
{
const char *trues[] = {"1", "yes", "true", "on"};
size_t u;
*
* \retval 1 If the value is false, 0 if not.
*/
-int ConfValIsFalse(const char *val)
+int SCConfValIsFalse(const char *val)
{
const char *falses[] = {"0", "no", "false", "off"};
size_t u;
* \retval 1 will be returned if the name is found and was properly
* converted to a double, otherwise 0 will be returned.
*/
-int ConfGetDouble(const char *name, double *val)
+int SCConfGetDouble(const char *name, double *val)
{
const char *strval = NULL;
double tmpdo;
char *endptr;
- if (ConfGet(name, &strval) == 0)
+ if (SCConfGet(name, &strval) == 0)
return 0;
errno = 0;
* \retval 1 will be returned if the name is found and was properly
* converted to a double, otherwise 0 will be returned.
*/
-int ConfGetFloat(const char *name, float *val)
+int SCConfGetFloat(const char *name, float *val)
{
const char *strval = NULL;
double tmpfl;
char *endptr;
- if (ConfGet(name, &strval) == 0)
+ if (SCConfGet(name, &strval) == 0)
return 0;
errno = 0;
/**
* \brief Remove (and SCFree) the provided configuration node.
*/
-void ConfNodeRemove(ConfNode *node)
+void SCConfNodeRemove(SCConfNode *node)
{
if (node->parent != NULL)
TAILQ_REMOVE(&node->parent->head, node, next);
- ConfNodeFree(node);
+ SCConfNodeFree(node);
}
/**
* \retval Returns 1 if the parameter was removed, otherwise 0 is returned
* most likely indicating the parameter was not set.
*/
-int ConfRemove(const char *name)
+int SCConfRemove(const char *name)
{
- ConfNode *node;
+ SCConfNode *node;
- node = ConfGetNode(name);
+ node = SCConfGetNode(name);
if (node == NULL)
return 0;
else {
- ConfNodeRemove(node);
+ SCConfNodeRemove(node);
return 1;
}
}
/**
* \brief Creates a backup of the conf_hash hash_table used by the conf API.
*/
-void ConfCreateContextBackup(void)
+void SCConfCreateContextBackup(void)
{
root_backup = root;
root = NULL;
* \brief Restores the backup of the hash_table present in backup_conf_hash
* back to conf_hash.
*/
-void ConfRestoreContextBackup(void)
+void SCConfRestoreContextBackup(void)
{
root = root_backup;
root_backup = NULL;
/**
* \brief De-initializes the configuration system.
*/
-void ConfDeInit(void)
+void SCConfDeInit(void)
{
if (root != NULL) {
- ConfNodeFree(root);
+ SCConfNodeFree(root);
root = NULL;
}
/**
* \brief Dump a configuration node and all its children.
*/
-void ConfNodeDump(const ConfNode *node, const char *prefix)
+void SCConfNodeDump(const SCConfNode *node, const char *prefix)
{
- ConfNode *child;
+ SCConfNode *child;
static char *name[128];
static int level = -1;
printf("%s.%s = %s\n", prefix,
ConfPrintNameArray(name, level), child->val);
}
- ConfNodeDump(child, prefix);
+ SCConfNodeDump(child, prefix);
SCFree(name[level]);
}
level--;
/**
* \brief Dump configuration to stdout.
*/
-void ConfDump(void)
+void SCConfDump(void)
{
- ConfNodeDump(root, NULL);
+ SCConfNodeDump(root, NULL);
}
/**
* \retval true if node has children
* \retval false if node does not have children
*/
-bool ConfNodeHasChildren(const ConfNode *node)
+bool SCConfNodeHasChildren(const SCConfNode *node)
{
if (TAILQ_EMPTY(&node->head)) {
return false;
/**
* \brief Lookup a child configuration node by name.
*
- * Given a ConfNode this function will lookup an immediate child
- * ConfNode by name and return the child ConfNode.
+ * Given a SCConfNode this function will lookup an immediate child
+ * SCConfNode by name and return the child ConfNode.
*
* \param node The parent configuration node.
* \param name The name of the child node to lookup.
*
- * \retval A pointer the child ConfNode if found otherwise NULL.
+ * \retval A pointer the child SCConfNode if found otherwise NULL.
*/
-ConfNode *ConfNodeLookupChild(const ConfNode *node, const char *name)
+SCConfNode *SCConfNodeLookupChild(const SCConfNode *node, const char *name)
{
- ConfNode *child;
+ SCConfNode *child;
if (node == NULL || name == NULL) {
return NULL;
/**
* \brief Lookup the value of a child configuration node by name.
*
- * Given a parent ConfNode this function will return the value of a
+ * Given a parent SCConfNode this function will return the value of a
* child configuration node by name returning a reference to that
* value.
*
* \param node The parent configuration node.
* \param name The name of the child node to lookup.
*
- * \retval A pointer the child ConfNodes value if found otherwise NULL.
+ * \retval A pointer the child SCConfNodes value if found otherwise NULL.
*/
-const char *ConfNodeLookupChildValue(const ConfNode *node, const char *name)
+const char *SCConfNodeLookupChildValue(const SCConfNode *node, const char *name)
{
- ConfNode *child;
+ SCConfNode *child;
- child = ConfNodeLookupChild(node, name);
+ child = SCConfNodeLookupChild(node, name);
if (child != NULL)
return child->val;
/**
* \brief Lookup for a key value under a specific node
*
- * \return the ConfNode matching or NULL
+ * \return the SCConfNode matching or NULL
*/
-ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key,
- const char *value)
+SCConfNode *SCConfNodeLookupKeyValue(const SCConfNode *base, const char *key, const char *value)
{
- ConfNode *child;
+ SCConfNode *child;
TAILQ_FOREACH(child, &base->head, next) {
if (!strncmp(child->val, key, strlen(child->val))) {
- ConfNode *subchild;
+ SCConfNode *subchild;
TAILQ_FOREACH(subchild, &child->head, next) {
if ((!strcmp(subchild->name, key)) && (!strcmp(subchild->val, value))) {
return child;
* \retval 1 if the child node has a true value, otherwise 0 is
* returned, even if the child node does not exist.
*/
-int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key)
+int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key)
{
const char *val;
- val = ConfNodeLookupChildValue(node, key);
+ val = SCConfNodeLookupChildValue(node, key);
- return val != NULL ? ConfValIsTrue(val) : 0;
+ return val != NULL ? SCConfValIsTrue(val) : 0;
}
/**
*
* \param node The configuration node to prune.
*/
-void ConfNodePrune(ConfNode *node)
+void SCConfNodePrune(SCConfNode *node)
{
- ConfNode *item, *it;
+ SCConfNode *item, *it;
for (item = TAILQ_FIRST(&node->head); item != NULL; item = it) {
it = TAILQ_NEXT(item, next);
if (!item->final) {
- ConfNodePrune(item);
+ SCConfNodePrune(item);
if (TAILQ_EMPTY(&item->head)) {
TAILQ_REMOVE(&node->head, item, next);
if (item->name != NULL)
*
* \return 1 if node is a sequence, otherwise 0.
*/
-int ConfNodeIsSequence(const ConfNode *node)
+int SCConfNodeIsSequence(const SCConfNode *node)
{
return node->is_seq == 0 ? 0 : 1;
}
* @param iface - interfaces name
* @return NULL on failure otherwise a valid pointer
*/
-ConfNode *ConfSetIfaceNode(const char *ifaces_node_name, const char *iface)
+SCConfNode *SCConfSetIfaceNode(const char *ifaces_node_name, const char *iface)
{
- ConfNode *if_node;
- ConfNode *ifaces_list_node;
+ SCConfNode *if_node;
+ SCConfNode *ifaces_list_node;
/* Find initial node which holds all interfaces */
- ifaces_list_node = ConfGetNode(ifaces_node_name);
+ ifaces_list_node = SCConfGetNode(ifaces_node_name);
if (ifaces_list_node == NULL) {
SCLogError("unable to find %s config", ifaces_node_name);
return NULL;
* @param if_default Node which is the default configuration in the given list of interfaces
* @return 0 on success, -ENODEV when neither the root interface nor the default interface was found
*/
-int ConfSetRootAndDefaultNodes(
- const char *ifaces_node_name, const char *iface, ConfNode **if_root, ConfNode **if_default)
+int SCConfSetRootAndDefaultNodes(const char *ifaces_node_name, const char *iface,
+ SCConfNode **if_root, SCConfNode **if_default)
{
const char *default_iface = "default";
- *if_root = ConfSetIfaceNode(ifaces_node_name, iface);
- *if_default = ConfSetIfaceNode(ifaces_node_name, default_iface);
+ *if_root = SCConfSetIfaceNode(ifaces_node_name, iface);
+ *if_default = SCConfSetIfaceNode(ifaces_node_name, default_iface);
if (*if_root == NULL && *if_default == NULL) {
SCLogError("unable to find configuration for the interface \"%s\" or the default "
char name[] = "non-existant-value";
const char *value;
- FAIL_IF(ConfGet(name, &value));
+ FAIL_IF(SCConfGet(name, &value));
PASS;
}
char value[] = "some-value";
const char *value0 = NULL;
- FAIL_IF(ConfSet(name, value) != 1);
- FAIL_IF(ConfGet(name, &value0) != 1);
+ FAIL_IF(SCConfSet(name, value) != 1);
+ FAIL_IF(SCConfGet(name, &value0) != 1);
FAIL_IF(value0 == NULL);
FAIL_IF(strcmp(value, value0) != 0);
/* Cleanup. */
- ConfRemove(name);
+ SCConfRemove(name);
PASS;
}
char value1[] = "new-value";
const char *val = NULL;
- FAIL_IF(ConfSet(name, value0) != 1);
- FAIL_IF(ConfSet(name, value1) != 1);
- FAIL_IF(ConfGet(name, &val) != 1);
+ FAIL_IF(SCConfSet(name, value0) != 1);
+ FAIL_IF(SCConfSet(name, value1) != 1);
+ FAIL_IF(SCConfGet(name, &val) != 1);
FAIL_IF(val == NULL);
FAIL_IF(strcmp(val, value1) != 0);
/* Cleanup. */
- ConfRemove(name);
+ SCConfRemove(name);
PASS;
}
char value1[] = "new-value";
const char *val = NULL;
- FAIL_IF(ConfSetFinal(name, value0) != 1);
- FAIL_IF(ConfSet(name, value1) != 0);
- FAIL_IF(ConfGet(name, &val) != 1);
+ FAIL_IF(SCConfSetFinal(name, value0) != 1);
+ FAIL_IF(SCConfSet(name, value1) != 0);
+ FAIL_IF(SCConfGet(name, &val) != 1);
FAIL_IF(val == NULL);
FAIL_IF(strcmp(val, value0) != 0);
/* Cleanup. */
- ConfRemove(name);
+ SCConfRemove(name);
PASS;
}
char name[] = "some-int.x";
intmax_t val;
- FAIL_IF(ConfSet(name, "0") != 1);
- FAIL_IF(ConfGetInt(name, &val) != 1);
+ FAIL_IF(SCConfSet(name, "0") != 1);
+ FAIL_IF(SCConfGetInt(name, &val) != 1);
FAIL_IF(val != 0);
- FAIL_IF(ConfSet(name, "-1") != 1);
- FAIL_IF(ConfGetInt(name, &val) != 1);
+ FAIL_IF(SCConfSet(name, "-1") != 1);
+ FAIL_IF(SCConfGetInt(name, &val) != 1);
FAIL_IF(val != -1);
- FAIL_IF(ConfSet(name, "0xffff") != 1);
- FAIL_IF(ConfGetInt(name, &val) != 1);
+ FAIL_IF(SCConfSet(name, "0xffff") != 1);
+ FAIL_IF(SCConfGetInt(name, &val) != 1);
FAIL_IF(val != 0xffff);
- FAIL_IF(ConfSet(name, "not-an-int") != 1);
- FAIL_IF(ConfGetInt(name, &val) != 0);
+ FAIL_IF(SCConfSet(name, "not-an-int") != 1);
+ FAIL_IF(SCConfGetInt(name, &val) != 0);
PASS;
}
size_t u;
for (u = 0; u < sizeof(trues) / sizeof(trues[0]); u++) {
- FAIL_IF(ConfSet(name, trues[u]) != 1);
- FAIL_IF(ConfGetBool(name, &val) != 1);
+ FAIL_IF(SCConfSet(name, trues[u]) != 1);
+ FAIL_IF(SCConfGetBool(name, &val) != 1);
FAIL_IF(val != 1);
}
for (u = 0; u < sizeof(falses) / sizeof(falses[0]); u++) {
- FAIL_IF(ConfSet(name, falses[u]) != 1);
- FAIL_IF(ConfGetBool(name, &val) != 1);
+ FAIL_IF(SCConfSet(name, falses[u]) != 1);
+ FAIL_IF(SCConfGetBool(name, &val) != 1);
FAIL_IF(val != 0);
}
const char *test_vals[] = { "one", "two", "three" };
size_t u;
- ConfNode *parent = ConfNodeNew();
- ConfNode *child;
+ SCConfNode *parent = SCConfNodeNew();
+ SCConfNode *child;
for (u = 0; u < sizeof(test_vals)/sizeof(test_vals[0]); u++) {
- child = ConfNodeNew();
+ child = SCConfNodeNew();
child->name = SCStrdup(test_vals[u]);
child->val = SCStrdup(test_vals[u]);
TAILQ_INSERT_TAIL(&parent->head, child, next);
}
- child = ConfNodeLookupChild(parent, "one");
+ child = SCConfNodeLookupChild(parent, "one");
FAIL_IF(child == NULL);
FAIL_IF(strcmp(child->name, "one") != 0);
FAIL_IF(strcmp(child->val, "one") != 0);
- child = ConfNodeLookupChild(parent, "two");
+ child = SCConfNodeLookupChild(parent, "two");
FAIL_IF(child == NULL);
FAIL_IF(strcmp(child->name, "two") != 0);
FAIL_IF(strcmp(child->val, "two") != 0);
- child = ConfNodeLookupChild(parent, "three");
+ child = SCConfNodeLookupChild(parent, "three");
FAIL_IF(child == NULL);
FAIL_IF(strcmp(child->name, "three") != 0);
FAIL_IF(strcmp(child->val, "three") != 0);
- child = ConfNodeLookupChild(parent, "four");
+ child = SCConfNodeLookupChild(parent, "four");
FAIL_IF(child != NULL);
- FAIL_IF(ConfNodeLookupChild(NULL, NULL) != NULL);
+ FAIL_IF(SCConfNodeLookupChild(NULL, NULL) != NULL);
if (parent != NULL) {
- ConfNodeFree(parent);
+ SCConfNodeFree(parent);
}
PASS;
const char *test_vals[] = { "one", "two", "three" };
size_t u;
- ConfNode *parent = ConfNodeNew();
- ConfNode *child;
+ SCConfNode *parent = SCConfNodeNew();
+ SCConfNode *child;
const char *value;
for (u = 0; u < sizeof(test_vals)/sizeof(test_vals[0]); u++) {
- child = ConfNodeNew();
+ child = SCConfNodeNew();
child->name = SCStrdup(test_vals[u]);
child->val = SCStrdup(test_vals[u]);
TAILQ_INSERT_TAIL(&parent->head, child, next);
}
- value = (char *)ConfNodeLookupChildValue(parent, "one");
+ value = (char *)SCConfNodeLookupChildValue(parent, "one");
FAIL_IF(value == NULL);
FAIL_IF(strcmp(value, "one") != 0);
- value = (char *)ConfNodeLookupChildValue(parent, "two");
+ value = (char *)SCConfNodeLookupChildValue(parent, "two");
FAIL_IF(value == NULL);
FAIL_IF(strcmp(value, "two") != 0);
- value = (char *)ConfNodeLookupChildValue(parent, "three");
+ value = (char *)SCConfNodeLookupChildValue(parent, "three");
FAIL_IF(value == NULL);
FAIL_IF(strcmp(value, "three") != 0);
- value = (char *)ConfNodeLookupChildValue(parent, "four");
+ value = (char *)SCConfNodeLookupChildValue(parent, "four");
FAIL_IF(value != NULL);
- ConfNodeFree(parent);
+ SCConfNodeFree(parent);
PASS;
}
static int ConfGetChildValueWithDefaultTest(void)
{
const char *val = "";
- ConfCreateContextBackup();
- ConfInit();
- ConfSet("af-packet.0.interface", "eth0");
- ConfSet("af-packet.1.interface", "default");
- ConfSet("af-packet.1.cluster-type", "cluster_cpu");
-
- ConfNode *myroot = ConfGetNode("af-packet.0");
- ConfNode *dflt = ConfGetNode("af-packet.1");
- ConfGetChildValueWithDefault(myroot, dflt, "cluster-type", &val);
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfSet("af-packet.0.interface", "eth0");
+ SCConfSet("af-packet.1.interface", "default");
+ SCConfSet("af-packet.1.cluster-type", "cluster_cpu");
+
+ SCConfNode *myroot = SCConfGetNode("af-packet.0");
+ SCConfNode *dflt = SCConfGetNode("af-packet.1");
+ SCConfGetChildValueWithDefault(myroot, dflt, "cluster-type", &val);
FAIL_IF(strcmp(val, "cluster_cpu"));
- ConfSet("af-packet.0.cluster-type", "cluster_flow");
- ConfGetChildValueWithDefault(myroot, dflt, "cluster-type", &val);
+ SCConfSet("af-packet.0.cluster-type", "cluster_flow");
+ SCConfGetChildValueWithDefault(myroot, dflt, "cluster-type", &val);
FAIL_IF(strcmp(val, "cluster_flow"));
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int ConfGetChildValueIntWithDefaultTest(void)
{
intmax_t val = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfSet("af-packet.0.interface", "eth0");
- ConfSet("af-packet.1.interface", "default");
- ConfSet("af-packet.1.threads", "2");
-
- ConfNode *myroot = ConfGetNode("af-packet.0");
- ConfNode *dflt = ConfGetNode("af-packet.1");
- ConfGetChildValueIntWithDefault(myroot, dflt, "threads", &val);
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfSet("af-packet.0.interface", "eth0");
+ SCConfSet("af-packet.1.interface", "default");
+ SCConfSet("af-packet.1.threads", "2");
+
+ SCConfNode *myroot = SCConfGetNode("af-packet.0");
+ SCConfNode *dflt = SCConfGetNode("af-packet.1");
+ SCConfGetChildValueIntWithDefault(myroot, dflt, "threads", &val);
FAIL_IF(val != 2);
- ConfSet("af-packet.0.threads", "1");
- ConfGetChildValueIntWithDefault(myroot, dflt, "threads", &val);
+ SCConfSet("af-packet.0.threads", "1");
+ SCConfGetChildValueIntWithDefault(myroot, dflt, "threads", &val);
FAIL_IF(val != 1);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int ConfGetChildValueBoolWithDefaultTest(void)
{
int val;
- ConfCreateContextBackup();
- ConfInit();
- ConfSet("af-packet.0.interface", "eth0");
- ConfSet("af-packet.1.interface", "default");
- ConfSet("af-packet.1.use-mmap", "yes");
-
- ConfNode *myroot = ConfGetNode("af-packet.0");
- ConfNode *dflt = ConfGetNode("af-packet.1");
- ConfGetChildValueBoolWithDefault(myroot, dflt, "use-mmap", &val);
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfSet("af-packet.0.interface", "eth0");
+ SCConfSet("af-packet.1.interface", "default");
+ SCConfSet("af-packet.1.use-mmap", "yes");
+
+ SCConfNode *myroot = SCConfGetNode("af-packet.0");
+ SCConfNode *dflt = SCConfGetNode("af-packet.1");
+ SCConfGetChildValueBoolWithDefault(myroot, dflt, "use-mmap", &val);
FAIL_IF(val == 0);
- ConfSet("af-packet.0.use-mmap", "no");
- ConfGetChildValueBoolWithDefault(myroot, dflt, "use-mmap", &val);
+ SCConfSet("af-packet.0.use-mmap", "no");
+ SCConfGetChildValueBoolWithDefault(myroot, dflt, "use-mmap", &val);
FAIL_IF(val);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
*/
static int ConfNodeRemoveTest(void)
{
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- FAIL_IF(ConfSet("some.nested.parameter", "blah") != 1);
+ FAIL_IF(SCConfSet("some.nested.parameter", "blah") != 1);
- ConfNode *node = ConfGetNode("some.nested.parameter");
+ SCConfNode *node = SCConfGetNode("some.nested.parameter");
FAIL_IF(node == NULL);
- ConfNodeRemove(node);
+ SCConfNodeRemove(node);
- node = ConfGetNode("some.nested.parameter");
+ node = SCConfGetNode("some.nested.parameter");
FAIL_IF(node != NULL);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int ConfSetTest(void)
{
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
/* Set some value with 2 levels. */
- FAIL_IF(ConfSet("one.two", "three") != 1);
- ConfNode *n = ConfGetNode("one.two");
+ FAIL_IF(SCConfSet("one.two", "three") != 1);
+ SCConfNode *n = SCConfGetNode("one.two");
FAIL_IF(n == NULL);
/* Set another 2 level parameter with the same first level, this
* used to trigger a bug that caused the second level of the name
* to become a first level node. */
- FAIL_IF(ConfSet("one.three", "four") != 1);
+ FAIL_IF(SCConfSet("one.three", "four") != 1);
- n = ConfGetNode("one.three");
+ n = SCConfGetNode("one.three");
FAIL_IF(n == NULL);
/* A top level node of "three" should not exist. */
- n = ConfGetNode("three");
+ n = SCConfGetNode("three");
FAIL_IF(n != NULL);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int ConfGetNodeOrCreateTest(void)
{
- ConfNode *node;
+ SCConfNode *node;
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
/* Get a node that should not exist, give it a value, re-get it
* and make sure the second time it returns the existing node. */
- node = ConfGetNodeOrCreate("node0", 0);
+ node = SCConfGetNodeOrCreate("node0", 0);
FAIL_IF(node == NULL);
FAIL_IF(node->parent == NULL || node->parent != root);
FAIL_IF(node->val != NULL);
node->val = SCStrdup("node0");
- node = ConfGetNodeOrCreate("node0", 0);
+ node = SCConfGetNodeOrCreate("node0", 0);
FAIL_IF(node == NULL);
FAIL_IF(node->val == NULL);
FAIL_IF(strcmp(node->val, "node0") != 0);
/* Do the same, but for something deeply nested. */
- node = ConfGetNodeOrCreate("parent.child.grandchild", 0);
+ node = SCConfGetNodeOrCreate("parent.child.grandchild", 0);
FAIL_IF(node == NULL);
FAIL_IF(node->parent == NULL || node->parent == root);
FAIL_IF(node->val != NULL);
node->val = SCStrdup("parent.child.grandchild");
- node = ConfGetNodeOrCreate("parent.child.grandchild", 0);
+ node = SCConfGetNodeOrCreate("parent.child.grandchild", 0);
FAIL_IF(node == NULL);
FAIL_IF(node->val == NULL);
FAIL_IF(strcmp(node->val, "parent.child.grandchild") != 0);
/* Test that 2 child nodes have the same root. */
- ConfNode *child1 = ConfGetNodeOrCreate("parent.kids.child1", 0);
- ConfNode *child2 = ConfGetNodeOrCreate("parent.kids.child2", 0);
+ SCConfNode *child1 = SCConfGetNodeOrCreate("parent.kids.child1", 0);
+ SCConfNode *child2 = SCConfGetNodeOrCreate("parent.kids.child2", 0);
FAIL_IF(child1 == NULL || child2 == NULL);
FAIL_IF(child1->parent != child2->parent);
FAIL_IF(strcmp(child1->parent->name, "kids") != 0);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int ConfNodePruneTest(void)
{
- ConfNode *node;
+ SCConfNode *node;
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
/* Test that final nodes exist after a prune. */
- FAIL_IF(ConfSet("node.notfinal", "notfinal") != 1);
- FAIL_IF(ConfSetFinal("node.final", "final") != 1);
- FAIL_IF(ConfGetNode("node.notfinal") == NULL);
- FAIL_IF(ConfGetNode("node.final") == NULL);
- FAIL_IF((node = ConfGetNode("node")) == NULL);
- ConfNodePrune(node);
- FAIL_IF(ConfGetNode("node.notfinal") != NULL);
- FAIL_IF(ConfGetNode("node.final") == NULL);
+ FAIL_IF(SCConfSet("node.notfinal", "notfinal") != 1);
+ FAIL_IF(SCConfSetFinal("node.final", "final") != 1);
+ FAIL_IF(SCConfGetNode("node.notfinal") == NULL);
+ FAIL_IF(SCConfGetNode("node.final") == NULL);
+ FAIL_IF((node = SCConfGetNode("node")) == NULL);
+ SCConfNodePrune(node);
+ FAIL_IF(SCConfGetNode("node.notfinal") != NULL);
+ FAIL_IF(SCConfGetNode("node.final") == NULL);
/* Test that everything under a final node exists after a prune. */
- FAIL_IF(ConfSet("node.final.one", "one") != 1);
- FAIL_IF(ConfSet("node.final.two", "two") != 1);
- ConfNodePrune(node);
- FAIL_IF(ConfNodeLookupChild(node, "final") == NULL);
- FAIL_IF(ConfGetNode("node.final.one") == NULL);
- FAIL_IF(ConfGetNode("node.final.two") == NULL);
+ FAIL_IF(SCConfSet("node.final.one", "one") != 1);
+ FAIL_IF(SCConfSet("node.final.two", "two") != 1);
+ SCConfNodePrune(node);
+ FAIL_IF(SCConfNodeLookupChild(node, "final") == NULL);
+ FAIL_IF(SCConfGetNode("node.final.one") == NULL);
+ FAIL_IF(SCConfGetNode("node.final.two") == NULL);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int ConfNodeIsSequenceTest(void)
{
- ConfNode *node = ConfNodeNew();
+ SCConfNode *node = SCConfNodeNew();
FAIL_IF(node == NULL);
- FAIL_IF(ConfNodeIsSequence(node));
+ FAIL_IF(SCConfNodeIsSequence(node));
node->is_seq = 1;
- FAIL_IF(!ConfNodeIsSequence(node));
+ FAIL_IF(!SCConfNodeIsSequence(node));
if (node != NULL) {
- ConfNodeFree(node);
+ SCConfNodeFree(node);
}
PASS;
}
static int ConfSetFromStringTest(void)
{
- ConfNode *n;
+ SCConfNode *n;
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
- FAIL_IF_NOT(ConfSetFromString("stream.midstream=true", 0));
- n = ConfGetNode("stream.midstream");
+ FAIL_IF_NOT(SCConfSetFromString("stream.midstream=true", 0));
+ n = SCConfGetNode("stream.midstream");
FAIL_IF_NULL(n);
FAIL_IF_NULL(n->val);
FAIL_IF(strcmp("true", n->val));
- FAIL_IF_NOT(ConfSetFromString("stream.midstream =false", 0));
- n = ConfGetNode("stream.midstream");
+ FAIL_IF_NOT(SCConfSetFromString("stream.midstream =false", 0));
+ n = SCConfGetNode("stream.midstream");
FAIL_IF_NULL(n);
FAIL_IF(n->val == NULL || strcmp("false", n->val));
- FAIL_IF_NOT(ConfSetFromString("stream.midstream= true", 0));
- n = ConfGetNode("stream.midstream");
+ FAIL_IF_NOT(SCConfSetFromString("stream.midstream= true", 0));
+ n = SCConfGetNode("stream.midstream");
FAIL_IF_NULL(n);
FAIL_IF(n->val == NULL || strcmp("true", n->val));
- FAIL_IF_NOT(ConfSetFromString("stream.midstream = false", 0));
- n = ConfGetNode("stream.midstream");
+ FAIL_IF_NOT(SCConfSetFromString("stream.midstream = false", 0));
+ n = SCConfGetNode("stream.midstream");
FAIL_IF_NULL(n);
FAIL_IF(n->val == NULL || strcmp("false", n->val));
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
static int ConfNodeHasChildrenTest(void)
{
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
/* Set a plain key with value. */
- ConfSet("no-children", "value");
- ConfNode *n = ConfGetNode("no-children");
+ SCConfSet("no-children", "value");
+ SCConfNode *n = SCConfGetNode("no-children");
FAIL_IF_NULL(n);
- FAIL_IF(ConfNodeHasChildren(n));
+ FAIL_IF(SCConfNodeHasChildren(n));
/* Set a key with a sub key to a value. This makes the first key a
* map. */
- ConfSet("parent.child", "value");
- n = ConfGetNode("parent");
+ SCConfSet("parent.child", "value");
+ n = SCConfGetNode("parent");
FAIL_IF_NULL(n);
- FAIL_IF(!ConfNodeHasChildren(n));
+ FAIL_IF(!SCConfNodeHasChildren(n));
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
-void ConfRegisterTests(void)
+void SCConfRegisterTests(void)
{
UtRegisterTest("ConfTestGetNonExistant", ConfTestGetNonExistant);
UtRegisterTest("ConfSetTest", ConfSetTest);
/**
* Structure of a configuration parameter.
*/
-typedef struct ConfNode_ {
+typedef struct SCConfNode_ {
char *name;
char *val;
/**< Flag that sets this nodes value as final. */
int final;
- struct ConfNode_ *parent;
- TAILQ_HEAD(, ConfNode_) head;
- TAILQ_ENTRY(ConfNode_) next;
-} ConfNode;
-
+ struct SCConfNode_ *parent;
+ TAILQ_HEAD(, SCConfNode_) head;
+ TAILQ_ENTRY(SCConfNode_) next;
+} SCConfNode;
/**
* The default log directory.
#define DEFAULT_DATA_DIR DATA_DIR
#endif /* OS_WIN32 */
-void ConfInit(void);
-void ConfDeInit(void);
-ConfNode *ConfGetRootNode(void);
-int ConfGet(const char *name, const char **vptr);
-int ConfGetInt(const char *name, intmax_t *val);
-int ConfGetBool(const char *name, int *val);
-int ConfGetDouble(const char *name, double *val);
-int ConfGetFloat(const char *name, float *val);
-int ConfSet(const char *name, const char *val);
-int ConfSetFromString(const char *input, int final);
-int ConfSetFinal(const char *name, const char *val);
-void ConfDump(void);
-void ConfNodeDump(const ConfNode *node, const char *prefix);
-ConfNode *ConfNodeNew(void);
-void ConfNodeFree(ConfNode *);
-ConfNode *ConfGetNode(const char *key);
-void ConfCreateContextBackup(void);
-void ConfRestoreContextBackup(void);
-ConfNode *ConfNodeLookupChild(const ConfNode *node, const char *key);
-const char *ConfNodeLookupChildValue(const ConfNode *node, const char *key);
-void ConfNodeRemove(ConfNode *);
-void ConfRegisterTests(void);
-int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key);
-int ConfValIsTrue(const char *val);
-int ConfValIsFalse(const char *val);
-void ConfNodePrune(ConfNode *node);
-int ConfRemove(const char *name);
-bool ConfNodeHasChildren(const ConfNode *node);
+void SCConfInit(void);
+void SCConfDeInit(void);
+SCConfNode *SCConfGetRootNode(void);
+int SCConfGet(const char *name, const char **vptr);
+int SCConfGetInt(const char *name, intmax_t *val);
+int SCConfGetBool(const char *name, int *val);
+int SCConfGetDouble(const char *name, double *val);
+int SCConfGetFloat(const char *name, float *val);
+int SCConfSet(const char *name, const char *val);
+int SCConfSetFromString(const char *input, int final);
+int SCConfSetFinal(const char *name, const char *val);
+void SCConfDump(void);
+void SCConfNodeDump(const SCConfNode *node, const char *prefix);
+SCConfNode *SCConfNodeNew(void);
+void SCConfNodeFree(SCConfNode *);
+SCConfNode *SCConfGetNode(const char *key);
+void SCConfCreateContextBackup(void);
+void SCConfRestoreContextBackup(void);
+SCConfNode *SCConfNodeLookupChild(const SCConfNode *node, const char *key);
+const char *SCConfNodeLookupChildValue(const SCConfNode *node, const char *key);
+void SCConfNodeRemove(SCConfNode *);
+void SCConfRegisterTests(void);
+int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key);
+int SCConfValIsTrue(const char *val);
+int SCConfValIsFalse(const char *val);
+void SCConfNodePrune(SCConfNode *node);
+int SCConfRemove(const char *name);
+bool SCConfNodeHasChildren(const SCConfNode *node);
-ConfNode *ConfGetChildWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name);
-ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value);
-int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr);
-int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val);
-int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val);
-int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, const char **vptr);
-int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, intmax_t *val);
-int ConfGetChildValueBoolWithDefault(
- const ConfNode *base, const ConfNode *dflt, const char *name, int *val);
-int ConfNodeIsSequence(const ConfNode *node);
-ConfNode *ConfSetIfaceNode(const char *ifaces_node_name, const char *iface);
-int ConfSetRootAndDefaultNodes(
- const char *ifaces_node_name, const char *iface, ConfNode **if_root, ConfNode **if_default);
-ConfNode *ConfNodeGetNodeOrCreate(ConfNode *parent, const char *name, int final);
+SCConfNode *SCConfGetChildWithDefault(
+ const SCConfNode *base, const SCConfNode *dflt, const char *name);
+SCConfNode *SCConfNodeLookupKeyValue(const SCConfNode *base, const char *key, const char *value);
+int SCConfGetChildValue(const SCConfNode *base, const char *name, const char **vptr);
+int SCConfGetChildValueInt(const SCConfNode *base, const char *name, intmax_t *val);
+int SCConfGetChildValueBool(const SCConfNode *base, const char *name, int *val);
+int SCConfGetChildValueWithDefault(
+ const SCConfNode *base, const SCConfNode *dflt, const char *name, const char **vptr);
+int SCConfGetChildValueIntWithDefault(
+ const SCConfNode *base, const SCConfNode *dflt, const char *name, intmax_t *val);
+int SCConfGetChildValueBoolWithDefault(
+ const SCConfNode *base, const SCConfNode *dflt, const char *name, int *val);
+int SCConfNodeIsSequence(const SCConfNode *node);
+SCConfNode *SCConfSetIfaceNode(const char *ifaces_node_name, const char *iface);
+int SCConfSetRootAndDefaultNodes(const char *ifaces_node_name, const char *iface,
+ SCConfNode **if_root, SCConfNode **if_default);
+SCConfNode *SCConfNodeGetNodeOrCreate(SCConfNode *parent, const char *name, int final);
#endif /* ! SURICATA_CONF_H */
pca->head[id].updates++;
}
-static ConfNode *GetConfig(void) {
- ConfNode *stats = ConfGetNode("stats");
+static SCConfNode *GetConfig(void)
+{
+ SCConfNode *stats = SCConfGetNode("stats");
if (stats != NULL)
return stats;
- ConfNode *root = ConfGetNode("outputs");
- ConfNode *node = NULL;
+ SCConfNode *root = SCConfGetNode("outputs");
+ SCConfNode *node = NULL;
if (root != NULL) {
TAILQ_FOREACH(node, &root->head, next) {
if (strcmp(node->val, "stats") == 0) {
static void StatsInitCtxPreOutput(void)
{
SCEnter();
- ConfNode *stats = GetConfig();
+ SCConfNode *stats = GetConfig();
if (stats != NULL) {
- const char *enabled = ConfNodeLookupChildValue(stats, "enabled");
- if (enabled != NULL && ConfValIsFalse(enabled)) {
+ const char *enabled = SCConfNodeLookupChildValue(stats, "enabled");
+ if (enabled != NULL && SCConfValIsFalse(enabled)) {
stats_enabled = false;
SCLogDebug("Stats module has been disabled");
SCReturn;
}
/* warn if we are using legacy config to enable stats */
- ConfNode *gstats = ConfGetNode("stats");
+ SCConfNode *gstats = SCConfGetNode("stats");
if (gstats == NULL) {
SCLogWarning("global stats config is missing. "
"Stats enabled through legacy stats.log. "
GetDocURL());
}
- const char *interval = ConfNodeLookupChildValue(stats, "interval");
+ const char *interval = SCConfNodeLookupChildValue(stats, "interval");
if (interval != NULL)
if (StringParseUint32(&stats_tts, 10, 0, interval) < 0) {
SCLogWarning("Invalid value for "
}
int b;
- int ret = ConfGetChildValueBool(stats, "decoder-events", &b);
+ int ret = SCConfGetChildValueBool(stats, "decoder-events", &b);
if (ret) {
stats_decoder_events = (b == 1);
}
- ret = ConfGetChildValueBool(stats, "stream-events", &b);
+ ret = SCConfGetChildValueBool(stats, "stream-events", &b);
if (ret) {
stats_stream_events = (b == 1);
}
const char *prefix = NULL;
- if (ConfGet("stats.decoder-events-prefix", &prefix) != 1) {
+ if (SCConfGet("stats.decoder-events-prefix", &prefix) != 1) {
prefix = "decoder.event";
}
stats_decoder_events_prefix = prefix;
static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize)
{
const char *str = NULL;
- if (ConfGet("datasets.defaults.memcap", &str) == 1) {
+ if (SCConfGet("datasets.defaults.memcap", &str) == 1) {
if (ParseSizeStringU64(str, memcap) < 0) {
SCLogWarning("memcap value cannot be deduced: %s,"
" resetting to default",
}
*hashsize = (uint32_t)DATASETS_HASHSIZE_DEFAULT;
- if (ConfGet("datasets.defaults.hashsize", &str) == 1) {
+ if (SCConfGet("datasets.defaults.hashsize", &str) == 1) {
if (ParseSizeStringU32(str, hashsize) < 0) {
*hashsize = (uint32_t)DATASETS_HASHSIZE_DEFAULT;
SCLogWarning("hashsize value cannot be deduced: %s,"
int DatasetsInit(void)
{
SCLogDebug("datasets start");
- ConfNode *datasets = ConfGetNode("datasets");
+ SCConfNode *datasets = SCConfGetNode("datasets");
uint64_t default_memcap = 0;
uint32_t default_hashsize = 0;
GetDefaultMemcap(&default_memcap, &default_hashsize);
if (datasets != NULL) {
const char *str = NULL;
- if (ConfGet("datasets.limits.total-hashsizes", &str) == 1) {
+ if (SCConfGet("datasets.limits.total-hashsizes", &str) == 1) {
if (ParseSizeStringU32(str, &dataset_max_total_hashsize) < 0) {
FatalError("failed to parse datasets.limits.total-hashsizes value: %s", str);
}
}
- if (ConfGet("datasets.limits.single-hashsize", &str) == 1) {
+ if (SCConfGet("datasets.limits.single-hashsize", &str) == 1) {
if (ParseSizeStringU32(str, &dataset_max_one_hashsize) < 0) {
FatalError("failed to parse datasets.limits.single-hashsize value: %s", str);
}
}
int list_pos = 0;
- ConfNode *iter = NULL;
+ SCConfNode *iter = NULL;
TAILQ_FOREACH(iter, &datasets->head, next) {
if (iter->name == NULL) {
list_pos++;
continue;
}
- ConfNode *set_type =
- ConfNodeLookupChild(iter, "type");
+ SCConfNode *set_type = SCConfNodeLookupChild(iter, "type");
if (set_type == NULL) {
list_pos++;
continue;
}
- ConfNode *set_save =
- ConfNodeLookupChild(iter, "state");
+ SCConfNode *set_save = SCConfNodeLookupChild(iter, "state");
if (set_save) {
DatasetGetPath(set_save->val, save, sizeof(save), TYPE_STATE);
strlcpy(load, save, sizeof(load));
} else {
- ConfNode *set_load =
- ConfNodeLookupChild(iter, "load");
+ SCConfNode *set_load = SCConfNodeLookupChild(iter, "load");
if (set_load) {
DatasetGetPath(set_load->val, load, sizeof(load), TYPE_LOAD);
}
}
- ConfNode *set_memcap = ConfNodeLookupChild(iter, "memcap");
+ SCConfNode *set_memcap = SCConfNodeLookupChild(iter, "memcap");
if (set_memcap) {
if (ParseSizeStringU64(set_memcap->val, &memcap) < 0) {
SCLogWarning("memcap value cannot be"
memcap = 0;
}
}
- ConfNode *set_hashsize = ConfNodeLookupChild(iter, "hashsize");
+ SCConfNode *set_hashsize = SCConfNodeLookupChild(iter, "hashsize");
if (set_hashsize) {
if (ParseSizeStringU32(set_hashsize->val, &hashsize) < 0) {
SCLogWarning("hashsize value cannot be"
void DecodeERSPANConfig(void)
{
int enabled = 0;
- if (ConfGetBool("decoder.erspan.typeI.enabled", &enabled) == 1) {
+ if (SCConfGetBool("decoder.erspan.typeI.enabled", &enabled) == 1) {
SCLogWarning("ERSPAN Type I is no longer configurable and it is always"
" enabled; ignoring configuration setting.");
}
void DecodeGeneveConfig(void)
{
int enabled = 0;
- if (ConfGetBool("decoder.geneve.enabled", &enabled) == 1) {
+ if (SCConfGetBool("decoder.geneve.enabled", &enabled) == 1) {
if (enabled) {
g_geneve_enabled = true;
} else {
}
if (g_geneve_enabled) {
- ConfNode *node = ConfGetNode("decoder.geneve.ports");
+ SCConfNode *node = SCConfGetNode("decoder.geneve.ports");
if (node && node->val) {
DecodeGeneveConfigPorts(node->val);
} else {
void DecodeTeredoConfig(void)
{
int enabled = 0;
- if (ConfGetBool("decoder.teredo.enabled", &enabled) == 1) {
+ if (SCConfGetBool("decoder.teredo.enabled", &enabled) == 1) {
if (enabled) {
g_teredo_enabled = true;
} else {
}
}
if (g_teredo_enabled) {
- ConfNode *node = ConfGetNode("decoder.teredo.ports");
+ SCConfNode *node = SCConfGetNode("decoder.teredo.ports");
if (node && node->val) {
DecodeTeredoConfigPorts(node->val);
}
void DecodeVXLANConfig(void)
{
int enabled = 0;
- if (ConfGetBool("decoder.vxlan.enabled", &enabled) == 1) {
+ if (SCConfGetBool("decoder.vxlan.enabled", &enabled) == 1) {
if (enabled) {
g_vxlan_enabled = true;
} else {
}
if (g_vxlan_enabled) {
- ConfNode *node = ConfGetNode("decoder.vxlan.ports");
+ SCConfNode *node = SCConfGetNode("decoder.vxlan.ports");
if (node && node->val) {
DecodeVXLANConfigPorts(node->val);
} else {
DecodeVXLANConfig();
DecodeERSPANConfig();
intmax_t value = 0;
- if (ConfGetInt("decoder.max-layers", &value) == 1) {
+ if (SCConfGetInt("decoder.max-layers", &value) == 1) {
if (value < 0 || value > UINT8_MAX) {
SCLogWarning("Invalid value for decoder.max-layers");
} else {
void PacketAlertGetMaxConfig(void)
{
intmax_t max = 0;
- if (ConfGetInt("packet-alert-max", &max) == 1) {
+ if (SCConfGetInt("packet-alert-max", &max) == 1) {
if (max <= 0 || max > UINT8_MAX) {
SCLogWarning("Invalid value for packet-alert-max, default value set instead");
} else {
return timeout;
}
-static void DefragParseParameters(ConfNode *n)
+static void DefragParseParameters(SCConfNode *n)
{
- ConfNode *si;
+ SCConfNode *si;
uint64_t timeout = 0;
TAILQ_FOREACH(si, &n->head, next) {
}
}
if (strcasecmp("address", si->name) == 0) {
- ConfNode *pval;
+ SCConfNode *pval;
TAILQ_FOREACH(pval, &si->head, next) {
DefragPolicyAddHostInfo(pval->val, timeout);
}
{
SCEnter();
- ConfNode *server_config = ConfGetNode("defrag.host-config");
+ SCConfNode *server_config = SCConfGetNode("defrag.host-config");
if (server_config == NULL) {
SCLogDebug("failed to read host config");
SCReturn;
}
SCLogDebug("configuring host config %p", server_config);
- ConfNode *sc;
+ SCConfNode *sc;
TAILQ_FOREACH(sc, &server_config->head, next) {
- ConfNode *p = NULL;
+ SCConfNode *p = NULL;
TAILQ_FOREACH(p, &sc->head, next) {
SCLogDebug("parsing configuration for %s", p->name);
uint64_t defrag_memcap;
/** set config values for memcap, prealloc and hash_size */
- if ((ConfGet("defrag.memcap", &conf_val)) == 1)
- {
+ if ((SCConfGet("defrag.memcap", &conf_val)) == 1) {
if (ParseSizeStringU64(conf_val, &defrag_memcap) < 0) {
SCLogError("Error parsing defrag.memcap "
"from conf file - %s. Killing engine",
SC_ATOMIC_SET(defrag_config.memcap, defrag_memcap);
}
}
- if ((ConfGet("defrag.hash-size", &conf_val)) == 1)
- {
+ if ((SCConfGet("defrag.hash-size", &conf_val)) == 1) {
if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
defrag_config.hash_size = configval;
}
}
-
- if ((ConfGet("defrag.trackers", &conf_val)) == 1)
- {
+ if ((SCConfGet("defrag.trackers", &conf_val)) == 1) {
if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
defrag_config.prealloc = configval;
(uintmax_t)sizeof(DefragTrackerHashRow));
}
- if ((ConfGet("defrag.prealloc", &conf_val)) == 1)
- {
- if (ConfValIsTrue(conf_val)) {
+ if ((SCConfGet("defrag.prealloc", &conf_val)) == 1) {
+ if (SCConfValIsTrue(conf_val)) {
/* pre allocate defrag trackers */
for (i = 0; i < defrag_config.prealloc; i++) {
if (!(DEFRAG_CHECK_MEMCAP(sizeof(DefragTracker)))) {
/* Initialize the pool of trackers. */
intmax_t tracker_pool_size;
- if (!ConfGetInt("defrag.trackers", &tracker_pool_size) || tracker_pool_size == 0) {
+ if (!SCConfGetInt("defrag.trackers", &tracker_pool_size) || tracker_pool_size == 0) {
tracker_pool_size = DEFAULT_DEFRAG_HASH_SIZE;
}
/* Initialize the pool of frags. */
intmax_t frag_pool_size;
- if (!ConfGetInt("defrag.max-frags", &frag_pool_size) || frag_pool_size == 0 ||
+ if (!SCConfGetInt("defrag.max-frags", &frag_pool_size) || frag_pool_size == 0 ||
frag_pool_size > UINT32_MAX) {
frag_pool_size = DEFAULT_DEFRAG_POOL_SIZE;
}
/* Set the default timeout. */
intmax_t timeout;
- if (!ConfGetInt("defrag.timeout", &timeout)) {
+ if (!SCConfGetInt("defrag.timeout", &timeout)) {
dc->timeout = TIMEOUT_DEFAULT;
- }
- else {
+ } else {
if (timeout < TIMEOUT_MIN) {
FatalError("defrag: Timeout less than minimum allowed value.");
}
DefragInit(void)
{
intmax_t tracker_pool_size;
- if (!ConfGetInt("defrag.trackers", &tracker_pool_size)) {
+ if (!SCConfGetInt("defrag.trackers", &tracker_pool_size)) {
tracker_pool_size = DEFAULT_DEFRAG_HASH_SIZE;
}
memset(&dtv, 0, sizeof(dtv));
/* Setup a small number of trackers. */
- FAIL_IF_NOT(ConfSet("defrag.trackers", "16"));
+ FAIL_IF_NOT(SCConfSet("defrag.trackers", "16"));
DefragInit();
SCLogDebug("save %s", save);
int allow_save = 1;
- if (ConfGetBool("datasets.rules.allow-write", &allow_save)) {
+ if (SCConfGetBool("datasets.rules.allow-write", &allow_save)) {
if (!allow_save) {
SCLogError("Rules containing save/state datasets have been disabled");
return -1;
}
int allow_absolute = 0;
- (void)ConfGetBool("datasets.rules.allow-absolute-filenames", &allow_absolute);
+ (void)SCConfGetBool("datasets.rules.allow-absolute-filenames", &allow_absolute);
if (allow_absolute) {
SCLogNotice("Allowing absolute filename for dataset rule: %s", save);
} else {
ResolvedVariablesList var_list = TAILQ_HEAD_INITIALIZER(var_list);
- ConfNode *address_vars_node = ConfGetNode("vars.address-groups");
+ SCConfNode *address_vars_node = SCConfGetNode("vars.address-groups");
if (address_vars_node == NULL) {
return 0;
}
DetectAddressHead *gh = NULL;
DetectAddressHead *ghn = NULL;
- ConfNode *seq_node;
+ SCConfNode *seq_node;
TAILQ_FOREACH(seq_node, &address_vars_node->head, next) {
SCLogDebug("Testing %s - %s", seq_node->name, seq_node->val);
int result = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
if (DetectAddressTestConfVars() < 0 && DetectPortTestConfVars() < 0)
result = 1;
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
return result;
}
int result = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
if (DetectAddressTestConfVars() == 0 && DetectPortTestConfVars() < 0)
result = 1;
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
return result;
}
int result = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
if (DetectAddressTestConfVars() < 0 && DetectPortTestConfVars() < 0)
result = 1;
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
return result;
}
int result = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
if (DetectAddressTestConfVars() == 0 && DetectPortTestConfVars() == 0)
result = 1;
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
return result;
}
int result = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
if (DetectAddressTestConfVars() != -1 && DetectPortTestConfVars() != -1)
goto end;
result = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
- return result;
+ return result;
}
static int AddressConfVarsTest06(void)
" EXTERNAL_NET: \"any\"\n"
"\n";
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
FAIL_IF(0 != DetectAddressTestConfVars());
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
{
int fp_engine_analysis_set = 0;
- if ((ConfGetBool("engine-analysis.rules-fast-pattern",
- &fp_engine_analysis_set)) == 0) {
+ if ((SCConfGetBool("engine-analysis.rules-fast-pattern", &fp_engine_analysis_set)) == 0) {
return false;
}
if (fp_engine_analysis_set == 0)
return false;
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
char *log_path = SCMalloc(PATH_MAX);
if (log_path == NULL) {
FatalError("Unable to allocate scratch memory for rule filename");
*/
static int SetupRuleAnalyzer(DetectEngineCtx *de_ctx)
{
- ConfNode *conf = ConfGetNode("engine-analysis");
+ SCConfNode *conf = SCConfGetNode("engine-analysis");
int enabled = 0;
if (conf != NULL) {
- const char *value = ConfNodeLookupChildValue(conf, "rules");
- if (value && ConfValIsTrue(value)) {
+ const char *value = SCConfNodeLookupChildValue(conf, "rules");
+ if (value && SCConfValIsTrue(value)) {
enabled = 1;
} else if (value && strcasecmp(value, "warnings-only") == 0) {
enabled = 1;
}
if (enabled) {
const char *log_dir;
- log_dir = ConfigGetLogDirectory();
+ log_dir = SCConfigGetLogDirectory();
char log_path[PATH_MAX];
snprintf(log_path, sizeof(log_path), "%s/%s%s", log_dir,
de_ctx->ea->file_prefix ? de_ctx->ea->file_prefix : "", "rules_analysis.txt");
jb_close(ctx.js);
const char *filename = "rules.json";
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
char json_path[PATH_MAX] = "";
snprintf(json_path, sizeof(json_path), "%s/%s%s", log_dir,
de_ctx->ea->file_prefix ? de_ctx->ea->file_prefix : "", filename);
jb_close(root_jb);
const char *filename = "patterns.json";
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
char json_path[PATH_MAX] = "";
snprintf(json_path, sizeof(json_path), "%s/%s%s", log_dir,
de_ctx->ea->file_prefix ? de_ctx->ea->file_prefix : "", filename);
jb_close(js);
const char *filename = "rule_group.json";
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
char log_path[PATH_MAX] = "";
snprintf(log_path, sizeof(log_path), "%s/%s", log_dir, filename);
}
int dump_grouping = 0;
- (void)ConfGetBool("detect.profiling.grouping.dump-to-disk", &dump_grouping);
+ (void)SCConfGetBool("detect.profiling.grouping.dump-to-disk", &dump_grouping);
if (dump_grouping) {
int add_rules = 0;
- (void)ConfGetBool("detect.profiling.grouping.include-rules", &add_rules);
+ (void)SCConfGetBool("detect.profiling.grouping.include-rules", &add_rules);
int add_mpm_stats = 0;
- (void)ConfGetBool("detect.profiling.grouping.include-mpm-stats", &add_mpm_stats);
+ (void)SCConfGetBool("detect.profiling.grouping.include-mpm-stats", &add_mpm_stats);
RulesDumpGrouping(de_ctx, add_rules, add_mpm_stats);
}
de_ctx->profile_match_logging_threshold = UINT_MAX; // disabled
intmax_t v = 0;
- if (ConfGetInt("detect.profiling.inspect-logging-threshold", &v) == 1)
+ if (SCConfGetInt("detect.profiling.inspect-logging-threshold", &v) == 1)
de_ctx->profile_match_logging_threshold = (uint32_t)v;
#endif
#ifdef PROFILE_RULES
/* If we have a configuration prefix, only use it if the primary configuration node
* is not marked as final, as that means it was provided on the command line with
* a --set. */
- ConfNode *default_rule_path = ConfGetNode("default-rule-path");
+ SCConfNode *default_rule_path = SCConfGetNode("default-rule-path");
if ((!default_rule_path || !default_rule_path->final) && strlen(de_ctx->config_prefix) > 0) {
snprintf(varname, sizeof(varname), "%s.default-rule-path",
de_ctx->config_prefix);
- default_rule_path = ConfGetNode(varname);
+ default_rule_path = SCConfGetNode(varname);
}
if (default_rule_path) {
defaultpath = default_rule_path->val;
{
SCEnter();
- ConfNode *rule_files;
- ConfNode *file = NULL;
+ SCConfNode *rule_files;
+ SCConfNode *file = NULL;
SigFileLoaderStat *sig_stat = &de_ctx->sig_stat;
int ret = 0;
char *sfile = NULL;
/* ok, let's load signature files from the general config */
if (!(sig_file != NULL && sig_file_exclusive)) {
- rule_files = ConfGetNode(varname);
+ rule_files = SCConfGetNode(varname);
if (rule_files != NULL) {
- if (!ConfNodeIsSequence(rule_files)) {
+ if (!SCConfNodeIsSequence(rule_files)) {
SCLogWarning("Invalid rule-files configuration section: "
"expected a list of filenames.");
- }
- else {
+ } else {
TAILQ_FOREACH(file, &rule_files->head, next) {
sfile = DetectLoadCompleteSigPath(de_ctx, file->val);
good_sigs = bad_sigs = skipped_sigs = 0;
void DetectLoadersInit(void)
{
intmax_t setting = NLOADERS;
- (void)ConfGetInt("multi-detect.loaders", &setting);
+ (void)SCConfGetInt("multi-detect.loaders", &setting);
if (setting < 1 || setting > 1024) {
FatalError("invalid multi-detect.loaders setting %" PRIdMAX, setting);
char confstring[256] = "detect.mpm.";
strlcat(confstring, n->name, sizeof(confstring));
strlcat(confstring, ".shared", sizeof(confstring));
- if (ConfGetBool(confstring, &confshared) == 1)
+ if (SCConfGetBool(confstring, &confshared) == 1)
shared = confshared;
if (shared == 0) {
int shared = (de_ctx->sgh_mpm_ctx_cnf == ENGINE_SGH_MPM_FACTORY_CONTEXT_SINGLE);
/* see if we use a unique or shared mpm ctx for this type */
int confshared = 0;
- if (ConfGetBool("detect.mpm.frame.shared", &confshared) == 1)
+ if (SCConfGetBool("detect.mpm.frame.shared", &confshared) == 1)
shared = confshared;
if (shared == 0) {
char confstring[256] = "detect.mpm.";
strlcat(confstring, n->name, sizeof(confstring));
strlcat(confstring, ".shared", sizeof(confstring));
- if (ConfGetBool(confstring, &confshared) == 1)
+ if (SCConfGetBool(confstring, &confshared) == 1)
shared = confshared;
if (shared == 0) {
char confstring[256] = "detect.mpm.";
strlcat(confstring, n->name, sizeof(confstring));
strlcat(confstring, ".shared", sizeof(confstring));
- if (ConfGetBool(confstring, &confshared) == 1)
+ if (SCConfGetBool(confstring, &confshared) == 1)
shared = confshared;
if (shared == 0) {
char confstring[256] = "detect.mpm.";
strlcat(confstring, name, sizeof(confstring));
strlcat(confstring, ".shared", sizeof(confstring));
- if (ConfGetBool(confstring, &confshared) == 1)
+ if (SCConfGetBool(confstring, &confshared) == 1)
shared = confshared;
int32_t ctx;
uint8_t mpm_algo_val = mpm_default_matcher;
/* Get the mpm algo defined in config file by the user */
- if ((ConfGet("mpm-algo", &mpm_algo)) == 1) {
+ if ((SCConfGet("mpm-algo", &mpm_algo)) == 1) {
if (mpm_algo != NULL) {
#if __BYTE_ORDER == __BIG_ENDIAN
if (strcmp(mpm_algo, "ac-ks") == 0) {
ResolvedVariablesList var_list = TAILQ_HEAD_INITIALIZER(var_list);
- ConfNode *port_vars_node = ConfGetNode("vars.port-groups");
+ SCConfNode *port_vars_node = SCConfGetNode("vars.port-groups");
if (port_vars_node == NULL) {
return 0;
}
- ConfNode *seq_node;
+ SCConfNode *seq_node;
TAILQ_FOREACH(seq_node, &port_vars_node->head, next) {
SCLogDebug("Testing %s - %s\n", seq_node->name, seq_node->val);
jb_close(js); // final close
const char *filename = "packet_inspected_rules.json";
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
char log_path[PATH_MAX] = "";
snprintf(log_path, sizeof(log_path), "%s/%s", log_dir, filename);
jb_close(js); // final close
const char *filename = "packet_inspected_rules.json";
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
char log_path[PATH_MAX] = "";
snprintf(log_path, sizeof(log_path), "%s/%s", log_dir, filename);
uint64_t memcap = 16 * 1024 * 1024;
const char *str;
- if (ConfGet("detect.thresholds.memcap", &str) == 1) {
+ if (SCConfGet("detect.thresholds.memcap", &str) == 1) {
if (ParseSizeStringU64(str, &memcap) < 0) {
SCLogError("Error parsing detect.thresholds.memcap from conf file - %s", str);
return -1;
}
intmax_t value = 0;
- if ((ConfGetInt("detect.thresholds.hash-size", &value)) == 1) {
+ if ((SCConfGetInt("detect.thresholds.hash-size", &value)) == 1) {
if (value < 256 || value > INT_MAX) {
SCLogError("'detect.thresholds.hash-size' value %" PRIiMAX
" out of range. Valid range 256-2147483647.",
bool DetectEngineMpmCachingEnabled(void)
{
const char *strval = NULL;
- if (ConfGet("detect.sgh-mpm-caching", &strval) != 1)
+ if (SCConfGet("detect.sgh-mpm-caching", &strval) != 1)
return false;
int sgh_mpm_caching = 0;
- (void)ConfGetBool("detect.sgh-mpm-caching", &sgh_mpm_caching);
+ (void)SCConfGetBool("detect.sgh-mpm-caching", &sgh_mpm_caching);
return (bool)sgh_mpm_caching;
}
char yamlpath[] = "detect.sgh-mpm-caching-path";
const char *strval = NULL;
- ConfGet(yamlpath, &strval);
+ SCConfGet(yamlpath, &strval);
if (strval != NULL) {
return strval;
}
int failure_fatal = 0;
- if (ConfGetBool("engine.init-failure-fatal", (int *)&failure_fatal) != 1) {
+ if (SCConfGetBool("engine.init-failure-fatal", (int *)&failure_fatal) != 1) {
SCLogDebug("ConfGetBool could not load the value.");
}
de_ctx->failure_fatal = (failure_fatal == 1);
/* init iprep... ignore errors for now */
(void)SRepInit(de_ctx);
- SCClassConfInit(de_ctx);
+ SCClassSCConfInit(de_ctx);
if (!SCClassConfLoadClassificationConfigFile(de_ctx, NULL)) {
if (SCRunmodeGet() == RUNMODE_CONF_TEST)
goto error;
if (ActionInitConfig() < 0) {
goto error;
}
- SCReferenceConfInit(de_ctx);
+ SCReferenceSCConfInit(de_ctx);
if (SCRConfLoadReferenceConfigFile(de_ctx, NULL) < 0) {
if (SCRunmodeGet() == RUNMODE_CONF_TEST)
goto error;
/* if we have a config prefix, remove the config from the tree */
if (strlen(de_ctx->config_prefix) > 0) {
/* remove config */
- ConfNode *node = ConfGetNode(de_ctx->config_prefix);
+ SCConfNode *node = SCConfGetNode(de_ctx->config_prefix);
if (node != NULL) {
- ConfNodeRemove(node); /* frees node */
+ SCConfNodeRemove(node); /* frees node */
}
#if 0
ConfDump();
const char *sgh_mpm_context = NULL;
const char *de_ctx_profile = NULL;
- (void)ConfGet("detect.profile", &de_ctx_profile);
- (void)ConfGet("detect.sgh-mpm-context", &sgh_mpm_context);
+ (void)SCConfGet("detect.profile", &de_ctx_profile);
+ (void)SCConfGet("detect.sgh-mpm-context", &sgh_mpm_context);
- ConfNode *de_ctx_custom = ConfGetNode("detect-engine");
- ConfNode *opt = NULL;
+ SCConfNode *de_ctx_custom = SCConfGetNode("detect-engine");
+ SCConfNode *opt = NULL;
if (de_ctx_custom != NULL) {
TAILQ_FOREACH(opt, &de_ctx_custom->head, next) {
break;
case ENGINE_PROFILE_CUSTOM:
- (void)ConfGet("detect.custom-values.toclient-groups",
- &max_uniq_toclient_groups_str);
- (void)ConfGet("detect.custom-values.toserver-groups",
- &max_uniq_toserver_groups_str);
+ (void)SCConfGet("detect.custom-values.toclient-groups", &max_uniq_toclient_groups_str);
+ (void)SCConfGet("detect.custom-values.toserver-groups", &max_uniq_toserver_groups_str);
if (de_ctx_custom != NULL) {
TAILQ_FOREACH(opt, &de_ctx_custom->head, next) {
if (opt->val && strcmp(opt->val, "custom-values") == 0) {
if (max_uniq_toclient_groups_str == NULL) {
- max_uniq_toclient_groups_str = (char *)ConfNodeLookupChildValue
- (opt->head.tqh_first, "toclient-sp-groups");
+ max_uniq_toclient_groups_str = (char *)SCConfNodeLookupChildValue(
+ opt->head.tqh_first, "toclient-sp-groups");
}
if (max_uniq_toclient_groups_str == NULL) {
- max_uniq_toclient_groups_str = (char *)ConfNodeLookupChildValue
- (opt->head.tqh_first, "toclient-groups");
+ max_uniq_toclient_groups_str = (char *)SCConfNodeLookupChildValue(
+ opt->head.tqh_first, "toclient-groups");
}
if (max_uniq_toserver_groups_str == NULL) {
- max_uniq_toserver_groups_str = (char *)ConfNodeLookupChildValue
- (opt->head.tqh_first, "toserver-dp-groups");
+ max_uniq_toserver_groups_str = (char *)SCConfNodeLookupChildValue(
+ opt->head.tqh_first, "toserver-dp-groups");
}
if (max_uniq_toserver_groups_str == NULL) {
- max_uniq_toserver_groups_str = (char *)ConfNodeLookupChildValue
- (opt->head.tqh_first, "toserver-groups");
+ max_uniq_toserver_groups_str = (char *)SCConfNodeLookupChildValue(
+ opt->head.tqh_first, "toserver-groups");
}
}
}
intmax_t value = 0;
de_ctx->inspection_recursion_limit = DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT;
- if (ConfGetInt("detect.inspection-recursion-limit", &value) == 1)
- {
+ if (SCConfGetInt("detect.inspection-recursion-limit", &value) == 1) {
if (value >= 0 && value <= INT_MAX) {
de_ctx->inspection_recursion_limit = (int)value;
}
/* fall back to old config parsing */
} else {
- ConfNode *insp_recursion_limit_node = NULL;
+ SCConfNode *insp_recursion_limit_node = NULL;
char *insp_recursion_limit = NULL;
if (de_ctx_custom != NULL) {
if (opt->val && strcmp(opt->val, "inspection-recursion-limit") != 0)
continue;
- insp_recursion_limit_node = ConfNodeLookupChild(opt, opt->val);
+ insp_recursion_limit_node = SCConfNodeLookupChild(opt, opt->val);
if (insp_recursion_limit_node == NULL) {
SCLogError("Error retrieving conf "
"entry for detect-engine:inspection-recursion-limit");
// default value is 4
de_ctx->guess_applayer_log_limit = 4;
- if (ConfGetInt("detect.stream-tx-log-limit", &value) == 1) {
+ if (SCConfGetInt("detect.stream-tx-log-limit", &value) == 1) {
if (value >= 0 && value <= UINT8_MAX) {
de_ctx->guess_applayer_log_limit = (uint8_t)value;
} else {
}
}
int guess_applayer = 0;
- if ((ConfGetBool("detect.guess-applayer-tx", &guess_applayer)) == 1) {
+ if ((SCConfGetBool("detect.guess-applayer-tx", &guess_applayer)) == 1) {
if (guess_applayer == 1) {
de_ctx->guess_applayer = true;
}
/* parse port grouping priority settings */
const char *ports = NULL;
- (void)ConfGet("detect.grouping.tcp-priority-ports", &ports);
+ (void)SCConfGet("detect.grouping.tcp-priority-ports", &ports);
if (ports) {
SCLogConfig("grouping: tcp-priority-ports %s", ports);
} else {
- (void)ConfGet("detect.grouping.tcp-whitelist", &ports);
+ (void)SCConfGet("detect.grouping.tcp-whitelist", &ports);
if (ports) {
SCLogConfig(
"grouping: tcp-priority-ports from legacy 'tcp-whitelist' setting: %s", ports);
}
ports = NULL;
- (void)ConfGet("detect.grouping.udp-priority-ports", &ports);
+ (void)SCConfGet("detect.grouping.udp-priority-ports", &ports);
if (ports) {
SCLogConfig("grouping: udp-priority-ports %s", ports);
} else {
- (void)ConfGet("detect.grouping.udp-whitelist", &ports);
+ (void)SCConfGet("detect.grouping.udp-whitelist", &ports);
if (ports) {
SCLogConfig(
"grouping: udp-priority-ports from legacy 'udp-whitelist' setting: %s", ports);
de_ctx->prefilter_setting = DETECT_PREFILTER_MPM;
const char *pf_setting = NULL;
- if (ConfGet("detect.prefilter.default", &pf_setting) == 1 && pf_setting) {
+ if (SCConfGet("detect.prefilter.default", &pf_setting) == 1 && pf_setting) {
if (strcasecmp(pf_setting, "mpm") == 0) {
de_ctx->prefilter_setting = DETECT_PREFILTER_MPM;
} else if (strcasecmp(pf_setting, "auto") == 0) {
goto error;
}
- ConfNode *node = ConfGetNode(prefix);
+ SCConfNode *node = SCConfGetNode(prefix);
if (node == NULL) {
SCLogError("failed to properly setup yaml %s", filename);
goto error;
reload_cnt++;
SCLogDebug("prefix %s", prefix);
- if (ConfYamlLoadFileWithPrefix(filename, prefix) != 0) {
+ if (SCConfYamlLoadFileWithPrefix(filename, prefix) != 0) {
SCLogError("failed to load yaml");
goto error;
}
- ConfNode *node = ConfGetNode(prefix);
+ SCConfNode *node = SCConfGetNode(prefix);
if (node == NULL) {
SCLogError("failed to properly setup yaml %s", filename);
goto error;
return 0;
}
-static int DetectEngineMultiTenantSetupLoadLivedevMappings(const ConfNode *mappings_root_node,
- bool failure_fatal)
+static int DetectEngineMultiTenantSetupLoadLivedevMappings(
+ const SCConfNode *mappings_root_node, bool failure_fatal)
{
- ConfNode *mapping_node = NULL;
+ SCConfNode *mapping_node = NULL;
int mapping_cnt = 0;
if (mappings_root_node != NULL) {
TAILQ_FOREACH(mapping_node, &mappings_root_node->head, next) {
- ConfNode *tenant_id_node = ConfNodeLookupChild(mapping_node, "tenant-id");
+ SCConfNode *tenant_id_node = SCConfNodeLookupChild(mapping_node, "tenant-id");
if (tenant_id_node == NULL)
goto bad_mapping;
- ConfNode *device_node = ConfNodeLookupChild(mapping_node, "device");
+ SCConfNode *device_node = SCConfNodeLookupChild(mapping_node, "device");
if (device_node == NULL)
goto bad_mapping;
return 0;
}
-static int DetectEngineMultiTenantSetupLoadVlanMappings(const ConfNode *mappings_root_node,
- bool failure_fatal)
+static int DetectEngineMultiTenantSetupLoadVlanMappings(
+ const SCConfNode *mappings_root_node, bool failure_fatal)
{
- ConfNode *mapping_node = NULL;
+ SCConfNode *mapping_node = NULL;
int mapping_cnt = 0;
if (mappings_root_node != NULL) {
TAILQ_FOREACH(mapping_node, &mappings_root_node->head, next) {
- ConfNode *tenant_id_node = ConfNodeLookupChild(mapping_node, "tenant-id");
+ SCConfNode *tenant_id_node = SCConfNodeLookupChild(mapping_node, "tenant-id");
if (tenant_id_node == NULL)
goto bad_mapping;
- ConfNode *vlan_id_node = ConfNodeLookupChild(mapping_node, "vlan-id");
+ SCConfNode *vlan_id_node = SCConfNodeLookupChild(mapping_node, "vlan-id");
if (vlan_id_node == NULL)
goto bad_mapping;
enum DetectEngineTenantSelectors tenant_selector = TENANT_SELECTOR_UNKNOWN;
DetectEngineMasterCtx *master = &g_master_de_ctx;
int failure_fatal = 0;
- (void)ConfGetBool("engine.init-failure-fatal", &failure_fatal);
+ (void)SCConfGetBool("engine.init-failure-fatal", &failure_fatal);
int enabled = 0;
- (void)ConfGetBool("multi-detect.enabled", &enabled);
+ (void)SCConfGetBool("multi-detect.enabled", &enabled);
if (enabled == 1) {
DetectLoadersInit();
TmModuleDetectLoaderRegister();
master->multi_tenant_enabled = 1;
const char *handler = NULL;
- if (ConfGet("multi-detect.selector", &handler) == 1) {
+ if (SCConfGet("multi-detect.selector", &handler) == 1) {
SCLogConfig("multi-tenant selector type %s", handler);
if (strcmp(handler, "vlan") == 0) {
tenant_selector = master->tenant_selector = TENANT_SELECTOR_VLAN;
int vlanbool = 0;
- if ((ConfGetBool("vlan.use-for-tracking", &vlanbool)) == 1 && vlanbool == 0) {
+ if ((SCConfGetBool("vlan.use-for-tracking", &vlanbool)) == 1 && vlanbool == 0) {
SCLogError("vlan tracking is disabled, "
"can't use multi-detect selector 'vlan'");
SCMutexUnlock(&master->lock);
SCLogConfig("multi-detect is enabled (multi tenancy). Selector: %s", handler);
/* traffic -- tenant mappings */
- ConfNode *mappings_root_node = ConfGetNode("multi-detect.mappings");
+ SCConfNode *mappings_root_node = SCConfGetNode("multi-detect.mappings");
if (tenant_selector == TENANT_SELECTOR_VLAN) {
int mapping_cnt = DetectEngineMultiTenantSetupLoadVlanMappings(mappings_root_node,
}
/* tenants */
- ConfNode *tenants_root_node = ConfGetNode("multi-detect.tenants");
- ConfNode *tenant_node = NULL;
+ SCConfNode *tenants_root_node = SCConfGetNode("multi-detect.tenants");
+ SCConfNode *tenant_node = NULL;
if (tenants_root_node != NULL) {
const char *path = NULL;
- ConfNode *path_node = ConfGetNode("multi-detect.config-path");
+ SCConfNode *path_node = SCConfGetNode("multi-detect.config-path");
if (path_node) {
path = path_node->val;
SCLogConfig("tenants config path: %s", path);
}
TAILQ_FOREACH(tenant_node, &tenants_root_node->head, next) {
- ConfNode *id_node = ConfNodeLookupChild(tenant_node, "id");
+ SCConfNode *id_node = SCConfNodeLookupChild(tenant_node, "id");
if (id_node == NULL) {
goto bad_tenant;
}
- ConfNode *yaml_node = ConfNodeLookupChild(tenant_node, "yaml");
+ SCConfNode *yaml_node = SCConfNodeLookupChild(tenant_node, "yaml");
if (yaml_node == NULL) {
goto bad_tenant;
}
SCLogDebug("tenant path: %s", yaml_path);
/* setup the yaml in this loop so that it's not done by the loader
- * threads. ConfYamlLoadFileWithPrefix is not thread safe. */
+ * threads. SCConfYamlLoadFileWithPrefix is not thread safe. */
char prefix[64];
snprintf(prefix, sizeof(prefix), "multi-detect.%u", tenant_id);
- if (ConfYamlLoadFileWithPrefix(yaml_path, prefix) != 0) {
+ if (SCConfYamlLoadFileWithPrefix(yaml_path, prefix) != 0) {
SCLogError("failed to load yaml %s", yaml_path);
goto bad_tenant;
}
if (suri->conf_filename != NULL) {
snprintf(prefix, sizeof(prefix), "detect-engine-reloads.%d", reloads++);
SCLogConfig("Reloading %s", suri->conf_filename);
- if (ConfYamlLoadFileWithPrefix(suri->conf_filename, prefix) != 0) {
+ if (SCConfYamlLoadFileWithPrefix(suri->conf_filename, prefix) != 0) {
SCLogError("failed to load yaml %s", suri->conf_filename);
return -1;
}
- ConfNode *node = ConfGetNode(prefix);
+ SCConfNode *node = SCConfGetNode(prefix);
if (node == NULL) {
SCLogError("failed to properly setup yaml %s", suri->conf_filename);
return -1;
if (suri->additional_configs) {
for (int i = 0; suri->additional_configs[i] != NULL; i++) {
SCLogConfig("Reloading %s", suri->additional_configs[i]);
- ConfYamlHandleInclude(node, suri->additional_configs[i]);
+ SCConfYamlHandleInclude(node, suri->additional_configs[i]);
}
}
static int DetectEngineInitYamlConf(const char *conf)
{
- ConfCreateContextBackup();
- ConfInit();
- return ConfYamlLoadString(conf, strlen(conf));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ return SCConfYamlLoadString(conf, strlen(conf));
}
static void DetectEngineDeInitYamlConf(void)
{
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
}
static int DetectEngineTest01(void)
jb_close(js); // object
const char *filename = "flowbits.json";
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
char log_path[PATH_MAX] = "";
snprintf(log_path, sizeof(log_path), "%s/%s", log_dir, filename);
const char *filename = NULL;
/* Get location and name of GeoIP2 database from YAML conf */
- (void)ConfGet("geoip-database", &filename);
+ (void)SCConfGet("geoip-database", &filename);
if (filename == NULL) {
SCLogWarning("Unable to locate a GeoIP2"
/* First check if Lua rules are enabled, by default Lua in rules
* is disabled. */
int enabled = 0;
- (void)ConfGetBool("security.lua.allow-rules", &enabled);
+ (void)SCConfGetBool("security.lua.allow-rules", &enabled);
if (!enabled) {
SCLogError("Lua rules disabled by security configuration: security.lua.allow-rules");
return -1;
/* Load lua sandbox configurations */
intmax_t lua_alloc_limit = DEFAULT_LUA_ALLOC_LIMIT;
intmax_t lua_instruction_limit = DEFAULT_LUA_INSTRUCTION_LIMIT;
- (void)ConfGetInt("security.lua.max-bytes", &lua_alloc_limit);
- (void)ConfGetInt("security.lua.max-instructions", &lua_instruction_limit);
+ (void)SCConfGetInt("security.lua.max-bytes", &lua_alloc_limit);
+ (void)SCConfGetInt("security.lua.max-instructions", &lua_instruction_limit);
lua->alloc_limit = lua_alloc_limit;
lua->instruction_limit = lua_instruction_limit;
int allow_restricted_functions = 0;
- (void)ConfGetBool("security.lua.allow-restricted-functions", &allow_restricted_functions);
+ (void)SCConfGetBool("security.lua.allow-restricted-functions", &allow_restricted_functions);
lua->allow_restricted_functions = allow_restricted_functions;
if (DetectLuaSetupPrime(de_ctx, lua, s) == -1) {
/** \test http buffer */
static int LuaMatchTest01(void)
{
- ConfSetFinal("security.lua.allow-rules", "true");
+ SCConfSetFinal("security.lua.allow-rules", "true");
const char script[] =
"function init (args)\n"
intmax_t val = 0;
- if (!ConfGetInt("pcre.match-limit", &val)) {
+ if (!SCConfGetInt("pcre.match-limit", &val)) {
pcre_match_limit = SC_MATCH_LIMIT_DEFAULT;
SCLogDebug("Using PCRE match-limit setting of: %i", pcre_match_limit);
- }
- else {
+ } else {
pcre_match_limit = val;
if (pcre_match_limit != SC_MATCH_LIMIT_DEFAULT) {
SCLogInfo("Using PCRE match-limit setting of: %i", pcre_match_limit);
val = 0;
- if (!ConfGetInt("pcre.match-limit-recursion", &val)) {
+ if (!SCConfGetInt("pcre.match-limit-recursion", &val)) {
pcre_match_limit_recursion = SC_MATCH_LIMIT_RECURSION_DEFAULT;
SCLogDebug("Using PCRE match-limit-recursion setting of: %i", pcre_match_limit_recursion);
- }
- else {
+ } else {
pcre_match_limit_recursion = val;
if (pcre_match_limit_recursion != SC_MATCH_LIMIT_RECURSION_DEFAULT) {
SCLogInfo("Using PCRE match-limit-recursion setting of: %i", pcre_match_limit_recursion);
SCEnter();
const char *legacy = NULL;
- if (ConfGet("legacy.uricontent", &legacy) == 1) {
+ if (SCConfGet("legacy.uricontent", &legacy) == 1) {
if (strcasecmp("disabled", legacy) == 0) {
SCLogError("uricontent deprecated. To "
"use a rule with \"uricontent\", either set the "
void FlowManagerThreadSpawn(void)
{
intmax_t setting = 1;
- (void)ConfGetInt("flow.managers", &setting);
+ (void)SCConfGetInt("flow.managers", &setting);
if (setting < 1 || setting > 1024) {
FatalError("invalid flow.managers setting %" PRIdMAX, setting);
void FlowRecyclerThreadSpawn(void)
{
intmax_t setting = 1;
- (void)ConfGetInt("flow.recyclers", &setting);
+ (void)SCConfGetInt("flow.recyclers", &setting);
if (setting < 1 || setting > 1024) {
FatalError("invalid flow.recyclers setting %" PRIdMAX, setting);
/* If we have specific config, overwrite the defaults with them,
* otherwise, leave the default values */
intmax_t val = 0;
- if (ConfGetInt("flow.emergency-recovery", &val) == 1) {
+ if (SCConfGetInt("flow.emergency-recovery", &val) == 1) {
if (val <= 100 && val >= 1) {
flow_config.emergency_recovery = (uint8_t)val;
} else {
/** set config values for memcap, prealloc and hash_size */
uint64_t flow_memcap_copy = 0;
- if ((ConfGet("flow.memcap", &conf_val)) == 1)
- {
+ if ((SCConfGet("flow.memcap", &conf_val)) == 1) {
if (conf_val == NULL) {
FatalError("Invalid value for flow.memcap: NULL");
}
SC_ATOMIC_SET(flow_config.memcap, flow_memcap_copy);
}
}
- if ((ConfGet("flow.hash-size", &conf_val)) == 1)
- {
+ if ((SCConfGet("flow.hash-size", &conf_val)) == 1) {
if (conf_val == NULL) {
FatalError("Invalid value for flow.hash-size: NULL");
}
"1-4294967295");
}
}
- if ((ConfGet("flow.prealloc", &conf_val)) == 1)
- {
+ if ((SCConfGet("flow.prealloc", &conf_val)) == 1) {
if (conf_val == NULL) {
FatalError("Invalid value for flow.prealloc: NULL");
}
const char *emergency_closed = NULL;
const char *emergency_bypassed = NULL;
- ConfNode *flow_timeouts = ConfGetNode("flow-timeouts");
+ SCConfNode *flow_timeouts = SCConfGetNode("flow-timeouts");
if (flow_timeouts != NULL) {
- ConfNode *proto = NULL;
+ SCConfNode *proto = NULL;
uint32_t configval = 0;
/* Defaults. */
- proto = ConfNodeLookupChild(flow_timeouts, "default");
+ proto = SCConfNodeLookupChild(flow_timeouts, "default");
if (proto != NULL) {
- new = ConfNodeLookupChildValue(proto, "new");
- established = ConfNodeLookupChildValue(proto, "established");
- closed = ConfNodeLookupChildValue(proto, "closed");
- bypassed = ConfNodeLookupChildValue(proto, "bypassed");
- emergency_new = ConfNodeLookupChildValue(proto, "emergency-new");
- emergency_established = ConfNodeLookupChildValue(proto,
- "emergency-established");
- emergency_closed = ConfNodeLookupChildValue(proto,
- "emergency-closed");
- emergency_bypassed = ConfNodeLookupChildValue(proto,
- "emergency-bypassed");
+ new = SCConfNodeLookupChildValue(proto, "new");
+ established = SCConfNodeLookupChildValue(proto, "established");
+ closed = SCConfNodeLookupChildValue(proto, "closed");
+ bypassed = SCConfNodeLookupChildValue(proto, "bypassed");
+ emergency_new = SCConfNodeLookupChildValue(proto, "emergency-new");
+ emergency_established = SCConfNodeLookupChildValue(proto, "emergency-established");
+ emergency_closed = SCConfNodeLookupChildValue(proto, "emergency-closed");
+ emergency_bypassed = SCConfNodeLookupChildValue(proto, "emergency-bypassed");
if (new != NULL &&
StringParseUint32(&configval, 10, strlen(new), new) > 0) {
}
/* TCP. */
- proto = ConfNodeLookupChild(flow_timeouts, "tcp");
+ proto = SCConfNodeLookupChild(flow_timeouts, "tcp");
if (proto != NULL) {
- new = ConfNodeLookupChildValue(proto, "new");
- established = ConfNodeLookupChildValue(proto, "established");
- closed = ConfNodeLookupChildValue(proto, "closed");
- bypassed = ConfNodeLookupChildValue(proto, "bypassed");
- emergency_new = ConfNodeLookupChildValue(proto, "emergency-new");
- emergency_established = ConfNodeLookupChildValue(proto,
- "emergency-established");
- emergency_closed = ConfNodeLookupChildValue(proto,
- "emergency-closed");
- emergency_bypassed = ConfNodeLookupChildValue(proto,
- "emergency-bypassed");
+ new = SCConfNodeLookupChildValue(proto, "new");
+ established = SCConfNodeLookupChildValue(proto, "established");
+ closed = SCConfNodeLookupChildValue(proto, "closed");
+ bypassed = SCConfNodeLookupChildValue(proto, "bypassed");
+ emergency_new = SCConfNodeLookupChildValue(proto, "emergency-new");
+ emergency_established = SCConfNodeLookupChildValue(proto, "emergency-established");
+ emergency_closed = SCConfNodeLookupChildValue(proto, "emergency-closed");
+ emergency_bypassed = SCConfNodeLookupChildValue(proto, "emergency-bypassed");
if (new != NULL &&
StringParseUint32(&configval, 10, strlen(new), new) > 0) {
}
/* UDP. */
- proto = ConfNodeLookupChild(flow_timeouts, "udp");
+ proto = SCConfNodeLookupChild(flow_timeouts, "udp");
if (proto != NULL) {
- new = ConfNodeLookupChildValue(proto, "new");
- established = ConfNodeLookupChildValue(proto, "established");
- bypassed = ConfNodeLookupChildValue(proto, "bypassed");
- emergency_new = ConfNodeLookupChildValue(proto, "emergency-new");
- emergency_established = ConfNodeLookupChildValue(proto,
- "emergency-established");
- emergency_bypassed = ConfNodeLookupChildValue(proto,
- "emergency-bypassed");
+ new = SCConfNodeLookupChildValue(proto, "new");
+ established = SCConfNodeLookupChildValue(proto, "established");
+ bypassed = SCConfNodeLookupChildValue(proto, "bypassed");
+ emergency_new = SCConfNodeLookupChildValue(proto, "emergency-new");
+ emergency_established = SCConfNodeLookupChildValue(proto, "emergency-established");
+ emergency_bypassed = SCConfNodeLookupChildValue(proto, "emergency-bypassed");
if (new != NULL &&
StringParseUint32(&configval, 10, strlen(new), new) > 0) {
}
/* ICMP. */
- proto = ConfNodeLookupChild(flow_timeouts, "icmp");
+ proto = SCConfNodeLookupChild(flow_timeouts, "icmp");
if (proto != NULL) {
- new = ConfNodeLookupChildValue(proto, "new");
- established = ConfNodeLookupChildValue(proto, "established");
- bypassed = ConfNodeLookupChildValue(proto, "bypassed");
- emergency_new = ConfNodeLookupChildValue(proto, "emergency-new");
- emergency_established = ConfNodeLookupChildValue(proto,
- "emergency-established");
- emergency_bypassed = ConfNodeLookupChildValue(proto,
- "emergency-bypassed");
+ new = SCConfNodeLookupChildValue(proto, "new");
+ established = SCConfNodeLookupChildValue(proto, "established");
+ bypassed = SCConfNodeLookupChildValue(proto, "bypassed");
+ emergency_new = SCConfNodeLookupChildValue(proto, "emergency-new");
+ emergency_established = SCConfNodeLookupChildValue(proto, "emergency-established");
+ emergency_bypassed = SCConfNodeLookupChildValue(proto, "emergency-bypassed");
if (new != NULL &&
StringParseUint32(&configval, 10, strlen(new), new) > 0) {
uint32_t configval = 0;
/** set config values for memcap, prealloc and hash_size */
- if ((ConfGet("host.memcap", &conf_val)) == 1) {
+ if ((SCConfGet("host.memcap", &conf_val)) == 1) {
uint64_t host_memcap = 0;
if (ParseSizeStringU64(conf_val, &host_memcap) < 0) {
SCLogError("Error parsing host.memcap "
SC_ATOMIC_SET(host_config.memcap, host_memcap);
}
}
- if ((ConfGet("host.hash-size", &conf_val)) == 1) {
+ if ((SCConfGet("host.hash-size", &conf_val)) == 1) {
if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
host_config.hash_size = configval;
}
}
- if ((ConfGet("host.prealloc", &conf_val)) == 1) {
+ if ((SCConfGet("host.prealloc", &conf_val)) == 1) {
if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
host_config.prealloc = configval;
/** set config values for memcap, prealloc and hash_size */
uint64_t ippair_memcap;
- if ((ConfGet("ippair.memcap", &conf_val)) == 1)
- {
+ if ((SCConfGet("ippair.memcap", &conf_val)) == 1) {
if (ParseSizeStringU64(conf_val, &ippair_memcap) < 0) {
SCLogError("Error parsing ippair.memcap "
"from conf file - %s. Killing engine",
SC_ATOMIC_SET(ippair_config.memcap, ippair_memcap);
}
}
- if ((ConfGet("ippair.hash-size", &conf_val)) == 1)
- {
+ if ((SCConfGet("ippair.hash-size", &conf_val)) == 1) {
if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
ippair_config.hash_size = configval;
}
}
- if ((ConfGet("ippair.prealloc", &conf_val)) == 1)
- {
+ if ((SCConfGet("ippair.prealloc", &conf_val)) == 1) {
if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
ippair_config.prealloc = configval;
static int OutputFlushInterval(void)
{
intmax_t output_flush_interval = 0;
- if (ConfGetInt("heartbeat.output-flush-interval", &output_flush_interval) == 0) {
+ if (SCConfGetInt("heartbeat.output-flush-interval", &output_flush_interval) == 0) {
output_flush_interval = 0;
}
if (output_flush_interval < 0 || output_flush_interval > 60) {
* \param conf Pointer to ConfNode containing this loggers configuration.
* \return NULL if failure, LogFileCtx* to the file_ctx if succesful
* */
-OutputInitResult LogHttpLogInitCtx(ConfNode *conf)
+OutputInitResult LogHttpLogInitCtx(SCConfNode *conf)
{
SCLogWarning("The http-log output has been deprecated and will be removed in Suricata 9.0.");
OutputInitResult result = { NULL, false };
httplog_ctx->file_ctx = file_ctx;
- const char *extended = ConfNodeLookupChildValue(conf, "extended");
- const char *custom = ConfNodeLookupChildValue(conf, "custom");
- const char *customformat = ConfNodeLookupChildValue(conf, "customformat");
+ const char *extended = SCConfNodeLookupChildValue(conf, "extended");
+ const char *custom = SCConfNodeLookupChildValue(conf, "custom");
+ const char *customformat = SCConfNodeLookupChildValue(conf, "customformat");
/* If custom logging format is selected, lets parse it */
- if (custom != NULL && customformat != NULL && ConfValIsTrue(custom)) {
+ if (custom != NULL && customformat != NULL && SCConfValIsTrue(custom)) {
httplog_ctx->cf = LogCustomFormatAlloc();
if (!httplog_ctx->cf) {
if (extended == NULL) {
httplog_ctx->flags |= LOG_HTTP_DEFAULT;
} else {
- if (ConfValIsTrue(extended)) {
+ if (SCConfValIsTrue(extended)) {
httplog_ctx->flags |= LOG_HTTP_EXTENDED;
}
}
#define SURICATA_LOG_HTTPLOG_H
void LogHttpLogRegister(void);
-OutputInitResult LogHttpLogInitCtx(ConfNode *);
+OutputInitResult LogHttpLogInitCtx(SCConfNode *);
#endif /* SURICATA_LOG_HTTPLOG_H */
static TmEcode PcapLogDataInit(ThreadVars *, const void *, void **);
static TmEcode PcapLogDataDeinit(ThreadVars *, void *);
static void PcapLogFileDeInitCtx(OutputCtx *);
-static OutputInitResult PcapLogInitCtx(ConfNode *);
+static OutputInitResult PcapLogInitCtx(SCConfNode *);
static void PcapLogProfilingDump(PcapLogData *);
static bool PcapLogCondition(ThreadVars *, void *, const Packet *);
* \param conf The configuration node for this output.
* \retval output_ctx
* */
-static OutputInitResult PcapLogInitCtx(ConfNode *conf)
+static OutputInitResult PcapLogInitCtx(SCConfNode *conf)
{
OutputInitResult result = { NULL, false };
int en;
const char *filename = NULL;
if (conf != NULL) { /* To facilitate unit tests. */
- filename = ConfNodeLookupChildValue(conf, "filename");
+ filename = SCConfNodeLookupChildValue(conf, "filename");
}
if (filename == NULL)
pl->size_limit = DEFAULT_LIMIT;
if (conf != NULL) {
const char *s_limit = NULL;
- s_limit = ConfNodeLookupChildValue(conf, "limit");
+ s_limit = SCConfNodeLookupChildValue(conf, "limit");
if (s_limit != NULL) {
if (ParseSizeStringU64(s_limit, &pl->size_limit) < 0) {
SCLogError("Failed to initialize pcap output, invalid limit: %s", s_limit);
if (conf != NULL) {
const char *s_mode = NULL;
- s_mode = ConfNodeLookupChildValue(conf, "mode");
+ s_mode = SCConfNodeLookupChildValue(conf, "mode");
if (s_mode != NULL) {
if (strcasecmp(s_mode, "multi") == 0) {
pl->mode = LOGMODE_MULTI;
}
const char *s_dir = NULL;
- s_dir = ConfNodeLookupChildValue(conf, "dir");
+ s_dir = SCConfNodeLookupChildValue(conf, "dir");
if (s_dir == NULL) {
const char *log_dir = NULL;
- log_dir = ConfigGetLogDirectory();
+ log_dir = SCConfigGetLogDirectory();
strlcpy(pl->dir, log_dir, sizeof(pl->dir));
SCLogInfo("Using log dir %s", pl->dir);
s_dir, sizeof(pl->dir));
} else {
const char *log_dir = NULL;
- log_dir = ConfigGetLogDirectory();
+ log_dir = SCConfigGetLogDirectory();
snprintf(pl->dir, sizeof(pl->dir), "%s/%s",
log_dir, s_dir);
SCLogInfo("Using log dir %s", pl->dir);
}
- const char *compression_str = ConfNodeLookupChildValue(conf,
- "compression");
+ const char *compression_str = SCConfNodeLookupChildValue(conf, "compression");
PcapLogCompressionData *comp = &pl->compression;
if (compression_str == NULL || strcmp(compression_str, "none") == 0) {
memset(&comp->lz4f_prefs, '\0', sizeof(comp->lz4f_prefs));
comp->lz4f_prefs.frameInfo.blockSizeID = LZ4F_max4MB;
comp->lz4f_prefs.frameInfo.blockMode = LZ4F_blockLinked;
- if (ConfNodeChildValueIsTrue(conf, "lz4-checksum")) {
+ if (SCConfNodeChildValueIsTrue(conf, "lz4-checksum")) {
comp->lz4f_prefs.frameInfo.contentChecksumFlag = 1;
- }
- else {
+ } else {
comp->lz4f_prefs.frameInfo.contentChecksumFlag = 0;
}
intmax_t lvl = 0;
- if (ConfGetChildValueInt(conf, "lz4-level", &lvl)) {
+ if (SCConfGetChildValueInt(conf, "lz4-level", &lvl)) {
if (lvl > 16) {
lvl = 16;
} else if (lvl < 0) {
SCLogInfo("Selected pcap-log compression method: %s",
compression_str ? compression_str : "none");
- const char *s_conditional = ConfNodeLookupChildValue(conf, "conditional");
+ const char *s_conditional = SCConfNodeLookupChildValue(conf, "conditional");
if (s_conditional != NULL) {
if (strcasecmp(s_conditional, "alerts") == 0) {
pl->conditional = LOGMODE_COND_ALERTS;
uint32_t max_file_limit = DEFAULT_FILE_LIMIT;
if (conf != NULL) {
const char *max_number_of_files_s = NULL;
- max_number_of_files_s = ConfNodeLookupChildValue(conf, "max-files");
+ max_number_of_files_s = SCConfNodeLookupChildValue(conf, "max-files");
if (max_number_of_files_s != NULL) {
if (StringParseUint32(&max_file_limit, 10, 0,
max_number_of_files_s) == -1) {
const char *ts_format = NULL;
if (conf != NULL) { /* To facilitate unit tests. */
- ts_format = ConfNodeLookupChildValue(conf, "ts-format");
+ ts_format = SCConfNodeLookupChildValue(conf, "ts-format");
}
if (ts_format != NULL) {
if (strcasecmp(ts_format, "usec") == 0) {
const char *use_stream_depth = NULL;
if (conf != NULL) { /* To facilitate unit tests. */
- use_stream_depth = ConfNodeLookupChildValue(conf, "use-stream-depth");
+ use_stream_depth = SCConfNodeLookupChildValue(conf, "use-stream-depth");
}
if (use_stream_depth != NULL) {
- if (ConfValIsFalse(use_stream_depth)) {
+ if (SCConfValIsFalse(use_stream_depth)) {
pl->use_stream_depth = USE_STREAM_DEPTH_DISABLED;
- } else if (ConfValIsTrue(use_stream_depth)) {
+ } else if (SCConfValIsTrue(use_stream_depth)) {
pl->use_stream_depth = USE_STREAM_DEPTH_ENABLED;
} else {
FatalError("log-pcap use_stream_depth specified is invalid must be");
const char *honor_pass_rules = NULL;
if (conf != NULL) { /* To facilitate unit tests. */
- honor_pass_rules = ConfNodeLookupChildValue(conf, "honor-pass-rules");
+ honor_pass_rules = SCConfNodeLookupChildValue(conf, "honor-pass-rules");
}
if (honor_pass_rules != NULL) {
- if (ConfValIsFalse(honor_pass_rules)) {
+ if (SCConfValIsFalse(honor_pass_rules)) {
pl->honor_pass_rules = HONOR_PASS_RULES_DISABLED;
- } else if (ConfValIsTrue(honor_pass_rules)) {
+ } else if (SCConfValIsTrue(honor_pass_rules)) {
pl->honor_pass_rules = HONOR_PASS_RULES_ENABLED;
} else {
FatalError("log-pcap honor-pass-rules specified is invalid");
void PcapLogProfileSetup(void)
{
- ConfNode *conf = ConfGetNode("profiling.pcap-log");
- if (conf != NULL && ConfNodeChildValueIsTrue(conf, "enabled")) {
+ SCConfNode *conf = SCConfGetNode("profiling.pcap-log");
+ if (conf != NULL && SCConfNodeChildValueIsTrue(conf, "enabled")) {
profiling_pcaplog_enabled = 1;
SCLogInfo("pcap-log profiling enabled");
- const char *filename = ConfNodeLookupChildValue(conf, "filename");
+ const char *filename = SCConfNodeLookupChildValue(conf, "filename");
if (filename != NULL) {
const char *log_dir;
- log_dir = ConfigGetLogDirectory();
+ log_dir = SCConfigGetLogDirectory();
profiling_pcaplog_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_pcaplog_file_name == NULL)) {
snprintf(profiling_pcaplog_file_name, PATH_MAX, "%s/%s", log_dir, filename);
- const char *v = ConfNodeLookupChildValue(conf, "append");
- if (v == NULL || ConfValIsTrue(v)) {
+ const char *v = SCConfNodeLookupChildValue(conf, "append");
+ if (v == NULL || SCConfValIsTrue(v)) {
profiling_pcaplog_file_mode = "a";
} else {
profiling_pcaplog_file_mode = "w";
* \param conf Pointer to ConfNode containing this loggers configuration.
* \return NULL if failure, LogFileCtx* to the file_ctx if successful
* */
-static OutputInitResult LogStatsLogInitCtx(ConfNode *conf)
+static OutputInitResult LogStatsLogInitCtx(SCConfNode *conf)
{
OutputInitResult result = { NULL, false };
LogFileCtx *file_ctx = LogFileNewCtx();
statslog_ctx->flags = LOG_STATS_TOTALS;
if (conf != NULL) {
- const char *totals = ConfNodeLookupChildValue(conf, "totals");
- const char *threads = ConfNodeLookupChildValue(conf, "threads");
- const char *nulls = ConfNodeLookupChildValue(conf, "null-values");
+ const char *totals = SCConfNodeLookupChildValue(conf, "totals");
+ const char *threads = SCConfNodeLookupChildValue(conf, "threads");
+ const char *nulls = SCConfNodeLookupChildValue(conf, "null-values");
SCLogDebug("totals %s threads %s", totals, threads);
- if ((totals != NULL && ConfValIsFalse(totals)) &&
- (threads != NULL && ConfValIsFalse(threads))) {
+ if ((totals != NULL && SCConfValIsFalse(totals)) &&
+ (threads != NULL && SCConfValIsFalse(threads))) {
LogFileFreeCtx(file_ctx);
SCFree(statslog_ctx);
SCLogError("Cannot disable both totals and threads in stats logging");
return result;
}
- if (totals != NULL && ConfValIsFalse(totals)) {
+ if (totals != NULL && SCConfValIsFalse(totals)) {
statslog_ctx->flags &= ~LOG_STATS_TOTALS;
}
- if (threads != NULL && ConfValIsTrue(threads)) {
+ if (threads != NULL && SCConfValIsTrue(threads)) {
statslog_ctx->flags |= LOG_STATS_THREADS;
}
- if (nulls != NULL && ConfValIsTrue(nulls)) {
+ if (nulls != NULL && SCConfValIsTrue(nulls)) {
statslog_ctx->flags |= LOG_STATS_NULLS;
}
SCLogDebug("statslog_ctx->flags %08x", statslog_ctx->flags);
* \param conf Pointer to ConfNode containing this loggers configuration.
* \return NULL if failure, LogFileCtx* to the file_ctx if succesful
* */
-OutputInitResult LogTcpDataLogInitCtx(ConfNode *conf)
+OutputInitResult LogTcpDataLogInitCtx(SCConfNode *conf)
{
OutputInitResult result = { NULL, false };
char filename[PATH_MAX] = "";
}
}
- const char *logtype = ConfNodeLookupChildValue(conf, "type");
+ const char *logtype = SCConfNodeLookupChildValue(conf, "type");
if (logtype == NULL)
logtype = "file";
}
if (tcpdatalog_ctx->dir == 1) {
- tcpdatalog_ctx->log_dir = ConfigGetLogDirectory();
+ tcpdatalog_ctx->log_dir = SCConfigGetLogDirectory();
char dirfull[PATH_MAX];
/* create the filename to use */
#include "output.h"
void LogTcpDataLogRegister(void);
-OutputInitResult LogTcpDataLogInitCtx(ConfNode *);
+OutputInitResult LogTcpDataLogInitCtx(SCConfNode *);
#endif /* SURICATA_LOG_TCPDATALOG_H */
* \param conf Pointer to ConfNode containing this loggers configuration.
* \return NULL if failure, LogFileCtx* to the file_ctx if succesful
* */
-static OutputInitResult LogTlsLogInitCtx(ConfNode *conf)
+static OutputInitResult LogTlsLogInitCtx(SCConfNode *conf)
{
SCLogWarning("The tls-log output has been deprecated and will be removed in Suricata 9.0.");
}
tlslog_ctx->file_ctx = file_ctx;
- const char *extended = ConfNodeLookupChildValue(conf, "extended");
- const char *custom = ConfNodeLookupChildValue(conf, "custom");
- const char *customformat = ConfNodeLookupChildValue(conf, "customformat");
+ const char *extended = SCConfNodeLookupChildValue(conf, "extended");
+ const char *custom = SCConfNodeLookupChildValue(conf, "custom");
+ const char *customformat = SCConfNodeLookupChildValue(conf, "customformat");
/* If custom logging format is selected, lets parse it */
- if (custom != NULL && customformat != NULL && ConfValIsTrue(custom)) {
+ if (custom != NULL && customformat != NULL && SCConfValIsTrue(custom)) {
tlslog_ctx->cf = LogCustomFormatAlloc();
if (!tlslog_ctx->cf) {
goto tlslog_error;
if (extended == NULL) {
tlslog_ctx->flags |= LOG_TLS_DEFAULT;
} else {
- if (ConfValIsTrue(extended)) {
+ if (SCConfValIsTrue(extended)) {
tlslog_ctx->flags |= LOG_TLS_EXTENDED;
}
}
}
- const char *resumption = ConfNodeLookupChildValue(conf,
- "session-resumption");
- if (resumption == NULL || ConfValIsTrue(resumption)) {
+ const char *resumption = SCConfNodeLookupChildValue(conf, "session-resumption");
+ if (resumption == NULL || SCConfValIsTrue(resumption)) {
tlslog_ctx->flags |= LOG_TLS_SESSION_RESUMPTION;
}
* \param conf Pointer to ConfNode containing this loggers configuration.
* \return NULL if failure, LogFilestoreCtx* to the file_ctx if succesful
* */
-static OutputInitResult LogTlsStoreLogInitCtx(ConfNode *conf)
+static OutputInitResult LogTlsStoreLogInitCtx(SCConfNode *conf)
{
OutputInitResult result = { NULL, false };
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
output_ctx->data = NULL;
output_ctx->DeInit = LogTlsStoreLogDeInitCtx;
- const char *s_default_log_dir = ConfigGetLogDirectory();
- const char *s_base_dir = ConfNodeLookupChildValue(conf, "certs-log-dir");
+ const char *s_default_log_dir = SCConfigGetLogDirectory();
+ const char *s_base_dir = SCConfNodeLookupChildValue(conf, "certs-log-dir");
if (s_base_dir == NULL || strlen(s_base_dir) == 0) {
strlcpy(tls_logfile_base_dir,
s_default_log_dir, sizeof(tls_logfile_base_dir));
#define OUTPUT_NAME "nullsink"
-static int NullLogInit(const ConfNode *conf, const bool threaded, void **init_data)
+static int NullLogInit(const SCConfNode *conf, const bool threaded, void **init_data)
{
*init_data = NULL;
return 0;
SCFree(output_ctx);
}
-static uint16_t SetFlag(ConfNode *conf, const char *opt, const uint16_t inflag)
+static uint16_t SetFlag(SCConfNode *conf, const char *opt, const uint16_t inflag)
{
- const char *v = ConfNodeLookupChildValue(conf, opt);
- if (v != NULL && ConfValIsTrue(v)) {
+ const char *v = SCConfNodeLookupChildValue(conf, opt);
+ if (v != NULL && SCConfValIsTrue(v)) {
return inflag;
}
return 0;
}
-static OutputInitResult EveStreamLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult EveStreamLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ajt = parent_ctx->data;
int alert_syslog_level;
} Context;
-static int SyslogInit(const ConfNode *conf, const bool threaded, void **init_data)
+static int SyslogInit(const SCConfNode *conf, const bool threaded, void **init_data)
{
Context *context = SCCalloc(1, sizeof(Context));
if (context == NULL) {
SCLogError("Unable to allocate context for %s", OUTPUT_NAME);
return -1;
}
- const char *facility_s = ConfNodeLookupChildValue(conf, "facility");
+ const char *facility_s = SCConfNodeLookupChildValue(conf, "facility");
if (facility_s == NULL) {
facility_s = DEFAULT_ALERT_SYSLOG_FACILITY_STR;
}
facility = DEFAULT_ALERT_SYSLOG_FACILITY;
}
- const char *level_s = ConfNodeLookupChildValue(conf, "level");
+ const char *level_s = SCConfNodeLookupChildValue(conf, "level");
if (level_s != NULL) {
int level = SCMapEnumNameToValue(level_s, SCSyslogGetLogLevelMap());
if (level != -1) {
}
}
- const char *ident = ConfNodeLookupChildValue(conf, "identity");
+ const char *ident = SCConfNodeLookupChildValue(conf, "identity");
/* if null we just pass that to openlog, which will then
* figure it out by itself. */
*
* \retval 0 on success, -1 on failure
*/
- int (*Init)(const ConfNode *conf, const bool threaded, void **init_data);
+ int (*Init)(const SCConfNode *conf, const bool threaded, void **init_data);
/**
* \brief Initialize thread specific data.
SCFree(output_ctx);
}
-static void GetLogDirectory(const ConfNode *conf, char *out, size_t out_size)
+static void GetLogDirectory(const SCConfNode *conf, char *out, size_t out_size)
{
- const char *log_base_dir = ConfNodeLookupChildValue(conf, "dir");
+ const char *log_base_dir = SCConfNodeLookupChildValue(conf, "dir");
if (log_base_dir == NULL) {
SCLogConfig("Filestore (v2) default log directory %s", default_log_dir);
log_base_dir = default_log_dir;
if (PathIsAbsolute(log_base_dir)) {
strlcpy(out, log_base_dir, out_size);
} else {
- const char *default_log_prefix = ConfigGetLogDirectory();
+ const char *default_log_prefix = SCConfigGetLogDirectory();
snprintf(out, out_size, "%s/%s", default_log_prefix, log_base_dir);
}
}
* \param conf Pointer to ConfNode containing this loggers configuration.
* \return NULL if failure, OutputFilestoreCtx* to the file_ctx if succesful
* */
-static OutputInitResult OutputFilestoreLogInitCtx(ConfNode *conf)
+static OutputInitResult OutputFilestoreLogInitCtx(SCConfNode *conf)
{
OutputInitResult result = { NULL, false };
intmax_t version = 0;
- if (!ConfGetChildValueInt(conf, "version", &version) || version < 2) {
+ if (!SCConfGetChildValueInt(conf, "version", &version) || version < 2) {
SCLogWarning("File-store v1 has been removed. Please update to file-store v2.");
return result;
}
output_ctx->data = ctx;
output_ctx->DeInit = OutputFilestoreLogDeInitCtx;
- const char *write_fileinfo = ConfNodeLookupChildValue(conf,
- "write-fileinfo");
- if (write_fileinfo != NULL && ConfValIsTrue(write_fileinfo)) {
+ const char *write_fileinfo = SCConfNodeLookupChildValue(conf, "write-fileinfo");
+ if (write_fileinfo != NULL && SCConfValIsTrue(write_fileinfo)) {
SCLogConfig("Filestore (v2) will output fileinfo records.");
ctx->fileinfo = true;
}
- const char *force_filestore = ConfNodeLookupChildValue(conf,
- "force-filestore");
- if (force_filestore != NULL && ConfValIsTrue(force_filestore)) {
+ const char *force_filestore = SCConfNodeLookupChildValue(conf, "force-filestore");
+ if (force_filestore != NULL && SCConfValIsTrue(force_filestore)) {
FileForceFilestoreEnable();
SCLogInfo("forcing filestore of all files");
}
- const char *force_magic = ConfNodeLookupChildValue(conf, "force-magic");
- if (force_magic != NULL && ConfValIsTrue(force_magic)) {
+ const char *force_magic = SCConfNodeLookupChildValue(conf, "force-magic");
+ if (force_magic != NULL && SCConfValIsTrue(force_magic)) {
FileForceMagicEnable();
SCLogConfig("Filestore (v2) forcing magic lookup for stored files");
}
ProvidesFeature(FEATURE_OUTPUT_FILESTORE);
- const char *stream_depth_str = ConfNodeLookupChildValue(conf,
- "stream-depth");
+ const char *stream_depth_str = SCConfNodeLookupChildValue(conf, "stream-depth");
if (stream_depth_str != NULL && strcmp(stream_depth_str, "no")) {
uint32_t stream_depth = 0;
if (ParseSizeStringU32(stream_depth_str,
}
}
- const char *file_count_str = ConfNodeLookupChildValue(conf,
- "max-open-files");
+ const char *file_count_str = SCConfNodeLookupChildValue(conf, "max-open-files");
if (file_count_str != NULL) {
uint32_t file_count = 0;
if (ParseSizeStringU32(file_count_str,
SCFree(output_ctx);
}
-static void SetFlag(const ConfNode *conf, const char *name, uint16_t flag, uint16_t *out_flags)
+static void SetFlag(const SCConfNode *conf, const char *name, uint16_t flag, uint16_t *out_flags)
{
DEBUG_VALIDATE_BUG_ON(conf == NULL);
- const char *setting = ConfNodeLookupChildValue(conf, name);
+ const char *setting = SCConfNodeLookupChildValue(conf, name);
if (setting != NULL) {
- if (ConfValIsTrue(setting)) {
+ if (SCConfValIsTrue(setting)) {
*out_flags |= flag;
} else {
*out_flags &= ~flag;
}
}
-static void JsonAlertLogSetupMetadata(AlertJsonOutputCtx *json_output_ctx,
- ConfNode *conf)
+static void JsonAlertLogSetupMetadata(AlertJsonOutputCtx *json_output_ctx, SCConfNode *conf)
{
static bool warn_no_meta = false;
uint32_t payload_buffer_size = JSON_STREAM_BUFFER_SIZE;
if (conf != NULL) {
/* Check for metadata to enable/disable. */
- ConfNode *metadata = ConfNodeLookupChild(conf, "metadata");
+ SCConfNode *metadata = SCConfNodeLookupChild(conf, "metadata");
if (metadata != NULL) {
- if (metadata->val != NULL && ConfValIsFalse(metadata->val)) {
+ if (metadata->val != NULL && SCConfValIsFalse(metadata->val)) {
flags &= ~METADATA_DEFAULTS;
- } else if (ConfNodeHasChildren(metadata)) {
- ConfNode *rule_metadata = ConfNodeLookupChild(metadata, "rule");
+ } else if (SCConfNodeHasChildren(metadata)) {
+ SCConfNode *rule_metadata = SCConfNodeLookupChild(metadata, "rule");
if (rule_metadata) {
SetFlag(rule_metadata, "raw", LOG_JSON_RULE, &flags);
SetFlag(rule_metadata, "metadata", LOG_JSON_RULE_METADATA,
static const char *deprecated_flags[] = { "http", "tls", "ssh", "smtp", "dnp3", "app-layer",
"flow", NULL };
for (int i = 0; deprecated_flags[i] != NULL; i++) {
- if (ConfNodeLookupChildValue(conf, deprecated_flags[i]) != NULL) {
+ if (SCConfNodeLookupChildValue(conf, deprecated_flags[i]) != NULL) {
SCLogWarning("Found deprecated eve-log.alert flag \"%s\", this flag has no effect",
deprecated_flags[i]);
}
}
- const char *payload_buffer_value = ConfNodeLookupChildValue(conf, "payload-buffer-size");
+ const char *payload_buffer_value = SCConfNodeLookupChildValue(conf, "payload-buffer-size");
if (payload_buffer_value != NULL) {
uint32_t value;
json_output_ctx->flags |= flags;
}
-static HttpXFFCfg *JsonAlertLogGetXffCfg(ConfNode *conf)
+static HttpXFFCfg *JsonAlertLogGetXffCfg(SCConfNode *conf)
{
HttpXFFCfg *xff_cfg = NULL;
- if (conf != NULL && ConfNodeLookupChild(conf, "xff") != NULL) {
+ if (conf != NULL && SCConfNodeLookupChild(conf, "xff") != NULL) {
xff_cfg = SCCalloc(1, sizeof(HttpXFFCfg));
if (likely(xff_cfg != NULL)) {
HttpXFFGetCfg(conf, xff_cfg);
* \param conf The configuration node for this output.
* \return A LogFileCtx pointer on success, NULL on failure.
*/
-static OutputInitResult JsonAlertLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult JsonAlertLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ajt = parent_ctx->data;
JsonAnomalyLogDeInitCtxSubHelper(output_ctx);
}
-static void SetFlag(const ConfNode *conf, const char *name, uint16_t flag, uint16_t *out_flags)
+static void SetFlag(const SCConfNode *conf, const char *name, uint16_t flag, uint16_t *out_flags)
{
DEBUG_VALIDATE_BUG_ON(conf == NULL);
- const char *setting = ConfNodeLookupChildValue(conf, name);
+ const char *setting = SCConfNodeLookupChildValue(conf, name);
if (setting != NULL) {
- if (ConfValIsTrue(setting)) {
+ if (SCConfValIsTrue(setting)) {
*out_flags |= flag;
} else {
*out_flags &= ~flag;
}
}
-static void JsonAnomalyLogConf(AnomalyJsonOutputCtx *json_output_ctx,
- ConfNode *conf)
+static void JsonAnomalyLogConf(AnomalyJsonOutputCtx *json_output_ctx, SCConfNode *conf)
{
static bool warn_no_flags = false;
static bool warn_no_packet = false;
uint16_t flags = ANOMALY_DEFAULTS;
if (conf != NULL) {
/* Check for metadata to enable/disable. */
- ConfNode *typeconf = ConfNodeLookupChild(conf, "types");
+ SCConfNode *typeconf = SCConfNodeLookupChild(conf, "types");
if (typeconf != NULL) {
SetFlag(typeconf, "applayer", LOG_JSON_APPLAYER_TYPE, &flags);
SetFlag(typeconf, "stream", LOG_JSON_STREAM_TYPE, &flags);
json_output_ctx->flags |= flags;
}
-static OutputInitResult JsonAnomalyLogInitCtxHelper(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult JsonAnomalyLogInitCtxHelper(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ajt = parent_ctx->data;
* \param conf The configuration node for this output.
* \return A LogFileCtx pointer on success, NULL on failure.
*/
-static OutputInitResult JsonAnomalyLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult JsonAnomalyLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
if (!OutputAnomalyLoggerEnable()) {
return 0;
}
-OutputInitResult OutputJsonLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+OutputInitResult OutputJsonLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
return TM_ECODE_FAILED;
}
-static OutputInitResult DCERPCLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult DCERPCLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_DCERPC);
AppLayerParserRegisterLogger(IPPROTO_UDP, ALPROTO_DCERPC);
SCFree(output_ctx);
}
-static OutputInitResult OutputDHCPLogInitSub(ConfNode *conf,
- OutputCtx *parent_ctx)
+static OutputInitResult OutputDHCPLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
SCFree(output_ctx);
}
-static OutputInitResult OutputDNP3LogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult OutputDNP3LogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *json_ctx = parent_ctx->data;
SCFree(output_ctx);
}
-static void JsonDnsLogParseConfig(LogDnsFileCtx *dnslog_ctx, ConfNode *conf,
- const char *query_key, const char *answer_key,
- const char *answer_types_key)
+static void JsonDnsLogParseConfig(LogDnsFileCtx *dnslog_ctx, SCConfNode *conf,
+ const char *query_key, const char *answer_key, const char *answer_types_key)
{
- const char *query = ConfNodeLookupChildValue(conf, query_key);
+ const char *query = SCConfNodeLookupChildValue(conf, query_key);
if (query != NULL) {
- if (ConfValIsTrue(query)) {
+ if (SCConfValIsTrue(query)) {
dnslog_ctx->flags |= LOG_QUERIES;
} else {
dnslog_ctx->flags &= ~LOG_QUERIES;
dnslog_ctx->flags |= LOG_QUERIES;
}
- const char *response = ConfNodeLookupChildValue(conf, answer_key);
+ const char *response = SCConfNodeLookupChildValue(conf, answer_key);
if (response != NULL) {
- if (ConfValIsTrue(response)) {
+ if (SCConfValIsTrue(response)) {
dnslog_ctx->flags |= LOG_ANSWERS;
} else {
dnslog_ctx->flags &= ~LOG_ANSWERS;
dnslog_ctx->flags |= LOG_ANSWERS;
}
- ConfNode *custom;
- if ((custom = ConfNodeLookupChild(conf, answer_types_key)) != NULL) {
+ SCConfNode *custom;
+ if ((custom = SCConfNodeLookupChild(conf, answer_types_key)) != NULL) {
dnslog_ctx->flags &= ~LOG_ALL_RRTYPES;
- ConfNode *field;
+ SCConfNode *field;
TAILQ_FOREACH (field, &custom->head, next) {
DnsRRTypes f;
for (f = DNS_RRTYPE_A; f < DNS_RRTYPE_MAX; f++) {
}
}
-static uint8_t GetDnsLogVersion(ConfNode *conf)
+static uint8_t GetDnsLogVersion(SCConfNode *conf)
{
if (conf == NULL) {
return DNS_LOG_VERSION_DEFAULT;
}
char *version_string = NULL;
- const ConfNode *version_node = ConfNodeLookupChild(conf, "version");
+ const SCConfNode *version_node = SCConfNodeLookupChild(conf, "version");
if (version_node != NULL) {
version_string = version_node->val;
}
return DNS_LOG_VERSION_DEFAULT;
}
-static uint8_t JsonDnsCheckVersion(ConfNode *conf)
+static uint8_t JsonDnsCheckVersion(SCConfNode *conf)
{
const uint8_t default_version = DNS_LOG_VERSION_DEFAULT;
const uint8_t version = GetDnsLogVersion(conf);
return default_version;
}
-static void JsonDnsLogInitFilters(LogDnsFileCtx *dnslog_ctx, ConfNode *conf)
+static void JsonDnsLogInitFilters(LogDnsFileCtx *dnslog_ctx, SCConfNode *conf)
{
dnslog_ctx->flags = ~0ULL;
if (conf) {
JsonDnsLogParseConfig(dnslog_ctx, conf, "requests", "responses", "types");
if (dnslog_ctx->flags & LOG_ANSWERS) {
- ConfNode *format;
- if ((format = ConfNodeLookupChild(conf, "formats")) != NULL) {
+ SCConfNode *format;
+ if ((format = SCConfNodeLookupChild(conf, "formats")) != NULL) {
uint64_t flags = 0;
- ConfNode *field;
+ SCConfNode *field;
TAILQ_FOREACH (field, &format->head, next) {
if (strcasecmp(field->val, "detailed") == 0) {
flags |= LOG_FORMAT_DETAILED;
}
}
-static OutputInitResult JsonDnsLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult JsonDnsLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
- const char *enabled = ConfNodeLookupChildValue(conf, "enabled");
- if (enabled != NULL && !ConfValIsTrue(enabled)) {
+ const char *enabled = SCConfNodeLookupChildValue(conf, "enabled");
+ if (enabled != NULL && !SCConfValIsTrue(enabled)) {
result.ok = true;
return result;
}
SCFree(output_ctx);
}
-static OutputInitResult JsonDropLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult JsonDropLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
if (OutputDropLoggerEnable() != 0) {
}
if (conf) {
- const char *extended = ConfNodeLookupChildValue(conf, "alerts");
+ const char *extended = SCConfNodeLookupChildValue(conf, "alerts");
if (extended != NULL) {
- if (ConfValIsTrue(extended)) {
+ if (SCConfValIsTrue(extended)) {
drop_ctx->flags |= LOG_DROP_ALERTS;
}
}
- extended = ConfNodeLookupChildValue(conf, "flows");
+ extended = SCConfNodeLookupChildValue(conf, "flows");
if (extended != NULL) {
if (strcasecmp(extended, "start") == 0) {
g_droplog_flows_start = 1;
"'flow' are 'start' and 'all'");
}
}
- extended = ConfNodeLookupChildValue(conf, "verdict");
+ extended = SCConfNodeLookupChildValue(conf, "verdict");
if (extended != NULL) {
- if (ConfValIsTrue(extended)) {
+ if (SCConfValIsTrue(extended)) {
drop_ctx->flags |= LOG_DROP_VERDICT;
}
}
return false;
}
-void OutputEmailInitConf(ConfNode *conf, OutputJsonEmailCtx *email_ctx)
+void OutputEmailInitConf(SCConfNode *conf, OutputJsonEmailCtx *email_ctx)
{
if (conf) {
- const char *extended = ConfNodeLookupChildValue(conf, "extended");
+ const char *extended = SCConfNodeLookupChildValue(conf, "extended");
if (extended != NULL) {
- if (ConfValIsTrue(extended)) {
+ if (SCConfValIsTrue(extended)) {
email_ctx->flags = LOG_EMAIL_EXTENDED;
}
}
email_ctx->fields = 0;
- ConfNode *custom;
- if ((custom = ConfNodeLookupChild(conf, "custom")) != NULL) {
- ConfNode *field;
+ SCConfNode *custom;
+ if ((custom = SCConfNodeLookupChild(conf, "custom")) != NULL) {
+ SCConfNode *field;
TAILQ_FOREACH (field, &custom->head, next) {
int f = 0;
while (email_fields[f].config_field) {
}
email_ctx->flags = 0;
- ConfNode *md5_conf;
- if ((md5_conf = ConfNodeLookupChild(conf, "md5")) != NULL) {
- ConfNode *field;
+ SCConfNode *md5_conf;
+ if ((md5_conf = SCConfNodeLookupChild(conf, "md5")) != NULL) {
+ SCConfNode *field;
TAILQ_FOREACH (field, &md5_conf->head, next) {
if (strcmp("body", field->val) == 0) {
SCLogInfo("Going to log the md5 sum of email body");
TmEcode EveEmailLogJson(JsonEmailLogThread *aft, JsonBuilder *js, const Packet *p, Flow *f, void *state, void *vtx, uint64_t tx_id);
bool EveEmailAddMetadata(const Flow *f, uint64_t tx_id, JsonBuilder *js);
-void OutputEmailInitConf(ConfNode *conf, OutputJsonEmailCtx *email_ctx);
+void OutputEmailInitConf(SCConfNode *conf, OutputJsonEmailCtx *email_ctx);
#endif /* SURICATA_OUTPUT_JSON_EMAIL_COMMON_H */
* \param conf Pointer to ConfNode containing this loggers configuration.
* \return NULL if failure, LogFileCtx* to the file_ctx if succesful
* */
-static OutputInitResult OutputFileLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult OutputFileLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ojc = parent_ctx->data;
}
if (conf) {
- const char *force_filestore = ConfNodeLookupChildValue(conf, "force-filestore");
- if (force_filestore != NULL && ConfValIsTrue(force_filestore)) {
+ const char *force_filestore = SCConfNodeLookupChildValue(conf, "force-filestore");
+ if (force_filestore != NULL && SCConfValIsTrue(force_filestore)) {
FileForceFilestoreEnable();
SCLogConfig("forcing filestore of all files");
}
- const char *force_magic = ConfNodeLookupChildValue(conf, "force-magic");
- if (force_magic != NULL && ConfValIsTrue(force_magic)) {
+ const char *force_magic = SCConfNodeLookupChildValue(conf, "force-magic");
+ if (force_magic != NULL && SCConfValIsTrue(force_magic)) {
FileForceMagicEnable();
SCLogConfig("forcing magic lookup for logged files");
}
FileForceHashParseCfg(conf);
}
- if (conf != NULL && ConfNodeLookupChild(conf, "xff") != NULL) {
+ if (conf != NULL && SCConfNodeLookupChild(conf, "xff") != NULL) {
output_file_ctx->xff_cfg = SCCalloc(1, sizeof(HttpXFFCfg));
if (output_file_ctx->xff_cfg != NULL) {
HttpXFFGetCfg(conf, output_file_ctx->xff_cfg);
* \param conf The configuration node for this output.
* \return A LogFileCtx pointer on success, NULL on failure.
*/
-static OutputInitResult JsonFrameLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult JsonFrameLogInitCtxSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ajt = parent_ctx->data;
uint32_t payload_buffer_size = 4096;
if (conf != NULL) {
- const char *payload_buffer_value = ConfNodeLookupChildValue(conf, "payload-buffer-size");
+ const char *payload_buffer_value = SCConfNodeLookupChildValue(conf, "payload-buffer-size");
if (payload_buffer_value != NULL) {
uint32_t value;
if (ParseSizeStringU32(payload_buffer_value, &value) < 0) {
SCFree(output_ctx);
}
-static OutputInitResult OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult OutputHttpLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ojc = parent_ctx->data;
http_ctx->eve_ctx = ojc;
if (conf) {
- const char *extended = ConfNodeLookupChildValue(conf, "extended");
+ const char *extended = SCConfNodeLookupChildValue(conf, "extended");
if (extended != NULL) {
- if (ConfValIsTrue(extended)) {
+ if (SCConfValIsTrue(extended)) {
http_ctx->flags = LOG_HTTP_EXTENDED;
}
}
- const char *all_headers = ConfNodeLookupChildValue(conf, "dump-all-headers");
+ const char *all_headers = SCConfNodeLookupChildValue(conf, "dump-all-headers");
if (all_headers != NULL) {
if (strncmp(all_headers, "both", 4) == 0) {
http_ctx->flags |= LOG_HTTP_REQ_HEADERS;
http_ctx->flags |= LOG_HTTP_RES_HEADERS;
}
}
- ConfNode *custom;
- if ((custom = ConfNodeLookupChild(conf, "custom")) != NULL) {
+ SCConfNode *custom;
+ if ((custom = SCConfNodeLookupChild(conf, "custom")) != NULL) {
if ((http_ctx->flags & (LOG_HTTP_REQ_HEADERS | LOG_HTTP_RES_HEADERS)) ==
(LOG_HTTP_REQ_HEADERS | LOG_HTTP_RES_HEADERS)) {
SCLogWarning("No need for custom as dump-all-headers is already present");
}
- ConfNode *field;
+ SCConfNode *field;
TAILQ_FOREACH (field, &custom->head, next) {
HttpField f;
for (f = HTTP_FIELD_ACCEPT; f < HTTP_FIELD_SIZE; f++) {
}
}
- if (conf != NULL && ConfNodeLookupChild(conf, "xff") != NULL) {
+ if (conf != NULL && SCConfNodeLookupChild(conf, "xff") != NULL) {
http_ctx->xff_cfg = SCCalloc(1, sizeof(HttpXFFCfg));
if (http_ctx->xff_cfg != NULL) {
HttpXFFGetCfg(conf, http_ctx->xff_cfg);
SCFree(output_ctx);
}
-static OutputInitResult OutputIKELogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult OutputIKELogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ajt = parent_ctx->data;
}
ikelog_ctx->flags = LOG_IKE_DEFAULT;
- const char *extended = ConfNodeLookupChildValue(conf, "extended");
+ const char *extended = SCConfNodeLookupChildValue(conf, "extended");
if (extended) {
- if (ConfValIsTrue(extended)) {
+ if (SCConfValIsTrue(extended)) {
ikelog_ctx->flags = LOG_IKE_EXTENDED;
}
}
SCFree(output_ctx);
}
-static void JsonMQTTLogParseConfig(ConfNode *conf, LogMQTTFileCtx *mqttlog_ctx)
+static void JsonMQTTLogParseConfig(SCConfNode *conf, LogMQTTFileCtx *mqttlog_ctx)
{
- const char *query = ConfNodeLookupChildValue(conf, "passwords");
+ const char *query = SCConfNodeLookupChildValue(conf, "passwords");
if (query != NULL) {
- if (ConfValIsTrue(query)) {
+ if (SCConfValIsTrue(query)) {
mqttlog_ctx->flags |= MQTT_LOG_PASSWORDS;
} else {
mqttlog_ctx->flags &= ~MQTT_LOG_PASSWORDS;
mqttlog_ctx->flags |= MQTT_LOG_PASSWORDS;
}
uint32_t max_log_len = MQTT_DEFAULT_MAXLOGLEN;
- query = ConfNodeLookupChildValue(conf, "string-log-limit");
+ query = SCConfNodeLookupChildValue(conf, "string-log-limit");
if (query != NULL) {
if (ParseSizeStringU32(query, &max_log_len) < 0) {
SCLogError("Error parsing string-log-limit from config - %s, ", query);
mqttlog_ctx->max_log_len = max_log_len;
}
-static OutputInitResult OutputMQTTLogInitSub(ConfNode *conf,
- OutputCtx *parent_ctx)
+static OutputInitResult OutputMQTTLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ajt = parent_ctx->data;
return TM_ECODE_OK;
}
-static OutputInitResult NFSLogInitSub(ConfNode *conf,
- OutputCtx *parent_ctx)
+static OutputInitResult NFSLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_NFS);
AppLayerParserRegisterLogger(IPPROTO_UDP, ALPROTO_NFS);
SCFree(output_ctx);
}
-static void JsonPgsqlLogParseConfig(ConfNode *conf, OutputPgsqlCtx *pgsqllog_ctx)
+static void JsonPgsqlLogParseConfig(SCConfNode *conf, OutputPgsqlCtx *pgsqllog_ctx)
{
pgsqllog_ctx->flags = ~0U;
- const char *query = ConfNodeLookupChildValue(conf, "passwords");
+ const char *query = SCConfNodeLookupChildValue(conf, "passwords");
if (query != NULL) {
- if (ConfValIsTrue(query)) {
+ if (SCConfValIsTrue(query)) {
pgsqllog_ctx->flags |= PGSQL_LOG_PASSWORDS;
} else {
pgsqllog_ctx->flags &= ~PGSQL_LOG_PASSWORDS;
}
}
-static OutputInitResult OutputPgsqlLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult OutputPgsqlLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ojc = parent_ctx->data;
void JsonPgsqlLogRegister(void)
{
/* PGSQL_START_REMOVE */
- if (ConfGetNode("app-layer.protocols.pgsql") == NULL) {
+ if (SCConfGetNode("app-layer.protocols.pgsql") == NULL) {
SCLogDebug("Disabling Pgsql eve-logger");
return;
}
return TM_ECODE_FAILED;
}
-static OutputInitResult SMBLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult SMBLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_SMB);
AppLayerParserRegisterLogger(IPPROTO_UDP, ALPROTO_SMB);
SCFree(output_ctx);
}
-static OutputInitResult OutputSmtpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult OutputSmtpLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ojc = parent_ctx->data;
SCFree(output_ctx);
}
-static OutputInitResult OutputStatsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult OutputStatsLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ajt = parent_ctx->data;
stats_ctx->flags = JSON_STATS_TOTALS;
if (conf != NULL) {
- const char *totals = ConfNodeLookupChildValue(conf, "totals");
- const char *threads = ConfNodeLookupChildValue(conf, "threads");
- const char *deltas = ConfNodeLookupChildValue(conf, "deltas");
- const char *zero_counters = ConfNodeLookupChildValue(conf, "null-values");
+ const char *totals = SCConfNodeLookupChildValue(conf, "totals");
+ const char *threads = SCConfNodeLookupChildValue(conf, "threads");
+ const char *deltas = SCConfNodeLookupChildValue(conf, "deltas");
+ const char *zero_counters = SCConfNodeLookupChildValue(conf, "null-values");
SCLogDebug("totals %s threads %s deltas %s", totals, threads, deltas);
- if ((totals != NULL && ConfValIsFalse(totals)) &&
- (threads != NULL && ConfValIsFalse(threads))) {
+ if ((totals != NULL && SCConfValIsFalse(totals)) &&
+ (threads != NULL && SCConfValIsFalse(threads))) {
SCFree(stats_ctx);
SCLogError("Cannot disable both totals and threads in stats logging");
return result;
}
- if (totals != NULL && ConfValIsFalse(totals)) {
+ if (totals != NULL && SCConfValIsFalse(totals)) {
stats_ctx->flags &= ~JSON_STATS_TOTALS;
}
- if (threads != NULL && ConfValIsTrue(threads)) {
+ if (threads != NULL && SCConfValIsTrue(threads)) {
stats_ctx->flags |= JSON_STATS_THREADS;
}
- if (deltas != NULL && ConfValIsTrue(deltas)) {
+ if (deltas != NULL && SCConfValIsTrue(deltas)) {
stats_ctx->flags |= JSON_STATS_DELTAS;
}
- if (zero_counters != NULL && ConfValIsFalse(zero_counters)) {
+ if (zero_counters != NULL && SCConfValIsFalse(zero_counters)) {
stats_ctx->flags |= JSON_STATS_NO_ZEROES;
}
SCLogDebug("stats_ctx->flags %08x", stats_ctx->flags);
return TM_ECODE_OK;
}
-static OutputTlsCtx *OutputTlsInitCtx(ConfNode *conf)
+static OutputTlsCtx *OutputTlsInitCtx(SCConfNode *conf)
{
OutputTlsCtx *tls_ctx = SCCalloc(1, sizeof(OutputTlsCtx));
if (unlikely(tls_ctx == NULL))
if (conf == NULL)
return tls_ctx;
- const char *extended = ConfNodeLookupChildValue(conf, "extended");
+ const char *extended = SCConfNodeLookupChildValue(conf, "extended");
if (extended) {
- if (ConfValIsTrue(extended)) {
+ if (SCConfValIsTrue(extended)) {
tls_ctx->fields = EXTENDED_FIELDS;
}
}
- ConfNode *custom = ConfNodeLookupChild(conf, "custom");
+ SCConfNode *custom = SCConfNodeLookupChild(conf, "custom");
if (custom) {
tls_ctx->fields = 0;
- ConfNode *field;
+ SCConfNode *field;
TAILQ_FOREACH(field, &custom->head, next)
{
bool valid = false;
}
}
- const char *session_resumption = ConfNodeLookupChildValue(conf, "session-resumption");
- if (session_resumption == NULL || ConfValIsTrue(session_resumption)) {
+ const char *session_resumption = SCConfNodeLookupChildValue(conf, "session-resumption");
+ if (session_resumption == NULL || SCConfValIsTrue(session_resumption)) {
tls_ctx->fields |= LOG_TLS_FIELD_SESSION_RESUMED;
tls_ctx->session_resumed = true;
}
SCFree(output_ctx);
}
-static OutputInitResult OutputTlsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult OutputTlsLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
OutputJsonCtx *ojc = parent_ctx->data;
}
static int LogFileTypePrepare(
- OutputJsonCtx *json_ctx, enum LogFileType log_filetype, ConfNode *conf)
+ OutputJsonCtx *json_ctx, enum LogFileType log_filetype, SCConfNode *conf)
{
if (log_filetype == LOGFILE_TYPE_FILE || log_filetype == LOGFILE_TYPE_UNIX_DGRAM ||
#ifdef HAVE_LIBHIREDIS
else if (log_filetype == LOGFILE_TYPE_REDIS) {
SCLogRedisInit();
- ConfNode *redis_node = ConfNodeLookupChild(conf, "redis");
+ SCConfNode *redis_node = SCConfNodeLookupChild(conf, "redis");
if (!json_ctx->file_ctx->sensor_name) {
char hostname[1024];
gethostname(hostname, 1023);
* \param conf The configuration node for this output.
* \return A LogFileCtx pointer on success, NULL on failure.
*/
-OutputInitResult OutputJsonInitCtx(ConfNode *conf)
+OutputInitResult OutputJsonInitCtx(SCConfNode *conf)
{
OutputInitResult result = { NULL, false };
OutputCtx *output_ctx = NULL;
/* First lookup a sensor-name value in this outputs configuration
* node (deprecated). If that fails, lookup the global one. */
- const char *sensor_name = ConfNodeLookupChildValue(conf, "sensor-name");
+ const char *sensor_name = SCConfNodeLookupChildValue(conf, "sensor-name");
if (sensor_name != NULL) {
SCLogWarning("Found deprecated eve-log setting \"sensor-name\". "
"Please set sensor-name globally.");
}
else {
- (void)ConfGet("sensor-name", &sensor_name);
+ (void)SCConfGet("sensor-name", &sensor_name);
}
json_ctx->file_ctx = LogFileNewCtx();
output_ctx->DeInit = OutputJsonDeInitCtx;
if (conf) {
- const char *output_s = ConfNodeLookupChildValue(conf, "filetype");
+ const char *output_s = SCConfNodeLookupChildValue(conf, "filetype");
// Backwards compatibility
if (output_s == NULL) {
- output_s = ConfNodeLookupChildValue(conf, "type");
+ output_s = SCConfNodeLookupChildValue(conf, "type");
}
enum LogFileType log_filetype = FileTypeFromConf(output_s);
FatalError("Invalid JSON output option: %s", output_s);
}
- const char *prefix = ConfNodeLookupChildValue(conf, "prefix");
+ const char *prefix = SCConfNodeLookupChildValue(conf, "prefix");
if (prefix != NULL)
{
SCLogInfo("Using prefix '%s' for JSON messages", prefix);
}
/* Threaded file output */
- const ConfNode *threaded = ConfNodeLookupChild(conf, "threaded");
- if (threaded && threaded->val && ConfValIsTrue(threaded->val)) {
+ const SCConfNode *threaded = SCConfNodeLookupChild(conf, "threaded");
+ if (threaded && threaded->val && SCConfValIsTrue(threaded->val)) {
SCLogConfig("Threaded EVE logging configured");
json_ctx->file_ctx->threaded = true;
} else {
goto error_exit;
}
- const char *sensor_id_s = ConfNodeLookupChildValue(conf, "sensor-id");
+ const char *sensor_id_s = SCConfNodeLookupChildValue(conf, "sensor-id");
if (sensor_id_s != NULL) {
if (StringParseUint64((uint64_t *)&sensor_id, 10, 0, sensor_id_s) < 0) {
FatalError("Failed to initialize JSON output, "
}
/* Check if top-level metadata should be logged. */
- const ConfNode *metadata = ConfNodeLookupChild(conf, "metadata");
- if (metadata && metadata->val && ConfValIsFalse(metadata->val)) {
+ const SCConfNode *metadata = SCConfNodeLookupChild(conf, "metadata");
+ if (metadata && metadata->val && SCConfValIsFalse(metadata->val)) {
SCLogConfig("Disabling eve metadata logging.");
json_ctx->cfg.include_metadata = false;
} else {
}
/* Check if ethernet information should be logged. */
- const ConfNode *ethernet = ConfNodeLookupChild(conf, "ethernet");
- if (ethernet && ethernet->val && ConfValIsTrue(ethernet->val)) {
+ const SCConfNode *ethernet = SCConfNodeLookupChild(conf, "ethernet");
+ if (ethernet && ethernet->val && SCConfValIsTrue(ethernet->val)) {
SCLogConfig("Enabling Ethernet MAC address logging.");
json_ctx->cfg.include_ethernet = true;
} else {
}
/* See if we want to enable the community id */
- const ConfNode *community_id = ConfNodeLookupChild(conf, "community-id");
- if (community_id && community_id->val && ConfValIsTrue(community_id->val)) {
+ const SCConfNode *community_id = SCConfNodeLookupChild(conf, "community-id");
+ if (community_id && community_id->val && SCConfValIsTrue(community_id->val)) {
SCLogConfig("Enabling eve community_id logging.");
json_ctx->cfg.include_community_id = true;
} else {
json_ctx->cfg.include_community_id = false;
}
- const char *cid_seed = ConfNodeLookupChildValue(conf, "community-id-seed");
+ const char *cid_seed = SCConfNodeLookupChildValue(conf, "community-id-seed");
if (cid_seed != NULL) {
if (StringParseUint16(&json_ctx->cfg.community_id_seed,
10, 0, cid_seed) < 0)
}
/* Do we have a global eve xff configuration? */
- const ConfNode *xff = ConfNodeLookupChild(conf, "xff");
+ const SCConfNode *xff = SCConfNodeLookupChild(conf, "xff");
if (xff != NULL) {
json_ctx->xff_cfg = SCCalloc(1, sizeof(HttpXFFCfg));
if (likely(json_ctx->xff_cfg != NULL)) {
}
}
- const char *pcapfile_s = ConfNodeLookupChildValue(conf, "pcap-file");
- if (pcapfile_s != NULL && ConfValIsTrue(pcapfile_s)) {
+ const char *pcapfile_s = SCConfNodeLookupChildValue(conf, "pcap-file");
+ if (pcapfile_s != NULL && SCConfValIsTrue(pcapfile_s)) {
json_ctx->file_ctx->is_pcap_offline =
(SCRunmodeGet() == RUNMODE_PCAP_FILE || SCRunmodeGet() == RUNMODE_UNIX_SOCKET);
}
int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer **buffer);
void OutputJsonBuilderBuffer(
ThreadVars *tv, const Packet *p, Flow *f, JsonBuilder *js, OutputJsonThreadCtx *ctx);
-OutputInitResult OutputJsonInitCtx(ConfNode *);
+OutputInitResult OutputJsonInitCtx(SCConfNode *);
-OutputInitResult OutputJsonLogInitSub(ConfNode *conf, OutputCtx *parent_ctx);
+OutputInitResult OutputJsonLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx);
TmEcode JsonLogThreadInit(ThreadVars *t, const void *initdata, void **data);
TmEcode JsonLogThreadDeinit(ThreadVars *t, void *data);
*
* Runs script 'setup' function.
*/
-static OutputInitResult OutputLuaLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
+static OutputInitResult OutputLuaLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
if (conf == NULL)
* inspect, then fills the OutputCtx::submodules list with the
* proper Logger function for the data type the script needs.
*/
-static OutputInitResult OutputLuaLogInit(ConfNode *conf)
+static OutputInitResult OutputLuaLogInit(SCConfNode *conf)
{
OutputInitResult result = { NULL, false };
- const char *dir = ConfNodeLookupChildValue(conf, "scripts-dir");
+ const char *dir = SCConfNodeLookupChildValue(conf, "scripts-dir");
if (dir == NULL)
dir = "";
- ConfNode *scripts = ConfNodeLookupChild(conf, "scripts");
+ SCConfNode *scripts = SCConfNodeLookupChild(conf, "scripts");
if (scripts == NULL) {
/* No "outputs" section in the configuration. */
SCLogInfo("scripts not defined");
LogLuaMasterCtx *master_config = output_ctx->data;
strlcpy(master_config->script_dir, dir, sizeof(master_config->script_dir));
- const char *lua_path = ConfNodeLookupChildValue(conf, "path");
+ const char *lua_path = SCConfNodeLookupChildValue(conf, "path");
if (lua_path && strlen(lua_path) > 0) {
strlcpy(master_config->path, lua_path, sizeof(master_config->path));
}
- const char *lua_cpath = ConfNodeLookupChildValue(conf, "cpath");
+ const char *lua_cpath = SCConfNodeLookupChildValue(conf, "cpath");
if (lua_cpath && strlen(lua_cpath) > 0) {
strlcpy(master_config->cpath, lua_cpath, sizeof(master_config->cpath));
}
TAILQ_INIT(&output_ctx->submodules);
/* check the enables scripts and set them up as submodules */
- ConfNode *script;
+ SCConfNode *script;
TAILQ_FOREACH(script, &scripts->head, next) {
SCLogInfo("enabling script %s", script->val);
LogLuaScriptOptions opts;
output_ctx->DeInit(output_ctx);
int failure_fatal = 0;
- if (ConfGetBool("engine.init-failure-fatal", &failure_fatal) != 1) {
+ if (SCConfGetBool("engine.init-failure-fatal", &failure_fatal) != 1) {
SCLogDebug("ConfGetBool could not load the value.");
}
if (failure_fatal) {
/* app layer frames */
JsonFrameLogRegister();
/* BitTorrent DHT JSON logger */
- if (ConfGetNode("app-layer.protocols.bittorrent-dht") != NULL) {
+ if (SCConfGetNode("app-layer.protocols.bittorrent-dht") != NULL) {
/* Register as an eve sub-module. */
OutputRegisterTxSubModule(LOGGER_JSON_TX, "eve-log", "JsonBitTorrentDHTLog",
"eve-log.bittorrent-dht", OutputJsonLogInitSub, ALPROTO_BITTORRENT_DHT,
bool ok;
} OutputInitResult;
-typedef OutputInitResult (*OutputInitFunc)(ConfNode *);
-typedef OutputInitResult (*OutputInitSubFunc)(ConfNode *, OutputCtx *);
+typedef OutputInitResult (*OutputInitFunc)(SCConfNode *);
+typedef OutputInitResult (*OutputInitSubFunc)(SCConfNode *, OutputCtx *);
typedef TmEcode (*OutputLogFunc)(ThreadVars *, Packet *, void *);
typedef TmEcode (*OutputFlushFunc)(ThreadVars *, Packet *, void *);
typedef uint32_t (*OutputGetActiveCountFunc)(void);
/* Path not specified */
if (PathIsRelative(file)) {
- if (ConfGet("default-reputation-path", &defaultpath) == 1) {
+ if (SCConfGet("default-reputation-path", &defaultpath) == 1) {
SCLogDebug("Default path: %s", defaultpath);
size_t path_len = sizeof(char) * (strlen(defaultpath) +
strlen(file) + 2);
*/
int SRepInit(DetectEngineCtx *de_ctx)
{
- ConfNode *files;
- ConfNode *file = NULL;
+ SCConfNode *files;
+ SCConfNode *file = NULL;
const char *filename = NULL;
int init = 0;
}
/* if both settings are missing, we assume the user doesn't want ip rep */
- (void)ConfGet("reputation-categories-file", &filename);
- files = ConfGetNode("reputation-files");
+ (void)SCConfGet("reputation-categories-file", &filename);
+ files = SCConfGetNode("reputation-files");
if (filename == NULL && files == NULL) {
SCLogConfig("IP reputation disabled");
return 0;
bool has_ips = false;
bool has_ids = false;
- ConfNode *af_packet_node = ConfGetNode("af-packet");
+ SCConfNode *af_packet_node = SCConfGetNode("af-packet");
if (af_packet_node == NULL) {
SCLogConfig("no 'af-packet' section in the yaml, default to IDS");
return false;
}
- ConfNode *if_default = ConfNodeLookupKeyValue(af_packet_node, "interface", "default");
+ SCConfNode *if_default = SCConfNodeLookupKeyValue(af_packet_node, "interface", "default");
for (int ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev);
SCLogConfig("invalid livedev at index %d, default to IDS", ldev);
return false;
}
- ConfNode *if_root = ConfFindDeviceConfig(af_packet_node, live_dev);
+ SCConfNode *if_root = ConfFindDeviceConfig(af_packet_node, live_dev);
if (if_root == NULL) {
if (if_default == NULL) {
SCLogConfig(
const char *copymodestr = NULL;
const char *copyifacestr = NULL;
- if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1 &&
- ConfGetChildValue(if_root, "copy-iface", ©ifacestr) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1 &&
+ SCConfGetChildValue(if_root, "copy-iface", ©ifacestr) == 1) {
if (strcmp(copymodestr, "ips") == 0) {
has_ips = true;
} else {
static void *ParseAFPConfig(const char *iface)
{
const char *threadsstr = NULL;
- ConfNode *if_root;
- ConfNode *if_default = NULL;
- ConfNode *af_packet_node;
+ SCConfNode *if_root;
+ SCConfNode *if_default = NULL;
+ SCConfNode *af_packet_node;
const char *tmpclusterid;
const char *tmpctype;
const char *copymodestr;
#endif
/* Find initial node */
- af_packet_node = ConfGetNode("af-packet");
+ af_packet_node = SCConfGetNode("af-packet");
if (af_packet_node == NULL) {
SCLogInfo("%s: unable to find af-packet config using default values", iface);
goto finalize;
if (active_runmode && !strcmp("single", active_runmode)) {
aconf->threads = 1;
- } else if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
+ } else if (SCConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
aconf->threads = 0;
} else {
if (threadsstr != NULL) {
}
}
- if (ConfGetChildValueWithDefault(if_root, if_default, "copy-iface", &out_iface) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "copy-iface", &out_iface) == 1) {
if (out_iface != NULL) {
if (strlen(out_iface) > 0) {
aconf->out_iface = out_iface;
}
}
- (void)ConfGetChildValueBoolWithDefault(if_root, if_default, "mmap-locked", &boolval);
+ (void)SCConfGetChildValueBoolWithDefault(if_root, if_default, "mmap-locked", &boolval);
if (boolval) {
SCLogConfig("%s: enabling locked memory for mmap", aconf->iface);
aconf->flags |= AFP_MMAP_LOCKED;
}
- (void)ConfGetChildValueBoolWithDefault(if_root, if_default, "use-emergency-flush", &boolval);
+ (void)SCConfGetChildValueBoolWithDefault(if_root, if_default, "use-emergency-flush", &boolval);
if (boolval) {
SCLogConfig("%s: using emergency ring flush", aconf->iface);
aconf->flags |= AFP_EMERGENCY_MODE;
}
- if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1) {
if (aconf->out_iface == NULL) {
SCLogWarning("%s: copy mode activated but no destination"
" iface. Disabling feature",
}
}
- if (ConfGetChildValueBoolWithDefault(if_root, if_default, "tpacket-v3", &boolval) == 1) {
+ if (SCConfGetChildValueBoolWithDefault(if_root, if_default, "tpacket-v3", &boolval) == 1) {
if (boolval) {
if (strcasecmp(RunmodeGetActive(), "workers") == 0) {
SCLogConfig("%s: enabling tpacket v3", aconf->iface);
SCLogWarning("%s: using tpacket-v3 in IPS or TAP mode will result in high latency", iface);
}
- if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-id", &tmpclusterid) != 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "cluster-id", &tmpclusterid) != 1) {
aconf->cluster_id = (uint16_t)(cluster_id_auto++);
} else {
if (StringParseUint16(&aconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) {
SCLogDebug("Going to use cluster-id %" PRIu16, aconf->cluster_id);
}
- if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-type", &tmpctype) != 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "cluster-type", &tmpctype) != 1) {
SCLogConfig("%s: using default cluster-type of \"cluster_flow\"", aconf->iface);
tmpctype = "cluster_flow";
}
uint16_t defrag = 0;
int conf_val = 0;
SCLogConfig("%s: using flow cluster mode for AF_PACKET", aconf->iface);
- if (ConfGetChildValueBoolWithDefault(if_root, if_default, "defrag", &conf_val)) {
+ if (SCConfGetChildValueBoolWithDefault(if_root, if_default, "defrag", &conf_val)) {
if (conf_val) {
SCLogConfig("%s: using defrag kernel functionality for AF_PACKET", aconf->iface);
defrag = PACKET_FANOUT_FLAG_DEFRAG;
}
int conf_val = 0;
- ConfGetChildValueBoolWithDefault(if_root, if_default, "rollover", &conf_val);
+ SCConfGetChildValueBoolWithDefault(if_root, if_default, "rollover", &conf_val);
if (conf_val) {
SCLogConfig("%s: Rollover requested for AF_PACKET but ignored -- see ticket #6128.",
aconf->iface);
ConfSetBPFFilter(if_root, if_default, iface, &aconf->bpf_filter);
- if (ConfGetChildValueWithDefault(if_root, if_default, "ebpf-lb-file", &ebpf_file) != 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "ebpf-lb-file", &ebpf_file) != 1) {
aconf->ebpf_lb_file = NULL;
} else {
#ifdef HAVE_PACKET_EBPF
#ifdef HAVE_PACKET_EBPF
boolval = false;
- if (ConfGetChildValueBoolWithDefault(if_root, if_default, "pinned-maps", &boolval) == 1) {
+ if (SCConfGetChildValueBoolWithDefault(if_root, if_default, "pinned-maps", &boolval) == 1) {
if (boolval) {
SCLogConfig("%s: using pinned maps", aconf->iface);
aconf->ebpf_t_config.flags |= EBPF_PINNED_MAPS;
}
const char *pinned_maps_name = NULL;
- if (ConfGetChildValueWithDefault(if_root, if_default,
- "pinned-maps-name",
- &pinned_maps_name) != 1) {
+ if (SCConfGetChildValueWithDefault(
+ if_root, if_default, "pinned-maps-name", &pinned_maps_name) != 1) {
aconf->ebpf_t_config.pinned_maps_name = pinned_maps_name;
} else {
aconf->ebpf_t_config.pinned_maps_name = NULL;
}
#endif
- if (ConfGetChildValueWithDefault(if_root, if_default, "ebpf-filter-file", &ebpf_file) != 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "ebpf-filter-file", &ebpf_file) != 1) {
aconf->ebpf_filter_file = NULL;
} else {
#ifdef HAVE_PACKET_EBPF
aconf->ebpf_t_config.mode = AFP_MODE_EBPF_BYPASS;
aconf->ebpf_t_config.flags |= EBPF_SOCKET_FILTER;
#endif
- ConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &conf_val);
+ SCConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &conf_val);
if (conf_val) {
#ifdef HAVE_PACKET_EBPF
SCLogConfig("%s: using bypass kernel functionality for AF_PACKET", aconf->iface);
#endif
}
- if (ConfGetChildValueWithDefault(if_root, if_default, "xdp-filter-file", &ebpf_file) != 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "xdp-filter-file", &ebpf_file) != 1) {
aconf->xdp_filter_file = NULL;
} else {
#ifdef HAVE_PACKET_XDP
aconf->ebpf_t_config.mode = AFP_MODE_XDP_BYPASS;
aconf->ebpf_t_config.flags |= EBPF_XDP_CODE;
aconf->xdp_filter_file = ebpf_file;
- ConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &conf_val);
+ SCConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &conf_val);
if (conf_val) {
SCLogConfig("%s: using bypass kernel functionality for AF_PACKET", aconf->iface);
aconf->flags |= AFP_XDPBYPASS;
#endif
#ifdef HAVE_PACKET_XDP
const char *xdp_mode;
- if (ConfGetChildValueWithDefault(if_root, if_default, "xdp-mode", &xdp_mode) != 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "xdp-mode", &xdp_mode) != 1) {
aconf->xdp_mode = XDP_FLAGS_SKB_MODE;
} else {
if (!strcmp(xdp_mode, "soft")) {
}
boolval = true;
- if (ConfGetChildValueBoolWithDefault(if_root, if_default, "use-percpu-hash", &boolval) ==
+ if (SCConfGetChildValueBoolWithDefault(if_root, if_default, "use-percpu-hash", &boolval) ==
1) {
if (!boolval) {
SCLogConfig("%s: not using percpu hash", aconf->iface);
} else {
/* Try to get the xdp-cpu-redirect key */
const char *cpuset;
- if (ConfGetChildValueWithDefault(if_root, if_default,
- "xdp-cpu-redirect", &cpuset) == 1) {
+ if (SCConfGetChildValueWithDefault(
+ if_root, if_default, "xdp-cpu-redirect", &cpuset) == 1) {
SCLogConfig("%s: Setting up CPU map XDP", iface);
- ConfNode *node = ConfGetChildWithDefault(if_root, if_default, "xdp-cpu-redirect");
+ SCConfNode *node =
+ SCConfGetChildWithDefault(if_root, if_default, "xdp-cpu-redirect");
if (node == NULL) {
SCLogError("Previously found node has disappeared");
} else {
#endif
}
- if ((ConfGetChildValueIntWithDefault(if_root, if_default, "buffer-size", &value)) == 1) {
+ if ((SCConfGetChildValueIntWithDefault(if_root, if_default, "buffer-size", &value)) == 1) {
aconf->buffer_size = value;
} else {
aconf->buffer_size = 0;
}
- if ((ConfGetChildValueIntWithDefault(if_root, if_default, "ring-size", &value)) == 1) {
+ if ((SCConfGetChildValueIntWithDefault(if_root, if_default, "ring-size", &value)) == 1) {
aconf->ring_size = value;
}
- if ((ConfGetChildValueIntWithDefault(if_root, if_default, "block-size", &value)) == 1) {
+ if ((SCConfGetChildValueIntWithDefault(if_root, if_default, "block-size", &value)) == 1) {
if (value % getpagesize()) {
SCLogWarning("%s: block-size %" PRIuMAX " must be a multiple of pagesize (%u).", iface,
value, getpagesize());
}
}
- if ((ConfGetChildValueIntWithDefault(if_root, if_default, "block-timeout", &value)) == 1) {
+ if ((SCConfGetChildValueIntWithDefault(if_root, if_default, "block-timeout", &value)) == 1) {
aconf->block_timeout = value;
} else {
aconf->block_timeout = 10;
}
- if ((ConfGetChildValueIntWithDefault(if_root, if_default, "v2-block-size", &value)) == 1) {
+ if ((SCConfGetChildValueIntWithDefault(if_root, if_default, "v2-block-size", &value)) == 1) {
if (value % getpagesize()) {
SCLogWarning("%s: v2-block-size %" PRIuMAX " must be a multiple of pagesize (%u).",
iface, value, getpagesize());
}
}
- (void)ConfGetChildValueBoolWithDefault(if_root, if_default, "disable-promisc", &boolval);
+ (void)SCConfGetChildValueBoolWithDefault(if_root, if_default, "disable-promisc", &boolval);
if (boolval) {
SCLogConfig("%s: disabling promiscuous mode", aconf->iface);
aconf->promisc = 0;
}
- if (ConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) {
if (strcmp(tmpctype, "auto") == 0) {
aconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
- } else if (ConfValIsTrue(tmpctype)) {
+ } else if (SCConfValIsTrue(tmpctype)) {
aconf->checksum_mode = CHECKSUM_VALIDATION_ENABLE;
- } else if (ConfValIsFalse(tmpctype)) {
+ } else if (SCConfValIsFalse(tmpctype)) {
aconf->checksum_mode = CHECKSUM_VALIDATION_DISABLE;
} else if (strcmp(tmpctype, "kernel") == 0) {
aconf->checksum_mode = CHECKSUM_VALIDATION_KERNEL;
TimeModeSetLive();
- (void)ConfGet("af-packet.live-interface", &live_dev);
+ (void)SCConfGet("af-packet.live-interface", &live_dev);
SCLogDebug("live_dev %s", live_dev);
TimeModeSetLive();
- (void)ConfGet("af-packet.live-interface", &live_dev);
+ (void)SCConfGet("af-packet.live-interface", &live_dev);
if (AFPPeersListInit() != TM_ECODE_OK) {
FatalError("Unable to init peers list.");
TimeModeSetLive();
- (void)ConfGet("af-packet.live-interface", &live_dev);
+ (void)SCConfGet("af-packet.live-interface", &live_dev);
if (AFPPeersListInit() != TM_ECODE_OK) {
FatalError("Unable to init peers list.");
static void *ParseAFXDPConfig(const char *iface)
{
const char *confstr = NULL;
- ConfNode *if_root;
- ConfNode *if_default = NULL;
- ConfNode *af_xdp_node = NULL;
+ SCConfNode *if_root;
+ SCConfNode *if_default = NULL;
+ SCConfNode *af_xdp_node = NULL;
int conf_val = 0;
intmax_t conf_val_int = 0;
int boolval = 0;
aconf->mem_alignment = XSK_UMEM__DEFAULT_FLAGS;
/* Find initial node */
- af_xdp_node = ConfGetNode("af-xdp");
+ af_xdp_node = SCConfGetNode("af-xdp");
if (af_xdp_node == NULL) {
SCLogInfo("unable to find af-xdp config using default values");
goto finalize;
/* Threading */
confstr = "auto";
- (void)ConfGetChildValueWithDefault(if_root, if_default, "threads", &confstr);
+ (void)SCConfGetChildValueWithDefault(if_root, if_default, "threads", &confstr);
if (ConfigSetThreads(aconf, confstr) != TM_ECODE_OK) {
aconf->DerefFunc(aconf);
return NULL;
(void)SC_ATOMIC_ADD(aconf->ref, aconf->threads);
/* Promisc Mode */
- (void)ConfGetChildValueBoolWithDefault(if_root, if_default, "disable-promisc", &boolval);
+ (void)SCConfGetChildValueBoolWithDefault(if_root, if_default, "disable-promisc", &boolval);
if (boolval) {
SCLogConfig("Disabling promiscuous mode on iface %s", aconf->iface);
aconf->promisc = 0;
#ifdef HAVE_AF_XDP
/* AF_XDP socket mode options */
- if (ConfGetChildValueWithDefault(if_root, if_default, "force-xdp-mode", &confstr) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "force-xdp-mode", &confstr) == 1) {
if (strncasecmp(confstr, "drv", 3) == 0) {
aconf->mode |= XDP_FLAGS_DRV_MODE;
} else if (strncasecmp(confstr, "skb", 3) == 0) {
}
/* copy and zerocopy binding options */
- if (ConfGetChildValueWithDefault(if_root, if_default, "force-bind-mode", &confstr) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "force-bind-mode", &confstr) == 1) {
if (strncasecmp(confstr, "zero", 4) == 0) {
aconf->bind_flags |= XDP_ZEROCOPY;
} else if (strncasecmp(confstr, "copy", 4) == 0) {
}
/* memory alignment mode selection */
- if (ConfGetChildValueWithDefault(if_root, if_default, "mem-unaligned", &confstr) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "mem-unaligned", &confstr) == 1) {
if (strncasecmp(confstr, "yes", 3) == 0) {
aconf->mem_alignment = XDP_UMEM_UNALIGNED_CHUNK_FLAG;
}
}
/* Busy polling options */
- if (ConfGetChildValueBoolWithDefault(if_root, if_default, "enable-busy-poll", &conf_val) == 1) {
+ if (SCConfGetChildValueBoolWithDefault(if_root, if_default, "enable-busy-poll", &conf_val) ==
+ 1) {
if (conf_val == 0) {
aconf->enable_busy_poll = false;
}
}
if (aconf->enable_busy_poll) {
- if (ConfGetChildValueIntWithDefault(if_root, if_default, "busy-poll-time", &conf_val_int) ==
- 1) {
+ if (SCConfGetChildValueIntWithDefault(
+ if_root, if_default, "busy-poll-time", &conf_val_int) == 1) {
if (conf_val_int) {
aconf->busy_poll_time = conf_val_int;
}
}
- if (ConfGetChildValueIntWithDefault(
+ if (SCConfGetChildValueIntWithDefault(
if_root, if_default, "busy-poll-budget", &conf_val_int) == 1) {
if (conf_val_int) {
aconf->busy_poll_budget = conf_val_int;
}
/* 0 value is valid for these Linux tunable's */
- if (ConfGetChildValueIntWithDefault(
+ if (SCConfGetChildValueIntWithDefault(
if_root, if_default, "gro-flush-timeout", &conf_val_int) == 1) {
aconf->gro_flush_timeout = conf_val_int;
}
- if (ConfGetChildValueIntWithDefault(
+ if (SCConfGetChildValueIntWithDefault(
if_root, if_default, "napi-defer-hard-irq", &conf_val_int) == 1) {
aconf->napi_defer_hard_irqs = conf_val_int;
}
TimeModeSetLive();
- (void)ConfGet("af-xdp.live-interface", &live_dev);
+ (void)SCConfGet("af-xdp.live-interface", &live_dev);
if (AFXDPQueueProtectionInit() != TM_ECODE_OK) {
FatalError("Unable to init AF_XDP queue protection.");
TimeModeSetLive();
- (void)ConfGet("af-xdp.live-interface", &live_dev);
+ (void)SCConfGet("af-xdp.live-interface", &live_dev);
if (AFXDPQueueProtectionInit() != TM_ECODE_OK) {
FatalError("Unable to init AF_XDP queue protection.");
{
SCEnter();
int retval;
- ConfNode *param;
- const ConfNode *eal_params = ConfGetNode("dpdk.eal-params");
+ SCConfNode *param;
+ const SCConfNode *eal_params = SCConfGetNode("dpdk.eal-params");
struct Arguments args;
char **eal_argv;
ArgumentsAdd(&args, AllocAndSetArgument("suricata"));
TAILQ_FOREACH (param, &eal_params->head, next) {
- if (ConfNodeIsSequence(param)) {
+ if (SCConfNodeIsSequence(param)) {
const char *key = param->name;
- ConfNode *val;
+ SCConfNode *val;
TAILQ_FOREACH (val, ¶m->head, next) {
ArgumentsAddOptionAndArgument(&args, key, (const char *)val->val);
}
{
SCEnter();
int retval;
- ConfNode *if_root;
- ConfNode *if_default;
+ SCConfNode *if_root;
+ SCConfNode *if_default;
const char *entry_str = NULL;
intmax_t entry_int = 0;
int entry_bool = 0;
SCReturnInt(retval);
}
- retval = ConfSetRootAndDefaultNodes("dpdk.interfaces", iconf->iface, &if_root, &if_default);
+ retval = SCConfSetRootAndDefaultNodes("dpdk.interfaces", iconf->iface, &if_root, &if_default);
if (retval < 0) {
FatalError("failed to find DPDK configuration for the interface %s", iconf->iface);
}
- retval = ConfGetChildValueWithDefault(if_root, if_default, dpdk_yaml.threads, &entry_str) != 1
+ retval = SCConfGetChildValueWithDefault(if_root, if_default, dpdk_yaml.threads, &entry_str) != 1
? ConfigSetThreads(iconf, DPDK_CONFIG_DEFAULT_THREADS)
: ConfigSetThreads(iconf, entry_str);
if (retval < 0)
SCReturnInt(retval);
bool irq_enable;
- retval = ConfGetChildValueBoolWithDefault(if_root, if_default, dpdk_yaml.irq_mode, &entry_bool);
+ retval = SCConfGetChildValueBoolWithDefault(if_root, if_default, dpdk_yaml.irq_mode, &entry_bool);
if (retval != 1) {
irq_enable = DPDK_CONFIG_DEFAULT_INTERRUPT_MODE;
} else {
if (retval != true)
SCReturnInt(-EINVAL);
- retval = ConfGetChildValueWithDefault(if_root, if_default, dpdk_yaml.copy_mode, ©_mode_str);
+ retval = SCConfGetChildValueWithDefault(if_root, if_default, dpdk_yaml.copy_mode, ©_mode_str);
if (retval != 1) {
copy_mode_str = DPDK_CONFIG_DEFAULT_COPY_MODE;
}
- retval = ConfGetChildValueWithDefault(
+ retval = SCConfGetChildValueWithDefault(
if_root, if_default, dpdk_yaml.rx_descriptors, &entry_str) != 1
? ConfigSetRxDescriptors(iconf, DPDK_CONFIG_DEFAULT_RX_DESCRIPTORS,
dev_info.rx_desc_lim.nb_max)
SCReturnInt(retval);
bool iface_sends_pkts = ConfigIfaceSendsPkts(copy_mode_str);
- retval = ConfGetChildValueWithDefault(
+ retval = SCConfGetChildValueWithDefault(
if_root, if_default, dpdk_yaml.tx_descriptors, &entry_str) != 1
? ConfigSetTxDescriptors(iconf, DPDK_CONFIG_DEFAULT_TX_DESCRIPTORS,
dev_info.tx_desc_lim.nb_max, iface_sends_pkts)
SCReturnInt(retval);
}
- retval = ConfGetChildValueWithDefault(
+ retval = SCConfGetChildValueWithDefault(
if_root, if_default, dpdk_yaml.mempool_size, &entry_str) != 1
? ConfigSetMempoolSize(iconf, DPDK_CONFIG_DEFAULT_MEMPOOL_SIZE)
: ConfigSetMempoolSize(iconf, entry_str);
if (retval < 0)
SCReturnInt(retval);
- retval = ConfGetChildValueWithDefault(
+ retval = SCConfGetChildValueWithDefault(
if_root, if_default, dpdk_yaml.mempool_cache_size, &entry_str) != 1
? ConfigSetMempoolCacheSize(iconf, DPDK_CONFIG_DEFAULT_MEMPOOL_CACHE_SIZE)
: ConfigSetMempoolCacheSize(iconf, entry_str);
if (retval < 0)
SCReturnInt(retval);
- retval = ConfGetChildValueIntWithDefault(if_root, if_default, dpdk_yaml.mtu, &entry_int) != 1
+ retval = SCConfGetChildValueIntWithDefault(if_root, if_default, dpdk_yaml.mtu, &entry_int) != 1
? ConfigSetMtu(iconf, DPDK_CONFIG_DEFAULT_MTU)
: ConfigSetMtu(iconf, entry_int);
if (retval < 0)
SCReturnInt(retval);
- retval = ConfGetChildValueWithDefault(if_root, if_default, dpdk_yaml.rss_hf, &entry_str) != 1
+ retval = SCConfGetChildValueWithDefault(if_root, if_default, dpdk_yaml.rss_hf, &entry_str) != 1
? ConfigSetRSSHashFunctions(iconf, NULL)
: ConfigSetRSSHashFunctions(iconf, entry_str);
if (retval < 0)
SCReturnInt(retval);
- retval = ConfGetChildValueBoolWithDefault(
+ retval = SCConfGetChildValueBoolWithDefault(
if_root, if_default, dpdk_yaml.promisc, &entry_bool) != 1
? ConfigSetPromiscuousMode(iconf, DPDK_CONFIG_DEFAULT_PROMISCUOUS_MODE)
: ConfigSetPromiscuousMode(iconf, entry_bool);
if (retval != true)
SCReturnInt(-EINVAL);
- retval = ConfGetChildValueBoolWithDefault(
+ retval = SCConfGetChildValueBoolWithDefault(
if_root, if_default, dpdk_yaml.multicast, &entry_bool) != 1
? ConfigSetMulticast(iconf, DPDK_CONFIG_DEFAULT_MULTICAST_MODE)
: ConfigSetMulticast(iconf, entry_bool);
if (retval != true)
SCReturnInt(-EINVAL);
- retval = ConfGetChildValueBoolWithDefault(
+ retval = SCConfGetChildValueBoolWithDefault(
if_root, if_default, dpdk_yaml.checksum_checks, &entry_bool) != 1
? ConfigSetChecksumChecks(iconf, DPDK_CONFIG_DEFAULT_CHECKSUM_VALIDATION)
: ConfigSetChecksumChecks(iconf, entry_bool);
if (retval < 0)
SCReturnInt(retval);
- retval = ConfGetChildValueBoolWithDefault(
+ retval = SCConfGetChildValueBoolWithDefault(
if_root, if_default, dpdk_yaml.checksum_checks_offload, &entry_bool) != 1
? ConfigSetChecksumOffload(
iconf, DPDK_CONFIG_DEFAULT_CHECKSUM_VALIDATION_OFFLOAD)
if (retval < 0)
SCReturnInt(retval);
- retval = ConfGetChildValueBoolWithDefault(
+ retval = SCConfGetChildValueBoolWithDefault(
if_root, if_default, dpdk_yaml.vlan_strip_offload, &entry_bool);
if (retval != 1) {
ConfigSetVlanStrip(iconf, DPDK_CONFIG_DEFAULT_VLAN_STRIP);
ConfigSetVlanStrip(iconf, entry_bool);
}
- retval = ConfGetChildValueIntWithDefault(
+ retval = SCConfGetChildValueIntWithDefault(
if_root, if_default, dpdk_yaml.linkup_timeout, &entry_int) != 1
? ConfigSetLinkupTimeout(iconf, DPDK_CONFIG_DEFAULT_LINKUP_TIMEOUT)
: ConfigSetLinkupTimeout(iconf, entry_int);
if (retval < 0)
SCReturnInt(retval);
- retval = ConfGetChildValueWithDefault(
+ retval = SCConfGetChildValueWithDefault(
if_root, if_default, dpdk_yaml.copy_iface, ©_iface_str);
if (retval != 1) {
copy_iface_str = DPDK_CONFIG_DEFAULT_COPY_INTERFACE;
{
/* Find initial node */
const char dpdk_node_query[] = "dpdk.interfaces";
- ConfNode *dpdk_node = ConfGetNode(dpdk_node_query);
+ SCConfNode *dpdk_node = SCConfGetNode(dpdk_node_query);
if (dpdk_node == NULL) {
FatalError("Unable to get %s configuration node", dpdk_node_query);
}
const char default_iface[] = "default";
- ConfNode *if_default = ConfNodeLookupKeyValue(dpdk_node, "interface", default_iface);
+ SCConfNode *if_default = SCConfNodeLookupKeyValue(dpdk_node, "interface", default_iface);
int nlive = LiveGetDeviceCount();
bool has_ips = false;
bool has_ids = false;
if (live_dev == NULL)
FatalError("Unable to get device id %d from LiveDevice list", ldev);
- ConfNode *if_root = ConfFindDeviceConfig(dpdk_node, live_dev);
+ SCConfNode *if_root = ConfFindDeviceConfig(dpdk_node, live_dev);
if (if_root == NULL) {
if (if_default == NULL)
FatalError("Unable to get %s or %s interface", live_dev, default_iface);
const char *copymodestr = NULL;
const char *copyifacestr = NULL;
- if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1 &&
- ConfGetChildValue(if_root, "copy-iface", ©ifacestr) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1 &&
+ SCConfGetChildValue(if_root, "copy-iface", ©ifacestr) == 1) {
if (strcmp(copymodestr, "ips") == 0) {
has_ips = true;
} else {
SCEnter();
- if (ConfGet("erf-file.file", &file) == 0) {
+ if (SCConfGet("erf-file.file", &file) == 0) {
FatalError("Failed to get erf-file.file from config.");
}
uint16_t thread;
const char *file = NULL;
- if (ConfGet("erf-file.file", &file) == 0) {
+ if (SCConfGet("erf-file.file", &file) == 0) {
FatalError("Failed retrieving erf-file.file from config");
}
{
int nlive = LiveGetDeviceCount();
int ldev;
- ConfNode *if_root;
- ConfNode *if_default = NULL;
- ConfNode *netmap_node;
+ SCConfNode *if_root;
+ SCConfNode *if_default = NULL;
+ SCConfNode *netmap_node;
int has_ips = 0;
int has_ids = 0;
/* Find initial node */
- netmap_node = ConfGetNode("netmap");
+ netmap_node = SCConfGetNode("netmap");
if (netmap_node == NULL) {
return 0;
}
- if_default = ConfNodeLookupKeyValue(netmap_node, "interface", "default");
+ if_default = SCConfNodeLookupKeyValue(netmap_node, "interface", "default");
for (ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev);
SCLogError("Problem with config file");
return -1;
}
- if_root = ConfNodeLookupKeyValue(netmap_node, "interface", live_dev);
+ if_root = SCConfNodeLookupKeyValue(netmap_node, "interface", live_dev);
if (if_root == NULL) {
if (if_default == NULL) {
const char *copymodestr = NULL;
const char *copyifacestr = NULL;
- if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1 &&
- ConfGetChildValue(if_root, "copy-iface", ©ifacestr) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1 &&
+ SCConfGetChildValue(if_root, "copy-iface", ©ifacestr) == 1) {
if (strcmp(copymodestr, "ips") == 0) {
has_ips = 1;
} else {
}
}
-static int ParseNetmapSettings(NetmapIfaceSettings *ns, const char *iface,
- ConfNode *if_root, ConfNode *if_default)
+static int ParseNetmapSettings(
+ NetmapIfaceSettings *ns, const char *iface, SCConfNode *if_root, SCConfNode *if_default)
{
ns->threads = 0;
ns->promisc = true;
}
const char *threadsstr = NULL;
- if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
ns->threads = 0;
ns->threads_auto = true;
} else {
ConfSetBPFFilter(if_root, if_default, iface, &ns->bpf_filter);
int boolval = 0;
- (void)ConfGetChildValueBoolWithDefault(if_root, if_default, "disable-promisc", &boolval);
+ (void)SCConfGetChildValueBoolWithDefault(if_root, if_default, "disable-promisc", &boolval);
if (boolval) {
SCLogInfo("%s: disabling promiscuous mode", ns->iface);
ns->promisc = false;
}
const char *tmpctype;
- if (ConfGetChildValueWithDefault(if_root, if_default,
+ if (SCConfGetChildValueWithDefault(if_root, if_default,
"checksum-checks", &tmpctype) == 1)
{
if (strcmp(tmpctype, "auto") == 0) {
ns->checksum_mode = CHECKSUM_VALIDATION_AUTO;
- } else if (ConfValIsTrue(tmpctype)) {
+ } else if (SCConfValIsTrue(tmpctype)) {
ns->checksum_mode = CHECKSUM_VALIDATION_ENABLE;
- } else if (ConfValIsFalse(tmpctype)) {
+ } else if (SCConfValIsFalse(tmpctype)) {
ns->checksum_mode = CHECKSUM_VALIDATION_DISABLE;
} else {
SCLogWarning("%s: invalid value for checksum-checks '%s'", iface, tmpctype);
}
const char *copymodestr;
- if (ConfGetChildValueWithDefault(if_root, if_default,
+ if (SCConfGetChildValueWithDefault(if_root, if_default,
"copy-mode", ©modestr) == 1)
{
if (strcmp(copymodestr, "ips") == 0) {
*/
static void *ParseNetmapConfig(const char *iface_name)
{
- ConfNode *if_root = NULL;
- ConfNode *if_default = NULL;
+ SCConfNode *if_root = NULL;
+ SCConfNode *if_default = NULL;
const char *out_iface = NULL;
if (iface_name == NULL) {
(void) SC_ATOMIC_ADD(aconf->ref, 1);
/* Find initial node */
- ConfNode *netmap_node = ConfGetNode("netmap");
+ SCConfNode *netmap_node = SCConfGetNode("netmap");
if (netmap_node == NULL) {
SCLogInfo("%s: unable to find netmap config using default value", iface_name);
} else {
/* if we have a copy iface, parse that as well */
if (netmap_node != NULL &&
- ConfGetChildValueWithDefault(if_root, if_default, "copy-iface", &out_iface) == 1)
+ SCConfGetChildValueWithDefault(if_root, if_default, "copy-iface", &out_iface) == 1)
{
if (strlen(out_iface) > 0) {
if_root = ConfFindDeviceConfig(netmap_node, out_iface);
TimeModeSetLive();
const char *live_dev = NULL;
- (void)ConfGet("netmap.live-interface", &live_dev);
+ (void)SCConfGet("netmap.live-interface", &live_dev);
const char *runmode_str = "unknown";
int ret;
static void *ParseNflogConfig(const char *group)
{
- ConfNode *group_root;
- ConfNode *group_default = NULL;
- ConfNode *nflog_node;
+ SCConfNode *group_root;
+ SCConfNode *group_default = NULL;
+ SCConfNode *nflog_node;
NflogGroupConfig *nflogconf = SCMalloc(sizeof(*nflogconf));
intmax_t bufsize;
intmax_t bufsize_max;
}
nflogconf->DerefFunc = NflogDerefConfig;
- nflog_node = ConfGetNode("nflog");
+ nflog_node = SCConfGetNode("nflog");
if (nflog_node == NULL) {
SCLogInfo("Unable to find nflog config using default value");
return nflogconf;
}
- group_root = ConfNodeLookupKeyValue(nflog_node, "group", group);
+ group_root = SCConfNodeLookupKeyValue(nflog_node, "group", group);
- group_default = ConfNodeLookupKeyValue(nflog_node, "group", "default");
+ group_default = SCConfNodeLookupKeyValue(nflog_node, "group", "default");
if (group_root == NULL && group_default == NULL) {
SCLogInfo("Unable to find nflog config for "
FatalError("NFLOG's group number invalid.");
}
- boolval = ConfGetChildValueIntWithDefault(group_root, group_default,
- "buffer-size", &bufsize);
+ boolval = SCConfGetChildValueIntWithDefault(group_root, group_default, "buffer-size", &bufsize);
if (boolval)
nflogconf->nlbufsiz = bufsize;
return NULL;
}
- boolval = ConfGetChildValueIntWithDefault(group_root, group_default,
- "max-size", &bufsize_max);
+ boolval =
+ SCConfGetChildValueIntWithDefault(group_root, group_default, "max-size", &bufsize_max);
if (boolval)
nflogconf->nlbufsiz_max = bufsize_max;
nflogconf->nlbufsiz = nflogconf->nlbufsiz_max;
}
- boolval = ConfGetChildValueIntWithDefault(group_root, group_default,
- "qthreshold", &qthreshold);
+ boolval =
+ SCConfGetChildValueIntWithDefault(group_root, group_default, "qthreshold", &qthreshold);
if (boolval)
nflogconf->qthreshold = qthreshold;
return NULL;
}
- boolval = ConfGetChildValueIntWithDefault(group_root, group_default,
- "qtimeout", &qtimeout);
+ boolval = SCConfGetChildValueIntWithDefault(group_root, group_default, "qtimeout", &qtimeout);
if (boolval)
nflogconf->qtimeout = qtimeout;
const char *file = NULL;
char tname[TM_THREAD_NAME_MAX];
- if (ConfGet("pcap-file.file", &file) == 0) {
+ if (SCConfGet("pcap-file.file", &file) == 0) {
FatalError("Failed retrieving pcap-file from Conf");
}
uint16_t thread;
const char *file = NULL;
- if (ConfGet("pcap-file.file", &file) == 0) {
+ if (SCConfGet("pcap-file.file", &file) == 0) {
FatalError("Failed retrieving pcap-file from Conf");
}
SCLogDebug("file %s", file);
static void *ParsePcapConfig(const char *iface)
{
const char *threadsstr = NULL;
- ConfNode *if_root;
- ConfNode *if_default = NULL;
- ConfNode *pcap_node;
+ SCConfNode *if_root;
+ SCConfNode *if_default = NULL;
+ SCConfNode *pcap_node;
PcapIfaceConfig *aconf = SCMalloc(sizeof(*aconf));
const char *tmpbpf;
const char *tmpctype;
aconf->buffer_size = 0;
/* If set command line option has precedence over config */
- if ((ConfGetInt("pcap.buffer-size", &value)) == 1) {
+ if ((SCConfGetInt("pcap.buffer-size", &value)) == 1) {
if (value >= 0 && value <= INT_MAX) {
SCLogInfo("Pcap will use %d buffer size", (int)value);
aconf->buffer_size = (int)value;
aconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
aconf->bpf_filter = NULL;
- if ((ConfGet("bpf-filter", &tmpbpf)) == 1) {
+ if ((SCConfGet("bpf-filter", &tmpbpf)) == 1) {
aconf->bpf_filter = tmpbpf;
}
aconf->threads = 1;
/* Find initial node */
- pcap_node = ConfGetNode("pcap");
+ pcap_node = SCConfGetNode("pcap");
if (pcap_node == NULL) {
SCLogInfo("Unable to find pcap config using default value");
return aconf;
if_default = NULL;
}
- if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
aconf->threads = 1;
} else {
if (threadsstr != NULL) {
if (aconf->buffer_size == 0) {
const char *s_limit = NULL;
int ret;
- ret = ConfGetChildValueWithDefault(if_root, if_default, "buffer-size", &s_limit);
+ ret = SCConfGetChildValueWithDefault(if_root, if_default, "buffer-size", &s_limit);
if (ret == 1 && s_limit) {
uint64_t bsize = 0;
if (aconf->bpf_filter == NULL) {
/* set bpf filter if we have one */
- if (ConfGetChildValueWithDefault(if_root, if_default, "bpf-filter", &tmpbpf) != 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "bpf-filter", &tmpbpf) != 1) {
SCLogDebug("could not get bpf or none specified");
} else {
aconf->bpf_filter = tmpbpf;
SCLogInfo("BPF filter set from command line or via old 'bpf-filter' option.");
}
- if (ConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) {
+ if (SCConfGetChildValueWithDefault(if_root, if_default, "checksum-checks", &tmpctype) == 1) {
if (strcmp(tmpctype, "auto") == 0) {
aconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;
- } else if (ConfValIsTrue(tmpctype)) {
+ } else if (SCConfValIsTrue(tmpctype)) {
aconf->checksum_mode = CHECKSUM_VALIDATION_ENABLE;
- } else if (ConfValIsFalse(tmpctype)) {
+ } else if (SCConfValIsFalse(tmpctype)) {
aconf->checksum_mode = CHECKSUM_VALIDATION_DISABLE;
} else {
SCLogError("Invalid value for checksum-checks for %s", aconf->iface);
}
aconf->promisc = LIBPCAP_PROMISC;
- if (ConfGetChildValueBoolWithDefault(if_root, if_default, "promisc", &promisc) != 1) {
+ if (SCConfGetChildValueBoolWithDefault(if_root, if_default, "promisc", &promisc) != 1) {
SCLogDebug("could not get promisc or none specified");
} else {
aconf->promisc = promisc;
}
aconf->snaplen = 0;
- if (ConfGetChildValueIntWithDefault(if_root, if_default, "snaplen", &snaplen) != 1) {
+ if (SCConfGetChildValueIntWithDefault(if_root, if_default, "snaplen", &snaplen) != 1) {
SCLogDebug("could not get snaplen or none specified");
} else if (snaplen < INT_MIN || snaplen > INT_MAX) {
SCLogDebug("snaplen value is not in the accepted range");
TimeModeSetLive();
- (void)ConfGet("pcap.single-pcap-dev", &live_dev);
+ (void)SCConfGet("pcap.single-pcap-dev", &live_dev);
ret = RunModeSetLiveCaptureSingle(ParsePcapConfig,
PcapConfigGeThreadsCount,
SCEnter();
TimeModeSetLive();
- (void) ConfGet("pcap.single-pcap-dev", &live_dev);
+ (void)SCConfGet("pcap.single-pcap-dev", &live_dev);
ret = RunModeSetLiveCaptureAutoFp(ParsePcapConfig, PcapConfigGeThreadsCount, "ReceivePcap",
"DecodePcap", thread_name_autofp, live_dev);
TimeModeSetLive();
- (void) ConfGet("pcap.single-pcap-dev", &live_dev);
+ (void)SCConfGet("pcap.single-pcap-dev", &live_dev);
ret = RunModeSetLiveCaptureWorkers(ParsePcapConfig, PcapConfigGeThreadsCount, "ReceivePcap",
"DecodePcap", thread_name_workers, live_dev);
DecodeMPLSRegisterTests();
DecodeNSHRegisterTests();
AppLayerProtoDetectUnittestsRegister();
- ConfRegisterTests();
- ConfYamlRegisterTests();
+ SCConfRegisterTests();
+ SCConfYamlRegisterTests();
TmqhFlowRegisterTests();
FlowRegisterTests();
HostRegisterUnittests();
unix_manager_pcap_task_running = 1;
this->running = 1;
- if (ConfSetFinal("pcap-file.file", cfile->filename) != 1) {
+ if (SCConfSetFinal("pcap-file.file", cfile->filename) != 1) {
SCLogError("Can not set working file to '%s'", cfile->filename);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
int set_res = 0;
if (cfile->continuous) {
- set_res = ConfSetFinal("pcap-file.continuous", "true");
+ set_res = SCConfSetFinal("pcap-file.continuous", "true");
} else {
- set_res = ConfSetFinal("pcap-file.continuous", "false");
+ set_res = SCConfSetFinal("pcap-file.continuous", "false");
}
if (set_res != 1) {
SCLogError("Can not set continuous mode for pcap processing");
return TM_ECODE_FAILED;
}
if (cfile->should_delete) {
- set_res = ConfSetFinal("pcap-file.delete-when-done", "true");
+ set_res = SCConfSetFinal("pcap-file.delete-when-done", "true");
} else {
- set_res = ConfSetFinal("pcap-file.delete-when-done", "false");
+ set_res = SCConfSetFinal("pcap-file.delete-when-done", "false");
}
if (set_res != 1) {
SCLogError("Can not set delete mode for pcap processing");
if (cfile->delay > 0) {
char tstr[32];
snprintf(tstr, sizeof(tstr), "%" PRIuMAX, (uintmax_t)cfile->delay);
- if (ConfSetFinal("pcap-file.delay", tstr) != 1) {
+ if (SCConfSetFinal("pcap-file.delay", tstr) != 1) {
SCLogError("Can not set delay to '%s'", tstr);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
if (cfile->poll_interval > 0) {
char tstr[32];
snprintf(tstr, sizeof(tstr), "%" PRIuMAX, (uintmax_t)cfile->poll_interval);
- if (ConfSetFinal("pcap-file.poll-interval", tstr) != 1) {
+ if (SCConfSetFinal("pcap-file.poll-interval", tstr) != 1) {
SCLogError("Can not set poll-interval to '%s'", tstr);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
if (cfile->tenant_id > 0) {
char tstr[16];
snprintf(tstr, sizeof(tstr), "%u", cfile->tenant_id);
- if (ConfSetFinal("pcap-file.tenant-id", tstr) != 1) {
+ if (SCConfSetFinal("pcap-file.tenant-id", tstr) != 1) {
SCLogError("Can not set working tenant-id to '%s'", tstr);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
}
if (cfile->output_dir) {
- if (ConfSetFinal("default-log-dir", cfile->output_dir) != 1) {
+ if (SCConfSetFinal("default-log-dir", cfile->output_dir) != 1) {
SCLogError("Can not set output dir to '%s'", cfile->output_dir);
PcapFilesFree(cfile);
return TM_ECODE_FAILED;
SCLogDebug("add-tenant: %d %s", tenant_id, filename);
/* setup the yaml in this loop so that it's not done by the loader
- * threads. ConfYamlLoadFileWithPrefix is not thread safe. */
+ * threads. SCConfYamlLoadFileWithPrefix is not thread safe. */
char prefix[64];
snprintf(prefix, sizeof(prefix), "multi-detect.%u", tenant_id);
- if (ConfYamlLoadFileWithPrefix(filename, prefix) != 0) {
+ if (SCConfYamlLoadFileWithPrefix(filename, prefix) != 0) {
SCLogError("failed to load yaml %s", filename);
json_object_set_new(answer, "message", json_string("failed to load yaml"));
return TM_ECODE_FAILED;
{
const char *custom_mode = NULL;
const char *val = NULL;
- if (ConfGet("runmode", &val) != 1) {
+ if (SCConfGet("runmode", &val) != 1) {
custom_mode = NULL;
} else {
custom_mode = val;
}
}
-static void RunModeInitializeEveOutput(ConfNode *conf, OutputCtx *parent_ctx, LoggerId *logger_bits)
+static void RunModeInitializeEveOutput(
+ SCConfNode *conf, OutputCtx *parent_ctx, LoggerId *logger_bits)
{
- ConfNode *types = ConfNodeLookupChild(conf, "types");
+ SCConfNode *types = SCConfNodeLookupChild(conf, "types");
SCLogDebug("types %p", types);
if (types == NULL) {
return;
}
- ConfNode *type = NULL;
+ SCConfNode *type = NULL;
TAILQ_FOREACH(type, &types->head, next) {
int sub_count = 0;
char subname[256];
SCLogConfig("enabling 'eve-log' module '%s'", type->val);
- ConfNode *sub_output_config = ConfNodeLookupChild(type, type->val);
+ SCConfNode *sub_output_config = SCConfNodeLookupChild(type, type->val);
if (sub_output_config != NULL) {
- const char *enabled = ConfNodeLookupChildValue(
- sub_output_config, "enabled");
- if (enabled != NULL && !ConfValIsTrue(enabled)) {
+ const char *enabled = SCConfNodeLookupChildValue(sub_output_config, "enabled");
+ if (enabled != NULL && !SCConfValIsTrue(enabled)) {
continue;
}
}
}
}
-static void RunModeInitializeLuaOutput(ConfNode *conf, OutputCtx *parent_ctx, LoggerId *logger_bits)
+static void RunModeInitializeLuaOutput(
+ SCConfNode *conf, OutputCtx *parent_ctx, LoggerId *logger_bits)
{
OutputModule *lua_module = OutputGetModuleByConfName("lua");
BUG_ON(lua_module == NULL);
- ConfNode *scripts = ConfNodeLookupChild(conf, "scripts");
+ SCConfNode *scripts = SCConfNodeLookupChild(conf, "scripts");
BUG_ON(scripts == NULL); //TODO
OutputModule *m;
TAILQ_FOREACH(m, &parent_ctx->submodules, entries) {
SCLogDebug("m %p %s:%s", m, m->name, m->conf_name);
- ConfNode *script = NULL;
+ SCConfNode *script = NULL;
TAILQ_FOREACH(script, &scripts->head, next) {
SCLogDebug("script %s", script->val);
if (strcmp(script->val, m->conf_name) == 0) {
*/
void RunModeInitializeOutputs(void)
{
- ConfNode *outputs = ConfGetNode("outputs");
+ SCConfNode *outputs = SCConfGetNode("outputs");
if (outputs == NULL) {
/* No "outputs" section in the configuration. */
return;
}
- ConfNode *output, *output_config;
+ SCConfNode *output, *output_config;
const char *enabled;
char tls_log_enabled = 0;
char tls_store_present = 0;
memset(logger_bits, 0, g_alproto_max * sizeof(LoggerId));
TAILQ_FOREACH(output, &outputs->head, next) {
- output_config = ConfNodeLookupChild(output, output->val);
+ output_config = SCConfNodeLookupChild(output, output->val);
if (output_config == NULL) {
/* Shouldn't happen. */
FatalError("Failed to lookup configuration child node: %s", output->val);
tls_store_present = 1;
}
- enabled = ConfNodeLookupChildValue(output_config, "enabled");
- if (enabled == NULL || !ConfValIsTrue(enabled)) {
+ enabled = SCConfNodeLookupChildValue(output_config, "enabled");
+ if (enabled == NULL || !SCConfValIsTrue(enabled)) {
continue;
}
SCLogWarning("Please use 'tls-store' in YAML to configure TLS storage");
TAILQ_FOREACH(output, &outputs->head, next) {
- output_config = ConfNodeLookupChild(output, output->val);
+ output_config = SCConfNodeLookupChild(output, output->val);
if (strcmp(output->val, "tls-log") == 0) {
void RunModeInitializeThreadSettings(void)
{
int affinity = 0;
- if ((ConfGetBool("threading.set-cpu-affinity", &affinity)) == 0) {
+ if ((SCConfGetBool("threading.set-cpu-affinity", &affinity)) == 0) {
threading_set_cpu_affinity = false;
} else {
threading_set_cpu_affinity = affinity == 1;
if (threading_set_cpu_affinity) {
AffinitySetupLoadFromConfig();
}
- if ((ConfGetFloat("threading.detect-thread-ratio", &threading_detect_ratio)) != 1) {
- if (ConfGetNode("threading.detect-thread-ratio") != NULL)
+ if ((SCConfGetFloat("threading.detect-thread-ratio", &threading_detect_ratio)) != 1) {
+ if (SCConfGetNode("threading.detect-thread-ratio") != NULL)
WarnInvalidConfEntry("threading.detect-thread-ratio", "%s", "1");
threading_detect_ratio = 1;
}
* in case the default per-thread stack size is to be adjusted
*/
const char *ss = NULL;
- if ((ConfGet("threading.stack-size", &ss)) == 1) {
+ if ((SCConfGet("threading.stack-size", &ss)) == 1) {
if (ss != NULL) {
if (ParseSizeStringU64(ss, &threading_set_stack_size) < 0) {
FatalError("Failed to initialize thread_stack_size output, invalid limit: %s", ss);
memset(&nfq_config, 0, sizeof(nfq_config));
- if ((ConfGet("nfq.mode", &nfq_mode)) == 0) {
+ if ((SCConfGet("nfq.mode", &nfq_mode)) == 0) {
nfq_config.mode = NFQ_ACCEPT_MODE;
} else {
if (!strcmp("accept", nfq_mode)) {
}
}
- (void)ConfGetBool("nfq.fail-open", &boolval);
+ (void)SCConfGetBool("nfq.fail-open", &boolval);
if (boolval) {
#ifdef HAVE_NFQ_SET_QUEUE_FLAGS
SCLogInfo("Enabling fail-open on queue");
#endif
}
- if ((ConfGetInt("nfq.repeat-mark", &value)) == 1) {
+ if ((SCConfGetInt("nfq.repeat-mark", &value)) == 1) {
nfq_config.mark = (uint32_t)value;
}
- if ((ConfGetInt("nfq.repeat-mask", &value)) == 1) {
+ if ((SCConfGetInt("nfq.repeat-mask", &value)) == 1) {
nfq_config.mask = (uint32_t)value;
}
- if ((ConfGetInt("nfq.bypass-mark", &value)) == 1) {
+ if ((SCConfGetInt("nfq.bypass-mark", &value)) == 1) {
nfq_config.bypass_mark = (uint32_t)value;
}
- if ((ConfGetInt("nfq.bypass-mask", &value)) == 1) {
+ if ((SCConfGetInt("nfq.bypass-mask", &value)) == 1) {
nfq_config.bypass_mask = (uint32_t)value;
}
- if ((ConfGetInt("nfq.route-queue", &value)) == 1) {
+ if ((SCConfGetInt("nfq.route-queue", &value)) == 1) {
nfq_config.next_queue = ((uint32_t)value) << 16;
}
- if ((ConfGetInt("nfq.batchcount", &value)) == 1) {
+ if ((SCConfGetInt("nfq.batchcount", &value)) == 1) {
#ifdef HAVE_NFQ_SET_VERDICT_BATCH
if (value > 255) {
SCLogWarning("nfq.batchcount cannot exceed 255.");
pcap_g.read_buffer_size = PCAP_FILE_BUFFER_SIZE_DEFAULT;
const char *str = NULL;
- if (ConfGet("pcap-file.buffer-size", &str) == 1) {
+ if (SCConfGet("pcap-file.buffer-size", &str) == 1) {
uint32_t value = 0;
if (ParseSizeStringU32(str, &value) < 0) {
SCLogWarning("failed to parse pcap-file.buffer-size %s", str);
memset(&ptv->shared.last_processed, 0, sizeof(struct timespec));
intmax_t tenant = 0;
- if (ConfGetInt("pcap-file.tenant-id", &tenant) == 1) {
+ if (SCConfGetInt("pcap-file.tenant-id", &tenant) == 1) {
if (tenant > 0 && tenant < UINT_MAX) {
ptv->shared.tenant_id = (uint32_t)tenant;
SCLogInfo("tenant %u", ptv->shared.tenant_id);
}
}
- if (ConfGet("bpf-filter", &(tmp_bpf_string)) != 1) {
+ if (SCConfGet("bpf-filter", &(tmp_bpf_string)) != 1) {
SCLogDebug("could not get bpf or none specified");
} else {
ptv->shared.bpf_string = SCStrdup(tmp_bpf_string);
int should_delete = 0;
ptv->shared.should_delete = false;
- if (ConfGetBool("pcap-file.delete-when-done", &should_delete) == 1) {
+ if (SCConfGetBool("pcap-file.delete-when-done", &should_delete) == 1) {
ptv->shared.should_delete = should_delete == 1;
}
int should_recurse;
pv->should_recurse = false;
- if (ConfGetBool("pcap-file.recursive", &should_recurse) == 1) {
+ if (SCConfGetBool("pcap-file.recursive", &should_recurse) == 1) {
pv->should_recurse = (should_recurse == 1);
}
int should_loop = 0;
pv->should_loop = false;
- if (ConfGetBool("pcap-file.continuous", &should_loop) == 1) {
+ if (SCConfGetBool("pcap-file.continuous", &should_loop) == 1) {
pv->should_loop = (should_loop == 1);
}
pv->delay = 30;
intmax_t delay = 0;
- if (ConfGetInt("pcap-file.delay", &delay) == 1) {
+ if (SCConfGetInt("pcap-file.delay", &delay) == 1) {
if (delay > 0 && delay < UINT_MAX) {
pv->delay = (time_t)delay;
SCLogDebug("delay %lu", pv->delay);
pv->poll_interval = 5;
intmax_t poll_interval = 0;
- if (ConfGetInt("pcap-file.poll-interval", &poll_interval) == 1) {
+ if (SCConfGetInt("pcap-file.poll-interval", &poll_interval) == 1) {
if (poll_interval > 0 && poll_interval < UINT_MAX) {
pv->poll_interval = (time_t)poll_interval;
SCLogDebug("poll-interval %lu", pv->delay);
ptv->behavior.directory = pv;
}
- if (ConfGet("pcap-file.checksum-checks", &tmpstring) != 1) {
+ if (SCConfGet("pcap-file.checksum-checks", &tmpstring) != 1) {
pcap_g.conf_checksum_mode = CHECKSUM_VALIDATION_AUTO;
} else {
if (strcmp(tmpstring, "auto") == 0) {
pcap_g.conf_checksum_mode = CHECKSUM_VALIDATION_AUTO;
- } else if (ConfValIsTrue(tmpstring)){
+ } else if (SCConfValIsTrue(tmpstring)) {
pcap_g.conf_checksum_mode = CHECKSUM_VALIDATION_ENABLE;
- } else if (ConfValIsFalse(tmpstring)) {
+ } else if (SCConfValIsFalse(tmpstring)) {
pcap_g.conf_checksum_mode = CHECKSUM_VALIDATION_DISABLE;
}
}
static int StreamTcpReassemblyConfig(bool quiet)
{
uint32_t segment_prealloc = 2048;
- ConfNode *seg = ConfGetNode("stream.reassembly.segment-prealloc");
+ SCConfNode *seg = SCConfGetNode("stream.reassembly.segment-prealloc");
if (seg) {
uint32_t prealloc = 0;
if (StringParseUint32(&prealloc, 10, (uint16_t)strlen(seg->val), seg->val) < 0) {
stream_config.prealloc_segments = segment_prealloc;
int overlap_diff_data = 0;
- (void)ConfGetBool("stream.reassembly.check-overlap-different-data", &overlap_diff_data);
+ (void)SCConfGetBool("stream.reassembly.check-overlap-different-data", &overlap_diff_data);
if (overlap_diff_data) {
StreamTcpReassembleConfigEnableOverlapCheck();
}
}
uint16_t max_regions = 8;
- ConfNode *mr = ConfGetNode("stream.reassembly.max-regions");
+ SCConfNode *mr = SCConfGetNode("stream.reassembly.max-regions");
if (mr) {
uint16_t max_r = 0;
if (StringParseUint16(&max_r, 10, (uint16_t)strlen(mr->val), mr->val) < 0) {
SC_ATOMIC_INIT(stream_config.memcap);
SC_ATOMIC_INIT(stream_config.reassembly_memcap);
- if ((ConfGetInt("stream.max-sessions", &value)) == 1) {
+ if ((SCConfGetInt("stream.max-sessions", &value)) == 1) {
SCLogWarning("max-sessions is obsolete. "
"Number of concurrent sessions is now only limited by Flow and "
"TCP stream engine memcaps.");
}
- if ((ConfGetInt("stream.prealloc-sessions", &value)) == 1) {
+ if ((SCConfGetInt("stream.prealloc-sessions", &value)) == 1) {
stream_config.prealloc_sessions = (uint32_t)value;
} else {
if (RunmodeIsUnittests()) {
stream_config.prealloc_sessions = 128;
} else {
stream_config.prealloc_sessions = STREAMTCP_DEFAULT_PREALLOC;
- if (ConfGetNode("stream.prealloc-sessions") != NULL) {
+ if (SCConfGetNode("stream.prealloc-sessions") != NULL) {
WarnInvalidConfEntry("stream.prealloc_sessions",
"%"PRIu32,
stream_config.prealloc_sessions);
}
const char *temp_stream_memcap_str;
- if (ConfGet("stream.memcap", &temp_stream_memcap_str) == 1) {
+ if (SCConfGet("stream.memcap", &temp_stream_memcap_str) == 1) {
uint64_t stream_memcap_copy;
if (ParseSizeStringU64(temp_stream_memcap_str, &stream_memcap_copy) < 0) {
SCLogError("Error parsing stream.memcap "
}
int imidstream;
- (void)ConfGetBool("stream.midstream", &imidstream);
+ (void)SCConfGetBool("stream.midstream", &imidstream);
stream_config.midstream = imidstream != 0;
if (!quiet) {
}
int async_oneside;
- (void)ConfGetBool("stream.async-oneside", &async_oneside);
+ (void)SCConfGetBool("stream.async-oneside", &async_oneside);
stream_config.async_oneside = async_oneside != 0;
if (!quiet) {
int csum = 0;
- if ((ConfGetBool("stream.checksum-validation", &csum)) == 1) {
+ if ((SCConfGetBool("stream.checksum-validation", &csum)) == 1) {
if (csum == 1) {
stream_config.flags |= STREAMTCP_INIT_FLAG_CHECKSUM_VALIDATION;
}
}
const char *temp_stream_inline_str;
- if (ConfGet("stream.inline", &temp_stream_inline_str) == 1) {
+ if (SCConfGet("stream.inline", &temp_stream_inline_str) == 1) {
int inl = 0;
/* checking for "auto" and falling back to boolean to provide
if (EngineModeIsIPS()) {
stream_config.flags |= STREAMTCP_INIT_FLAG_INLINE;
}
- } else if (ConfGetBool("stream.inline", &inl) == 1) {
+ } else if (SCConfGetBool("stream.inline", &inl) == 1) {
if (inl) {
stream_config.flags |= STREAMTCP_INIT_FLAG_INLINE;
}
}
int bypass = 0;
- if ((ConfGetBool("stream.bypass", &bypass)) == 1) {
+ if ((SCConfGetBool("stream.bypass", &bypass)) == 1) {
if (bypass == 1) {
stream_config.flags |= STREAMTCP_INIT_FLAG_BYPASS;
}
}
int drop_invalid = 0;
- if ((ConfGetBool("stream.drop-invalid", &drop_invalid)) == 1) {
+ if ((SCConfGetBool("stream.drop-invalid", &drop_invalid)) == 1) {
if (drop_invalid == 1) {
stream_config.flags |= STREAMTCP_INIT_FLAG_DROP_INVALID;
}
}
const char *temp_urgpol = NULL;
- if (ConfGet("stream.reassembly.urgent.policy", &temp_urgpol) == 1 && temp_urgpol != NULL) {
+ if (SCConfGet("stream.reassembly.urgent.policy", &temp_urgpol) == 1 && temp_urgpol != NULL) {
if (strcmp(temp_urgpol, "inline") == 0) {
stream_config.urgent_policy = TCP_STREAM_URGENT_INLINE;
} else if (strcmp(temp_urgpol, "drop") == 0) {
}
if (stream_config.urgent_policy == TCP_STREAM_URGENT_OOB) {
const char *temp_urgoobpol = NULL;
- if (ConfGet("stream.reassembly.urgent.oob-limit-policy", &temp_urgoobpol) == 1 &&
+ if (SCConfGet("stream.reassembly.urgent.oob-limit-policy", &temp_urgoobpol) == 1 &&
temp_urgoobpol != NULL) {
if (strcmp(temp_urgoobpol, "inline") == 0) {
stream_config.urgent_oob_limit_policy = TCP_STREAM_URGENT_INLINE;
}
}
- if ((ConfGetInt("stream.max-syn-queued", &value)) == 1) {
+ if ((SCConfGetInt("stream.max-syn-queued", &value)) == 1) {
if (value >= 0 && value <= 255) {
stream_config.max_syn_queued = (uint8_t)value;
} else {
SCLogConfig("stream \"max-syn-queued\": %" PRIu8, stream_config.max_syn_queued);
}
- if ((ConfGetInt("stream.max-synack-queued", &value)) == 1) {
+ if ((SCConfGetInt("stream.max-synack-queued", &value)) == 1) {
if (value >= 0 && value <= 255) {
stream_config.max_synack_queued = (uint8_t)value;
} else {
}
const char *temp_stream_reassembly_memcap_str;
- if (ConfGet("stream.reassembly.memcap", &temp_stream_reassembly_memcap_str) == 1) {
+ if (SCConfGet("stream.reassembly.memcap", &temp_stream_reassembly_memcap_str) == 1) {
uint64_t stream_reassembly_memcap_copy;
if (ParseSizeStringU64(temp_stream_reassembly_memcap_str,
&stream_reassembly_memcap_copy) < 0) {
}
const char *temp_stream_reassembly_depth_str;
- if (ConfGet("stream.reassembly.depth", &temp_stream_reassembly_depth_str) == 1) {
+ if (SCConfGet("stream.reassembly.depth", &temp_stream_reassembly_depth_str) == 1) {
if (ParseSizeStringU32(temp_stream_reassembly_depth_str,
&stream_config.reassembly_depth) < 0) {
SCLogError("Error parsing "
}
int randomize = 0;
- if ((ConfGetBool("stream.reassembly.randomize-chunk-size", &randomize)) == 0) {
+ if ((SCConfGetBool("stream.reassembly.randomize-chunk-size", &randomize)) == 0) {
/* randomize by default if value not set
* In ut mode we disable, to get predictable test results */
if (!(RunmodeIsUnittests()))
if (randomize) {
const char *temp_rdrange;
- if (ConfGet("stream.reassembly.randomize-chunk-range", &temp_rdrange) == 1) {
+ if (SCConfGet("stream.reassembly.randomize-chunk-range", &temp_rdrange) == 1) {
if (ParseSizeStringU16(temp_rdrange, &rdrange) < 0) {
SCLogError("Error parsing "
"stream.reassembly.randomize-chunk-range "
}
const char *temp_stream_reassembly_toserver_chunk_size_str;
- if (ConfGet("stream.reassembly.toserver-chunk-size",
+ if (SCConfGet("stream.reassembly.toserver-chunk-size",
&temp_stream_reassembly_toserver_chunk_size_str) == 1) {
if (ParseSizeStringU16(temp_stream_reassembly_toserver_chunk_size_str,
&stream_config.reassembly_toserver_chunk_size) < 0) {
rdrange / 100);
}
const char *temp_stream_reassembly_toclient_chunk_size_str;
- if (ConfGet("stream.reassembly.toclient-chunk-size",
+ if (SCConfGet("stream.reassembly.toclient-chunk-size",
&temp_stream_reassembly_toclient_chunk_size_str) == 1) {
if (ParseSizeStringU16(temp_stream_reassembly_toclient_chunk_size_str,
&stream_config.reassembly_toclient_chunk_size) < 0) {
}
int enable_raw = 1;
- if (ConfGetBool("stream.reassembly.raw", &enable_raw) == 1) {
+ if (SCConfGetBool("stream.reassembly.raw", &enable_raw) == 1) {
if (!enable_raw) {
stream_config.stream_init_flags = STREAMTCP_STREAM_FLAG_DISABLE_RAW;
}
/* default to true. Not many ppl (correctly) set up host-os policies, so be permissive. */
stream_config.liberal_timestamps = true;
int liberal_timestamps = 0;
- if (ConfGetBool("stream.liberal-timestamps", &liberal_timestamps) == 1) {
+ if (SCConfGetBool("stream.liberal-timestamps", &liberal_timestamps) == 1) {
stream_config.liberal_timestamps = liberal_timestamps;
}
if (!quiet)
MpmHSGlobalCleanup();
#endif
- ConfDeInit();
+ SCConfDeInit();
DetectParseFreeRegexes();
}
if(strlen(bpf_filter) > 0) {
- if (ConfSetFinal("bpf-filter", bpf_filter) != 1) {
+ if (SCConfSetFinal("bpf-filter", bpf_filter) != 1) {
SCLogError("Failed to set bpf filter.");
SCFree(bpf_filter);
return TM_ECODE_FAILED;
bpf_filter[strlen(bpf_filter)-1] = '\0';
}
if (strlen(bpf_filter) > 0) {
- if (ConfSetFinal("bpf-filter", bpf_filter) != 1) {
+ if (SCConfSetFinal("bpf-filter", bpf_filter) != 1) {
SCFree(bpf_filter);
FatalError("failed to set bpf filter");
}
if (suri->conf_filename == NULL)
suri->conf_filename = DEFAULT_CONF_FILE;
- if (ConfYamlLoadFile(suri->conf_filename) != 0) {
+ if (SCConfYamlLoadFile(suri->conf_filename) != 0) {
/* Error already displayed. */
SCReturnInt(TM_ECODE_FAILED);
}
if (suri->additional_configs) {
for (int i = 0; suri->additional_configs[i] != NULL; i++) {
SCLogConfig("Loading additional configuration file %s", suri->additional_configs[i]);
- ConfYamlHandleInclude(ConfGetRootNode(), suri->additional_configs[i]);
+ SCConfYamlHandleInclude(SCConfGetRootNode(), suri->additional_configs[i]);
}
}
if (strcmp(suricata.capture_plugin_name, "pfring") == 0) {
/* Special handling for pfring. */
if (strlen(pcap_dev)) {
- if (ConfSetFinal("pfring.live-interface", pcap_dev) != 1) {
+ if (SCConfSetFinal("pfring.live-interface", pcap_dev) != 1) {
SCLogError("Failed to set pfring.live-interface");
SCReturnInt(TM_ECODE_FAILED);
}
} else if (runmode == RUNMODE_AFP_DEV) {
/* iface has been set on command line */
if (strlen(pcap_dev)) {
- if (ConfSetFinal("af-packet.live-interface", pcap_dev) != 1) {
+ if (SCConfSetFinal("af-packet.live-interface", pcap_dev) != 1) {
SCLogError("Failed to set af-packet.live-interface");
SCReturnInt(TM_ECODE_FAILED);
}
} else if (runmode == RUNMODE_AFXDP_DEV) {
/* iface has been set on command line */
if (strlen(pcap_dev)) {
- if (ConfSetFinal("af-xdp.live-interface", pcap_dev) != 1) {
+ if (SCConfSetFinal("af-xdp.live-interface", pcap_dev) != 1) {
SCLogError("Failed to set af-xdp.live-interface");
SCReturnInt(TM_ECODE_FAILED);
}
} else if (runmode == RUNMODE_NETMAP) {
/* iface has been set on command line */
if (strlen(pcap_dev)) {
- if (ConfSetFinal("netmap.live-interface", pcap_dev) != 1) {
+ if (SCConfSetFinal("netmap.live-interface", pcap_dev) != 1) {
SCLogError("Failed to set netmap.live-interface");
SCReturnInt(TM_ECODE_FAILED);
}
}
else if(strcmp((long_opts[option_index]).name , "pfring-cluster-id") == 0){
#ifdef HAVE_PFRING
- if (ConfSetFinal("pfring.cluster-id", optarg) != 1) {
+ if (SCConfSetFinal("pfring.cluster-id", optarg) != 1) {
SCLogError("failed to set pfring.cluster-id");
return TM_ECODE_FAILED;
}
}
else if(strcmp((long_opts[option_index]).name , "pfring-cluster-type") == 0){
#ifdef HAVE_PFRING
- if (ConfSetFinal("pfring.cluster-type", optarg) != 1) {
+ if (SCConfSetFinal("pfring.cluster-type", optarg) != 1) {
SCLogError("failed to set pfring.cluster-type");
return TM_ECODE_FAILED;
}
SCLogInfo("Setting IPS mode");
EngineModeSetIPS();
} else if (strcmp((long_opts[option_index]).name, "init-errors-fatal") == 0) {
- if (ConfSetFinal("engine.init-failure-fatal", "1") != 1) {
+ if (SCConfSetFinal("engine.init-failure-fatal", "1") != 1) {
SCLogError("failed to set engine init-failure-fatal");
return TM_ECODE_FAILED;
}
if (suri->run_mode == RUNMODE_UNKNOWN) {
suri->run_mode = RUNMODE_UNIX_SOCKET;
if (optarg) {
- if (ConfSetFinal("unix-command.filename", optarg) != 1) {
+ if (SCConfSetFinal("unix-command.filename", optarg) != 1) {
SCLogError("failed to set unix-command.filename");
return TM_ECODE_FAILED;
}
-
}
} else {
SCLogError("more than one run mode "
#endif /* HAVE_LIBCAP_NG */
} else if (strcmp((long_opts[option_index]).name, "erf-in") == 0) {
suri->run_mode = RUNMODE_ERF_FILE;
- if (ConfSetFinal("erf-file.file", optarg) != 1) {
+ if (SCConfSetFinal("erf-file.file", optarg) != 1) {
SCLogError("failed to set erf-file.file");
return TM_ECODE_FAILED;
}
#endif /* HAVE_NAPATECH */
} else if (strcmp((long_opts[option_index]).name, "pcap-buffer-size") == 0) {
#ifdef HAVE_PCAP_SET_BUFF
- if (ConfSetFinal("pcap.buffer-size", optarg) != 1) {
+ if (SCConfSetFinal("pcap.buffer-size", optarg) != 1) {
SCLogError("failed to set pcap-buffer-size");
return TM_ECODE_FAILED;
}
if (val == NULL) {
FatalError("Invalid argument for --set, must be key=val.");
}
- if (!ConfSetFromString(optarg, 1)) {
+ if (!SCConfSetFromString(optarg, 1)) {
FatalError("failed to set configuration value %s", optarg);
}
}
}
else if (strcmp((long_opts[option_index]).name, "pcap-file-continuous") == 0) {
- if (ConfSetFinal("pcap-file.continuous", "true") != 1) {
+ if (SCConfSetFinal("pcap-file.continuous", "true") != 1) {
SCLogError("Failed to set pcap-file.continuous");
return TM_ECODE_FAILED;
}
}
else if (strcmp((long_opts[option_index]).name, "pcap-file-delete") == 0) {
- if (ConfSetFinal("pcap-file.delete-when-done", "true") != 1) {
+ if (SCConfSetFinal("pcap-file.delete-when-done", "true") != 1) {
SCLogError("Failed to set pcap-file.delete-when-done");
return TM_ECODE_FAILED;
}
}
else if (strcmp((long_opts[option_index]).name, "pcap-file-recursive") == 0) {
- if (ConfSetFinal("pcap-file.recursive", "true") != 1) {
+ if (SCConfSetFinal("pcap-file.recursive", "true") != 1) {
SCLogError("failed to set pcap-file.recursive");
return TM_ECODE_FAILED;
}
} else if (strcmp((long_opts[option_index]).name, "pcap-file-buffer-size") == 0) {
- if (ConfSetFinal("pcap-file.buffer-size", optarg) != 1) {
+ if (SCConfSetFinal("pcap-file.buffer-size", optarg) != 1) {
SCLogError("failed to set pcap-file.buffer-size");
return TM_ECODE_FAILED;
}
break;
case 'T':
conf_test = 1;
- if (ConfSetFinal("engine.init-failure-fatal", "1") != 1) {
+ if (SCConfSetFinal("engine.init-failure-fatal", "1") != 1) {
SCLogError("failed to set engine init-failure-fatal");
return TM_ECODE_FAILED;
}
SCLogError("pcap file '%s': %s", optarg, strerror(errno));
return TM_ECODE_FAILED;
}
- if (ConfSetFinal("pcap-file.file", optarg) != 1) {
+ if (SCConfSetFinal("pcap-file.file", optarg) != 1) {
SCLogError("ERROR: Failed to set pcap-file.file\n");
return TM_ECODE_FAILED;
}
if (suri->daemon == 1 && suri->pid_filename == NULL) {
const char *pid_filename;
- if (ConfGet("pid-file", &pid_filename) == 1) {
+ if (SCConfGet("pid-file", &pid_filename) == 1) {
SCLogInfo("Use pid file %s from config file.", pid_filename);
} else {
pid_filename = DEFAULT_PID_FILENAME;
command line as not decide of that */
if (!suri->do_setuid && !suri->do_setgid) {
const char *id;
- if (ConfGet("run-as.user", &id) == 1) {
+ if (SCConfGet("run-as.user", &id) == 1) {
suri->do_setuid = true;
suri->user_name = id;
}
- if (ConfGet("run-as.group", &id) == 1) {
+ if (SCConfGet("run-as.group", &id) == 1) {
suri->do_setgid = true;
suri->group_name = id;
}
UtilSignalHandlerSetup(SIGTERM, SignalHandlerSigterm);
#if HAVE_LIBUNWIND
int enabled;
- if (ConfGetBool("logging.stacktrace-on-signal", &enabled) == 0) {
+ if (SCConfGetBool("logging.stacktrace-on-signal", &enabled) == 0) {
enabled = 1;
}
if (suri->offline) {
suri->delayed_detect = 0;
} else {
- if (ConfGetBool("detect.delayed-detect", &suri->delayed_detect) != 1) {
- ConfNode *denode = NULL;
- ConfNode *decnf = ConfGetNode("detect-engine");
+ if (SCConfGetBool("detect.delayed-detect", &suri->delayed_detect) != 1) {
+ SCConfNode *denode = NULL;
+ SCConfNode *decnf = SCConfGetNode("detect-engine");
if (decnf != NULL) {
TAILQ_FOREACH(denode, &decnf->head, next) {
if (strcmp(denode->val, "delayed-detect") == 0) {
- (void)ConfGetChildValueBool(denode, "delayed-detect", &suri->delayed_detect);
+ (void)SCConfGetChildValueBool(
+ denode, "delayed-detect", &suri->delayed_detect);
}
}
}
/* Pull the max pending packets from the config, if not found fall
* back on a sane default. */
intmax_t tmp_max_pending_packets;
- if (ConfGetInt("max-pending-packets", &tmp_max_pending_packets) != 1)
+ if (SCConfGetInt("max-pending-packets", &tmp_max_pending_packets) != 1)
tmp_max_pending_packets = DEFAULT_MAX_PENDING_PACKETS;
if (tmp_max_pending_packets < 1 || tmp_max_pending_packets > 2147483648) {
SCLogError("Maximum max-pending-packets setting is 2147483648 and must be greater than 0. "
/* Pull the default packet size from the config, if not found fall
* back on a sane default. */
const char *temp_default_packet_size;
- if ((ConfGet("default-packet-size", &temp_default_packet_size)) != 1) {
+ if ((SCConfGet("default-packet-size", &temp_default_packet_size)) != 1) {
int lthread;
int nlive;
int strip_trailing_plus = 0;
if (!suri->disabled_detect) {
SetupDelayedDetect(suri);
int mt_enabled = 0;
- (void)ConfGetBool("multi-detect.enabled", &mt_enabled);
+ (void)SCConfGetBool("multi-detect.enabled", &mt_enabled);
int default_tenant = 0;
if (mt_enabled)
- (void)ConfGetBool("multi-detect.default", &default_tenant);
+ (void)SCConfGetBool("multi-detect.default", &default_tenant);
if (DetectEngineMultiTenantSetup(suri->unix_socket_enabled) == -1) {
FatalError("initializing multi-detect "
"detection engine contexts failed.");
{
const char *hostmode = NULL;
- if (ConfGet("host-mode", &hostmode) == 1) {
+ if (SCConfGet("host-mode", &hostmode) == 1) {
if (!strcmp(hostmode, "router")) {
host_mode = SURI_HOST_IS_ROUTER;
} else if (!strcmp(hostmode, "sniffer-only")) {
SpmTableSetup();
int disable_offloading;
- if (ConfGetBool("capture.disable-offloading", &disable_offloading) == 0)
+ if (SCConfGetBool("capture.disable-offloading", &disable_offloading) == 0)
disable_offloading = 1;
if (disable_offloading) {
LiveSetOffloadDisable();
if (suri->checksum_validation == -1) {
const char *cv = NULL;
- if (ConfGet("capture.checksum-validation", &cv) == 1) {
+ if (SCConfGet("capture.checksum-validation", &cv) == 1) {
if (strcmp(cv, "none") == 0) {
suri->checksum_validation = 0;
} else if (strcmp(cv, "all") == 0) {
}
switch (suri->checksum_validation) {
case 0:
- ConfSet("stream.checksum-validation", "0");
+ SCConfSet("stream.checksum-validation", "0");
break;
case 1:
- ConfSet("stream.checksum-validation", "1");
+ SCConfSet("stream.checksum-validation", "1");
break;
}
if (suri->runmode_custom_mode) {
- ConfSet("runmode", suri->runmode_custom_mode);
+ SCConfSet("runmode", suri->runmode_custom_mode);
}
StorageInit();
SetMasterExceptionPolicy();
- ConfNode *eps = ConfGetNode("stats.exception-policy");
+ SCConfNode *eps = SCConfGetNode("stats.exception-policy");
if (eps != NULL) {
- if (ConfNodeChildValueIsTrue(eps, "per-app-proto-errors")) {
+ if (SCConfNodeChildValueIsTrue(eps, "per-app-proto-errors")) {
g_stats_eps_per_app_proto_errors = true;
}
}
/* Suricata will use this umask if provided. By default it will use the
umask passed on from the shell. */
const char *custom_umask;
- if (ConfGet("umask", &custom_umask) == 1) {
+ if (SCConfGet("umask", &custom_umask) == 1) {
uint16_t mask;
if (StringParseUint16(&mask, 8, (uint16_t)strlen(custom_umask), custom_umask) > 0) {
umask((mode_t)mask);
}
}
-
if (ConfigGetCaptureValue(suri) != TM_ECODE_OK) {
SCReturnInt(TM_ECODE_FAILED);
}
if (suri->run_mode == RUNMODE_ENGINE_ANALYSIS) {
SCLogInfo("== Carrying out Engine Analysis ==");
const char *temp = NULL;
- if (ConfGet("engine-analysis", &temp) == 0) {
+ if (SCConfGet("engine-analysis", &temp) == 0) {
SCLogInfo("no engine-analysis parameter(s) defined in conf file. "
"Please define/enable them in the conf to use this "
"feature.");
/* Check for the existence of the default logging directory which we pick
* from suricata.yaml. If not found, shut the engine down */
- suri->log_dir = ConfigGetLogDirectory();
+ suri->log_dir = SCConfigGetLogDirectory();
if (ConfigCheckLogDirectoryExists(suri->log_dir) != TM_ECODE_OK) {
SCLogError("The logging directory \"%s\" "
if (suri->disabled_detect) {
SCLogConfig("detection engine disabled");
/* disable raw reassembly */
- (void)ConfSetFinal("stream.reassembly.raw", "false");
+ (void)SCConfSetFinal("stream.reassembly.raw", "false");
}
HostInitConfig(HOST_VERBOSE);
RunModeRegisterRunModes();
/* Initialize the configuration module. */
- ConfInit();
+ SCConfInit();
DatalinkTableInit();
VarNameStoreInit();
GlobalsInitPreConfig();
if (suricata.run_mode == RUNMODE_DUMP_CONFIG) {
- ConfDump();
+ SCConfDump();
exit(EXIT_SUCCESS);
}
int tracking = 1;
- if (ConfGetBool("vlan.use-for-tracking", &tracking) == 1 && !tracking) {
+ if (SCConfGetBool("vlan.use-for-tracking", &tracking) == 1 && !tracking) {
/* Ignore vlan_ids when comparing flows. */
g_vlan_mask = 0x0000;
}
SCLogDebug("vlan tracking is %s", tracking == 1 ? "enabled" : "disabled");
- if (ConfGetBool("livedev.use-for-tracking", &tracking) == 1 && !tracking) {
+ if (SCConfGetBool("livedev.use-for-tracking", &tracking) == 1 && !tracking) {
/* Ignore livedev id when comparing flows. */
g_livedev_mask = 0x0000;
}
- if (ConfGetBool("decoder.recursion-level.use-for-tracking", &tracking) == 1 && !tracking) {
+ if (SCConfGetBool("decoder.recursion-level.use-for-tracking", &tracking) == 1 && !tracking) {
/* Ignore recursion level when comparing flows. */
g_recurlvl_mask = 0x00;
}
}
int limit_nproc = 0;
- if (ConfGetBool("security.limit-noproc", &limit_nproc) == 0) {
+ if (SCConfGetBool("security.limit-noproc", &limit_nproc) == 0) {
limit_nproc = 0;
}
memset(&ssn, 0, sizeof(ssn));
if (yaml) {
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(yaml, strlen(yaml));
+ SCConfYamlLoadString(yaml, strlen(yaml));
HTPConfigure();
}
if (yaml) {
HtpConfigRestoreBackup();
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
}
PASS;
}
memset(&ssn, 0, sizeof(ssn));
if (yaml) {
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString(yaml, strlen(yaml));
+ SCConfYamlLoadString(yaml, strlen(yaml));
HTPConfigure();
EngineModeSetIPS();
}
if (yaml) {
HtpConfigRestoreBackup();
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
EngineModeSetIDS();
}
PASS;
p->proto = IPPROTO_TCP;
p->dp = 80;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
return result;
}
p = UTHBuildPacketSrcDstPorts((uint8_t *)buf, buflen, IPPROTO_TCP, 12345, 1234);
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
UTHFreePackets(&p, 1);
return result;
}
p = UTHBuildPacketSrcDstPorts((uint8_t *)buf, buflen, IPPROTO_TCP, 12345, 80);
FAIL_IF_NULL(p);
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
FAIL_IF_NULL(de_ctx);
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
UTHFreePackets(&p, 1);
PASS;
p->sp = 21;
p->flowflags |= FLOW_PKT_TOSERVER;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
return result;
}
p->sp = 21;
p->flowflags |= FLOW_PKT_TOSERVER;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
return result;
}
{
int result = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string2, strlen(dummy_conf_string2));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string2, strlen(dummy_conf_string2));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineCtxFree(de_ctx);
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
return result;
}
{
int result = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string3, strlen(dummy_conf_string3));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string3, strlen(dummy_conf_string3));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineCtxFree(de_ctx);
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
return result;
}
{
int result = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string4, strlen(dummy_conf_string4));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string4, strlen(dummy_conf_string4));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineCtxFree(de_ctx);
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
return result;
}
{
int result = 0;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string5, strlen(dummy_conf_string5));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string5, strlen(dummy_conf_string5));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineCtxFree(de_ctx);
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
return result;
}
//redirect logs to /tmp
ConfigSetLogDirectory("/tmp/");
// disables checksums validation for fuzzing
- if (ConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
+ if (SCConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
abort();
}
//global init
InitGlobal();
SCRunmodeSet(RUNMODE_UNITTEST);
- if (ConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
+ if (SCConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
abort();
}
MpmTableSetup();
/**
* @file
* @author Philippe Antoine <contact@catenacyber.fr>
- * fuzz target for ConfYamlLoadString
+ * fuzz target for SCConfYamlLoadString
*/
-
#include "suricata-common.h"
#include "suricata.h"
#include "conf-yaml-loader.h"
initialized = 1;
}
- ConfYamlLoadString((const char *) data, size);
+ SCConfYamlLoadString((const char *)data, size);
return 0;
}
//redirect logs to /tmp
ConfigSetLogDirectory("/tmp/");
//disables checksums validation for fuzzing
- if (ConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
+ if (SCConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
abort();
}
/**
* @file
* @author Philippe Antoine <contact@catenacyber.fr>
- * fuzz target for ConfYamlLoadString
+ * fuzz target for SCConfYamlLoadString
*/
-
#include "suricata-common.h"
#include "suricata.h"
#include "rust.h"
// redirect logs to /tmp
ConfigSetLogDirectory("/tmp/");
// disables checksums validation for fuzzing
- if (ConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
+ if (SCConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
abort();
}
surifuzz.sig_file = malloc(strlen(filepath) + strlen("/fuzz.rules") + 1);
//redirect logs to /tmp
ConfigSetLogDirectory("/tmp/");
//disables checksums validation for fuzzing
- if (ConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
+ if (SCConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
abort();
}
// do not load rules before reproducible DetectEngineReload
break;
}
}
- if (ConfYamlLoadString(data, pos) != 0) {
+ if (SCConfYamlLoadString(data, pos) != 0) {
return 0;
}
if (pos < size) {
// redirect logs to /tmp
ConfigSetLogDirectory("/tmp/");
// disables checksums validation for fuzzing
- if (ConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
+ if (SCConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) {
abort();
}
// do not load rules before reproducible DetectEngineReload
goto end;
}
- if (ConfGet(conf_var_full_name, &conf_var_value) != 1) {
+ if (SCConfGet(conf_var_full_name, &conf_var_value) != 1) {
SCLogError("Error in getting conf value for conf name %s", conf_var_full_name);
goto end;
}
StreamTcpUTInit(&stt.ra_ctx);
/* Load the config string into parser */
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
/* Get the IP address as string and add it to Host info tree for lookups */
ip_addr = StreamTcpParseOSPolicy(os_policy_name);
ret = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
FLOW_DESTROY(&f);
StreamTcpUTDeinit(stt.ra_ctx);
StreamTcpUTInit(&stt.ra_ctx);
/* Load the config string into parser */
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
/* Get the IP address as string and add it to Host info tree for lookups */
ip_addr = StreamTcpParseOSPolicy(os_policy_name);
ret = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
FLOW_DESTROY(&f);
StreamTcpUTDeinit(stt.ra_ctx);
StreamTcpUTInit(&stt.ra_ctx);
/* Load the config string into parser */
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
/* Get the IP address as string and add it to Host info tree for lookups */
ip_addr = StreamTcpParseOSPolicy(os_policy_name);
ret = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
FLOW_DESTROY(&f);
StreamTcpUTDeinit(stt.ra_ctx);
StreamTcpUTInit(&stt.ra_ctx);
/* Load the config string into parser */
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
/* Get the IP address as string and add it to Host info tree for lookups */
ip_addr = StreamTcpParseOSPolicy(os_policy_name);
ret = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
FLOW_DESTROY(&f);
StreamTcpUTDeinit(stt.ra_ctx);
SCHInfoCleanResources();
/* Load the config string into parser */
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
/* Get the IP address as string and add it to Host info tree for lookups */
ip_addr = StreamTcpParseOSPolicy(os_policy_name);
ret = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
StreamTcpUTDeinit(stt.ra_ctx);
return ret;
SCHInfoCleanResources();
/* Load the config string into parser */
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
/* Get the IP address as string and add it to Host info tree for lookups */
ip_addr = StreamTcpParseOSPolicy(os_policy_name);
ret = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
StreamTcpUTDeinit(stt.ra_ctx);
return ret;
SCHInfoCleanResources();
/* Load the config string into parser */
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
/* Get the IP address as string and add it to Host info tree for lookups */
ip_addr = StreamTcpParseOSPolicy(os_policy_name);
ret = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
StreamTcpUTDeinit(stt.ra_ctx);
return ret;
SCHInfoCleanResources();
/* Load the config string into parser */
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
/* Get the IP address as string and add it to Host info tree for lookups */
ip_addr = StreamTcpParseOSPolicy(os_policy_name);
ret = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
StreamTcpUTDeinit(stt.ra_ctx);
return ret;
SCHInfoCleanResources();
/* Load the config string into parser */
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string1, strlen(dummy_conf_string1));
/* Get the IP address as string and add it to Host info tree for lookups */
ip_addr = StreamTcpParseOSPolicy(os_policy_name);
ret = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCFree(p);
StreamTcpUTDeinit(stt.ra_ctx);
return ret;
tmqh_table[TMQH_FLOW].RegisterTests = TmqhFlowRegisterTests;
const char *scheduler = NULL;
- if (ConfGet("autofp-scheduler", &scheduler) == 1) {
+ if (SCConfGet("autofp-scheduler", &scheduler) == 1) {
if (strcasecmp(scheduler, "round-robin") == 0) {
SCLogNotice("using flow hash instead of round robin");
tmqh_table[TMQH_FLOW].OutHandler = TmqhOutputFlowHash;
TAILQ_INIT(&this->clients);
int check_dir = 0;
- if (ConfGet("unix-command.filename", &socketname) == 1) {
+ if (SCConfGet("unix-command.filename", &socketname) == 1) {
if (PathIsAbsolute(socketname)) {
strlcpy(sockettarget, socketname, sizeof(sockettarget));
} else {
}
variable = (char *)json_string_value(jarg);
- if (ConfGet(variable, &confval) != 1) {
+ if (SCConfGet(variable, &confval) != 1) {
json_object_set_new(server_msg, "message", json_string("Unable to get value"));
SCReturnInt(TM_ECODE_FAILED);
}
{
if (UnixNew(&command) == 0) {
int failure_fatal = 0;
- if (ConfGetBool("engine.init-failure-fatal", &failure_fatal) != 1) {
+ if (SCConfGetBool("engine.init-failure-fatal", &failure_fatal) != 1) {
SCLogDebug("ConfGetBool could not load the value.");
}
if (failure_fatal) {
uint8_t actions_config[4] = {0, 0, 0, 0};
int order = 0;
- ConfNode *action_order;
- ConfNode *action = NULL;
+ SCConfNode *action_order;
+ SCConfNode *action = NULL;
/* Let's load the order of actions from the general config */
- action_order = ConfGetNode("action-order");
+ action_order = SCConfGetNode("action-order");
if (action_order == NULL) {
/* No configuration, use defaults. */
return 0;
- reject\n\
- alert\n";
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
ActionInitConfig();
FAIL_IF_NOT(action_order_sigs[0] == ACTION_PASS);
FAIL_IF_NOT(action_order_sigs[1] == ACTION_DROP);
FAIL_IF_NOT(action_order_sigs[2] == ACTION_REJECT);
FAIL_IF_NOT(action_order_sigs[3] == ACTION_ALERT);
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
/* Restore default values */
action_order_sigs[0] = ACTION_PASS;
- reject\n\
- ftw\n";
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
ActionInitConfig();
FAIL_IF_NOT(action_order_sigs[0] == ACTION_PASS);
FAIL_IF_NOT(action_order_sigs[1] == ACTION_DROP);
FAIL_IF_NOT(action_order_sigs[2] == ACTION_REJECT);
FAIL_IF_NOT(action_order_sigs[3] == ACTION_ALERT);
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
/* Restore default values */
action_order_sigs[0] = ACTION_PASS;
- drop\n\
- reject\n";
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
ActionInitConfig();
FAIL_IF_NOT(action_order_sigs[0] == ACTION_PASS);
FAIL_IF_NOT(action_order_sigs[1] == ACTION_DROP);
FAIL_IF_NOT(action_order_sigs[2] == ACTION_REJECT);
FAIL_IF_NOT(action_order_sigs[3] == ACTION_ALERT);
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
/* Restore default values */
action_order_sigs[0] = ACTION_PASS;
---\n\
action-order:\n";
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
ActionInitConfig();
FAIL_IF_NOT(action_order_sigs[0] == ACTION_PASS);
FAIL_IF_NOT(action_order_sigs[1] == ACTION_DROP);
FAIL_IF_NOT(action_order_sigs[2] == ACTION_REJECT);
FAIL_IF_NOT(action_order_sigs[3] == ACTION_ALERT);
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
/* Restore default values */
action_order_sigs[0] = ACTION_PASS;
- pass\n\
- whatever\n";
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
ActionInitConfig();
FAIL_IF_NOT(action_order_sigs[0] == ACTION_PASS);
FAIL_IF_NOT(action_order_sigs[1] == ACTION_DROP);
FAIL_IF_NOT(action_order_sigs[2] == ACTION_REJECT);
FAIL_IF_NOT(action_order_sigs[3] == ACTION_ALERT);
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
/* Restore default values */
action_order_sigs[0] = ACTION_PASS;
- reject\n\
- pass\n";
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
ActionInitConfig();
FAIL_IF_NOT(action_order_sigs[0] == ACTION_ALERT);
FAIL_IF_NOT(action_order_sigs[1] == ACTION_DROP);
FAIL_IF_NOT(action_order_sigs[2] == ACTION_REJECT);
FAIL_IF_NOT(action_order_sigs[3] == ACTION_PASS);
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
/* Restore default values */
action_order_sigs[0] = ACTION_PASS;
- drop\n\
- reject\n";
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
ActionInitConfig();
FAIL_IF_NOT(action_order_sigs[0] == ACTION_PASS);
FAIL_IF_NOT(action_order_sigs[1] == ACTION_ALERT);
FAIL_IF_NOT(action_order_sigs[2] == ACTION_DROP);
FAIL_IF_NOT(action_order_sigs[3] == ACTION_REJECT);
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
/* Restore default values */
action_order_sigs[0] = ACTION_PASS;
char config[] = "%YAML 1.1\n"
"---\n";
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
FAIL_IF_NOT(ActionInitConfig() == 0);
FAIL_IF_NOT(action_order_sigs[0] == ACTION_PASS);
FAIL_IF_NOT(action_order_sigs[2] == ACTION_REJECT);
FAIL_IF_NOT(action_order_sigs[3] == ACTION_ALERT);
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
PASS;
}
}
}
-void BuildCpusetWithCallback(const char *name, ConfNode *node,
- void (*Callback)(int i, void * data),
- void *data)
+void BuildCpusetWithCallback(
+ const char *name, SCConfNode *node, void (*Callback)(int i, void *data), void *data)
{
- ConfNode *lnode;
+ SCConfNode *lnode;
TAILQ_FOREACH(lnode, &node->head, next) {
uint32_t i;
uint32_t a, b;
CPU_SET(i, (cpu_set_t *)data);
}
-static void BuildCpuset(const char *name, ConfNode *node, cpu_set_t *cpu)
+static void BuildCpuset(const char *name, SCConfNode *node, cpu_set_t *cpu)
{
BuildCpusetWithCallback(name, node, AffinityCallback, (void *) cpu);
}
void AffinitySetupLoadFromConfig(void)
{
#if !defined __CYGWIN__ && !defined OS_WIN32 && !defined __OpenBSD__ && !defined sun
- ConfNode *root = ConfGetNode("threading.cpu-affinity");
- ConfNode *affinity;
+ SCConfNode *root = SCConfGetNode("threading.cpu-affinity");
+ SCConfNode *affinity;
if (thread_affinity_init_done == 0) {
AffinitySetupInit();
setname = "worker-cpu-set";
ThreadsAffinityType *taf = GetAffinityTypeFromName(setname);
- ConfNode *node = NULL;
- ConfNode *nprio = NULL;
+ SCConfNode *node = NULL;
+ SCConfNode *nprio = NULL;
if (taf == NULL) {
FatalError("unknown cpu-affinity type");
}
CPU_ZERO(&taf->cpu_set);
- node = ConfNodeLookupChild(affinity->head.tqh_first, "cpu");
+ node = SCConfNodeLookupChild(affinity->head.tqh_first, "cpu");
if (node == NULL) {
SCLogInfo("unable to find 'cpu'");
} else {
CPU_ZERO(&taf->lowprio_cpu);
CPU_ZERO(&taf->medprio_cpu);
CPU_ZERO(&taf->hiprio_cpu);
- nprio = ConfNodeLookupChild(affinity->head.tqh_first, "prio");
+ nprio = SCConfNodeLookupChild(affinity->head.tqh_first, "prio");
if (nprio != NULL) {
- node = ConfNodeLookupChild(nprio, "low");
+ node = SCConfNodeLookupChild(nprio, "low");
if (node == NULL) {
SCLogDebug("unable to find 'low' prio using default value");
} else {
BuildCpuset(setname, node, &taf->lowprio_cpu);
}
- node = ConfNodeLookupChild(nprio, "medium");
+ node = SCConfNodeLookupChild(nprio, "medium");
if (node == NULL) {
SCLogDebug("unable to find 'medium' prio using default value");
} else {
BuildCpuset(setname, node, &taf->medprio_cpu);
}
- node = ConfNodeLookupChild(nprio, "high");
+ node = SCConfNodeLookupChild(nprio, "high");
if (node == NULL) {
SCLogDebug("unable to find 'high' prio using default value");
} else {
BuildCpuset(setname, node, &taf->hiprio_cpu);
}
- node = ConfNodeLookupChild(nprio, "default");
+ node = SCConfNodeLookupChild(nprio, "default");
if (node != NULL) {
if (!strcmp(node->val, "low")) {
taf->prio = PRIO_LOW;
}
}
- node = ConfNodeLookupChild(affinity->head.tqh_first, "mode");
+ node = SCConfNodeLookupChild(affinity->head.tqh_first, "mode");
if (node != NULL) {
if (!strcmp(node->val, "exclusive")) {
taf->mode_flag = EXCLUSIVE_AFFINITY;
}
}
- node = ConfNodeLookupChild(affinity->head.tqh_first, "threads");
+ node = SCConfNodeLookupChild(affinity->head.tqh_first, "threads");
if (node != NULL) {
if (StringParseUint32(&taf->nb_threads, 10, 0, (const char *)node->val) < 0) {
FatalError("invalid value for threads "
void UtilAffinityCpusExclude(ThreadsAffinityType *mod_taf, ThreadsAffinityType *static_taf);
#endif /* HAVE_DPDK */
-void BuildCpusetWithCallback(const char *name, ConfNode *node,
- void (*Callback)(int i, void * data),
- void *data);
+void BuildCpusetWithCallback(
+ const char *name, SCConfNode *node, void (*Callback)(int i, void *data), void *data);
#endif /* SURICATA_UTIL_AFFINITY_H */
#include "util-debug.h"
void ConfSetBPFFilter(
- ConfNode *if_root, ConfNode *if_default, const char *iface, const char **bpf_filter)
+ SCConfNode *if_root, SCConfNode *if_default, const char *iface, const char **bpf_filter)
{
if (*bpf_filter != NULL) {
SCLogInfo("BPF filter already configured");
}
/* command line value has precedence */
- if (ConfGet("bpf-filter", bpf_filter) == 1) {
+ if (SCConfGet("bpf-filter", bpf_filter) == 1) {
if (strlen(*bpf_filter) > 0) {
SCLogConfig("%s: using command-line provided bpf filter '%s'", iface, *bpf_filter);
}
- } else if (ConfGetChildValueWithDefault(if_root, if_default, "bpf-filter", bpf_filter) ==
+ } else if (SCConfGetChildValueWithDefault(if_root, if_default, "bpf-filter", bpf_filter) ==
1) { // reading from a file
if (strlen(*bpf_filter) > 0) {
SCLogConfig("%s: using file provided bpf filter %s", iface, *bpf_filter);
#include "conf.h"
void ConfSetBPFFilter(
- ConfNode *if_root, ConfNode *if_default, const char *iface, const char **bpf_filter);
+ SCConfNode *if_root, SCConfNode *if_default, const char *iface, const char **bpf_filter);
int SCBPFCompile(int snaplen_arg, int linktype_arg, struct bpf_program *program,
const char *buf, int optimize, uint32_t mask,
const char *classtype, const char *classtype_desc, int priority);
static void SCClassConfDeAllocClasstype(SCClassConfClasstype *ct);
-void SCClassConfInit(DetectEngineCtx *de_ctx)
+void SCClassSCConfInit(DetectEngineCtx *de_ctx)
{
int en;
PCRE2_SIZE eo;
/* try loading prefix setting, fall back to global if that
* fails. */
- if (ConfGet(config_value, &log_filename) != 1) {
- if (ConfGet("classification-file", &log_filename) != 1) {
+ if (SCConfGet(config_value, &log_filename) != 1) {
+ if (SCConfGet("classification-file", &log_filename) != 1) {
log_filename = (char *)SC_CLASS_CONF_DEF_CONF_FILEPATH;
}
}
} else {
- if (ConfGet("classification-file", &log_filename) != 1) {
+ if (SCConfGet("classification-file", &log_filename) != 1) {
log_filename = (char *)SC_CLASS_CONF_DEF_CONF_FILEPATH;
}
}
DetectEngineCtx *);
void SCClassConfDeInitContext(DetectEngineCtx *);
-void SCClassConfInit(DetectEngineCtx *de_ctx);
+void SCClassSCConfInit(DetectEngineCtx *de_ctx);
void SCClassConfDeinit(DetectEngineCtx *de_ctx);
/* for unittests */
TmEcode ConfigSetLogDirectory(const char *name)
{
- return ConfSetFinal("default-log-dir", name) ? TM_ECODE_OK : TM_ECODE_FAILED;
+ return SCConfSetFinal("default-log-dir", name) ? TM_ECODE_OK : TM_ECODE_FAILED;
}
-const char *ConfigGetLogDirectory(void)
+const char *SCConfigGetLogDirectory(void)
{
const char *log_dir = NULL;
- if (ConfGet("default-log-dir", &log_dir) != 1) {
+ if (SCConfGet("default-log-dir", &log_dir) != 1) {
#ifdef OS_WIN32
log_dir = _getcwd(NULL, 0);
if (log_dir == NULL) {
if (size > 2 && tmp[size - 2] == '/') // > 2 to allow just /
tmp[size - 2] = '\0';
- return ConfSetFinal("default-data-dir", tmp) ? TM_ECODE_OK : TM_ECODE_FAILED;
+ return SCConfSetFinal("default-data-dir", tmp) ? TM_ECODE_OK : TM_ECODE_FAILED;
}
const char *ConfigGetDataDirectory(void)
{
const char *data_dir = NULL;
- if (ConfGet("default-data-dir", &data_dir) != 1) {
+ if (SCConfGet("default-data-dir", &data_dir) != 1) {
#ifdef OS_WIN32
data_dir = _getcwd(NULL, 0);
if (data_dir == NULL) {
*
* \param iface The name of the interface to find the config for.
*/
-ConfNode *ConfFindDeviceConfig(ConfNode *node, const char *iface)
+SCConfNode *ConfFindDeviceConfig(SCConfNode *node, const char *iface)
{
- ConfNode *if_node, *item;
+ SCConfNode *if_node, *item;
TAILQ_FOREACH(if_node, &node->head, next) {
TAILQ_FOREACH(item, &if_node->head, next) {
if (strcmp(item->name, "interface") == 0 &&
{
const char *value;
- if (ConfGet("unix-command.enabled", &value) != 1) {
+ if (SCConfGet("unix-command.enabled", &value) != 1) {
return 0;
}
#endif
}
- return ConfValIsTrue(value);
+ return SCConfValIsTrue(value);
}
#include "conf.h"
TmEcode ConfigSetLogDirectory(const char *name);
-const char *ConfigGetLogDirectory(void);
+const char *SCConfigGetLogDirectory(void);
TmEcode ConfigCheckLogDirectoryExists(const char *log_dir);
TmEcode ConfigSetDataDirectory(char *name);
const char *ConfigGetDataDirectory(void);
TmEcode ConfigCheckDataDirectory(const char *log_dir);
-ConfNode *ConfFindDeviceConfig(ConfNode *node, const char *iface);
+SCConfNode *ConfFindDeviceConfig(SCConfNode *node, const char *iface);
int ConfUnixSocketIsEnable(void);
const char *dump_size_config = NULL;
size_t rlim_size = sizeof(rlim_t);
- if (ConfGet ("coredump.max-dump", &dump_size_config) == 0) {
+ if (SCConfGet("coredump.max-dump", &dump_size_config) == 0) {
SCLogDebug ("core dump size not specified");
return 1;
}
FatalError("Error creating new session");
}
- if (ConfGet("daemon-directory", &daemondir) == 1) {
+ if (SCConfGet("daemon-directory", &daemondir) == 1) {
if ((chdir(daemondir)) < 0) {
FatalError("Error changing to working directory");
}
void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid)
{
- ConfNode *outputs;
+ SCConfNode *outputs;
SCLogInitData *sc_lid;
int have_logging = 0;
int max_level = 0;
min_level = SC_LOG_NOTICE + verbose;
}
- outputs = ConfGetNode("logging.outputs");
+ outputs = SCConfGetNode("logging.outputs");
if (outputs == NULL) {
SCLogDebug("No logging.output configuration section found.");
return;
/* Get default log level and format. */
const char *default_log_level_s = NULL;
- if (ConfGet("logging.default-log-level", &default_log_level_s) == 1) {
+ if (SCConfGet("logging.default-log-level", &default_log_level_s) == 1) {
SCLogLevel default_log_level =
SCMapEnumNameToValue(default_log_level_s, sc_log_level_map);
if (default_log_level == -1) {
exit(EXIT_FAILURE);
}
sc_lid->global_log_level = MAX(min_level, default_log_level);
- }
- else {
+ } else {
sc_lid->global_log_level = MAX(min_level, SC_LOG_NOTICE);
}
- if (ConfGet("logging.default-log-format", &sc_lid->global_log_format) != 1)
+ if (SCConfGet("logging.default-log-format", &sc_lid->global_log_format) != 1)
sc_lid->global_log_format = SCLogGetDefaultLogFormat(sc_lid->global_log_level);
- (void)ConfGet("logging.default-output-filter", &sc_lid->op_filter);
+ (void)SCConfGet("logging.default-output-filter", &sc_lid->op_filter);
- ConfNode *seq_node, *output;
+ SCConfNode *seq_node, *output;
TAILQ_FOREACH(seq_node, &outputs->head, next) {
SCLogLevel level = sc_lid->global_log_level;
SCLogOPIfaceCtx *op_iface_ctx = NULL;
const char *format;
const char *level_s;
- output = ConfNodeLookupChild(seq_node, seq_node->val);
+ output = SCConfNodeLookupChild(seq_node, seq_node->val);
if (output == NULL)
continue;
/* By default an output is enabled. */
- const char *enabled = ConfNodeLookupChildValue(output, "enabled");
- if (enabled != NULL && ConfValIsFalse(enabled))
+ const char *enabled = SCConfNodeLookupChildValue(output, "enabled");
+ if (enabled != NULL && SCConfValIsFalse(enabled))
continue;
SCLogOPType type = SC_LOG_OP_TYPE_REGULAR;
- const char *type_s = ConfNodeLookupChildValue(output, "type");
+ const char *type_s = SCConfNodeLookupChildValue(output, "type");
if (type_s != NULL) {
if (strcmp(type_s, "regular") == 0)
type = SC_LOG_OP_TYPE_REGULAR;
}
}
- format = ConfNodeLookupChildValue(output, "format");
+ format = SCConfNodeLookupChildValue(output, "format");
- level_s = ConfNodeLookupChildValue(output, "level");
+ level_s = SCConfNodeLookupChildValue(output, "level");
if (level_s != NULL) {
level = SCMapEnumNameToValue(level_s, sc_log_level_map);
if (level == -1) {
format = SC_LOG_DEF_FILE_FORMAT;
}
- const char *filename = ConfNodeLookupChildValue(output, "filename");
+ const char *filename = SCConfNodeLookupChildValue(output, "filename");
if (filename == NULL) {
FatalError("Logging to file requires a filename");
}
}
else if (strcmp(output->name, "syslog") == 0) {
int facility = SC_LOG_DEF_SYSLOG_FACILITY;
- const char *facility_s = ConfNodeLookupChildValue(output,
- "facility");
+ const char *facility_s = SCConfNodeLookupChildValue(output, "facility");
if (facility_s != NULL) {
facility = SCMapEnumNameToValue(facility_s, SCSyslogGetFacilityMap());
if (facility == -1) {
*/
static char *SCLogGetLogFilename(const char *filearg)
{
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
char *log_filename = SCMalloc(PATH_MAX);
if (unlikely(log_filename == NULL))
return NULL;
do { \
SC_ATOMIC_EXTERN(unsigned int, engine_stage); \
int init_errors_fatal = 0; \
- (void)ConfGetBool("engine.init-failure-fatal", &init_errors_fatal); \
+ (void)SCConfGetBool("engine.init-failure-fatal", &init_errors_fatal); \
if (init_errors_fatal && (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT)) { \
SCLogError(__VA_ARGS__); \
exit(EXIT_FAILURE); \
int LiveBuildDeviceListCustom(const char *runmode, const char *itemname)
{
- ConfNode *base = ConfGetNode(runmode);
- ConfNode *child;
+ SCConfNode *base = SCConfGetNode(runmode);
+ SCConfNode *child;
int i = 0;
if (base == NULL)
return 0;
TAILQ_FOREACH(child, &base->head, next) {
- ConfNode *subchild;
+ SCConfNode *subchild;
TAILQ_FOREACH(subchild, &child->head, next) {
if ((!strcmp(subchild->name, itemname))) {
if (!strcmp(subchild->val, "default"))
}
}
-void EBPFBuildCPUSet(ConfNode *node, char *iface)
+void EBPFBuildCPUSet(SCConfNode *node, char *iface)
{
uint32_t key0 = 0;
int mapfd = EBPFGetMapFDByName(iface, "cpus_count");
void EBPFRegisterExtension(void);
-void EBPFBuildCPUSet(ConfNode *node, char *iface);
+void EBPFBuildCPUSet(SCConfNode *node, char *iface);
int EBPFSetPeerIface(const char *iface, const char *out_iface);
enum ExceptionPolicy policy = EXCEPTION_POLICY_NOT_SET;
const char *value_str = NULL;
- if ((ConfGet(option, &value_str) == 1) && value_str != NULL) {
+ if ((SCConfGet(option, &value_str) == 1) && value_str != NULL) {
if (strcmp(option, "exception-policy") == 0) {
policy = ExceptionPolicyMasterParse(value_str);
} else {
enum ExceptionPolicy policy = EXCEPTION_POLICY_NOT_SET;
const char *value_str = NULL;
/* policy was set directly */
- if ((ConfGet("stream.midstream-policy", &value_str)) == 1 && value_str != NULL) {
+ if ((SCConfGet("stream.midstream-policy", &value_str)) == 1 && value_str != NULL) {
policy = ExceptionPolicyConfigValueParse("midstream-policy", value_str);
if (policy == EXCEPTION_POLICY_AUTO) {
policy = ExceptionPolicyPickAuto(midstream_enabled, true);
/**
* \brief Function to parse forced file hashing configuration.
*/
-void FileForceHashParseCfg(ConfNode *conf)
+void FileForceHashParseCfg(SCConfNode *conf)
{
BUG_ON(conf == NULL);
- ConfNode *forcehash_node = NULL;
+ SCConfNode *forcehash_node = NULL;
/* legacy option */
- const char *force_md5 = ConfNodeLookupChildValue(conf, "force-md5");
+ const char *force_md5 = SCConfNodeLookupChildValue(conf, "force-md5");
if (force_md5 != NULL) {
SCLogWarning("deprecated 'force-md5' option "
"found. Please use 'force-hash: [md5]' instead");
- if (ConfValIsTrue(force_md5)) {
+ if (SCConfValIsTrue(force_md5)) {
if (g_disable_hashing) {
SCLogInfo(
"not forcing md5 calculation for logged files: hashing globally disabled");
}
if (conf != NULL)
- forcehash_node = ConfNodeLookupChild(conf, "force-hash");
+ forcehash_node = SCConfNodeLookupChild(conf, "force-hash");
if (forcehash_node != NULL) {
- ConfNode *field = NULL;
+ SCConfNode *field = NULL;
TAILQ_FOREACH(field, &forcehash_node->head, next) {
if (strcasecmp("md5", field->val) == 0) {
void FileUpdateFlowFileFlags(Flow *f, uint16_t set_file_flags, uint8_t direction);
-void FileForceHashParseCfg(ConfNode *);
+void FileForceHashParseCfg(SCConfNode *);
void FileForceTrackingEnable(void);
*/
void SCHInfoLoadFromConfig(void)
{
- ConfNode *root = ConfGetNode("host-os-policy");
+ SCConfNode *root = SCConfGetNode("host-os-policy");
if (root == NULL)
return;
- ConfNode *policy;
+ SCConfNode *policy;
TAILQ_FOREACH(policy, &root->head, next) {
- ConfNode *host;
+ SCConfNode *host;
TAILQ_FOREACH(host, &policy->head, next) {
int is_ipv4 = 1;
if (host->val != NULL && strchr(host->val, ':') != NULL)
SCHInfoCreateContextBackup();
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
SCHInfoLoadFromConfig();
if (SCHInfoGetHostOSFlavour("10.0.0.4") != OS_POLICY_WINDOWS)
result = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
- SCHInfoRestoreContextBackup();
+ SCHInfoRestoreContextBackup();
- return result;
+ return result;
}
/**
SCHInfoCreateContextBackup();
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
- ConfNode *root = ConfGetNode("host-os-policy");
+ SCConfNode *root = SCConfGetNode("host-os-policy");
if (root == NULL)
goto end;
int count = 0;
- ConfNode *policy;
+ SCConfNode *policy;
TAILQ_FOREACH(policy, &root->head, next) {
switch (count) {
case 0:
result = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
- SCHInfoRestoreContextBackup();
+ SCHInfoRestoreContextBackup();
- return result;
+ return result;
}
/**
SCHInfoCreateContextBackup();
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
- ConfNode *root = ConfGetNode("host-os-policy");
+ SCConfNode *root = SCConfGetNode("host-os-policy");
if (root == NULL)
goto end;
- ConfNode *policy;
+ SCConfNode *policy;
TAILQ_FOREACH(policy, &root->head, next) {
if (SCMapEnumNameToValue(policy->name, sc_hinfo_os_policy_map) == -1) {
printf("Invalid enum map inside\n");
result = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
- SCHInfoRestoreContextBackup();
- return result;
+ SCHInfoRestoreContextBackup();
+ return result;
}
/**
SCHInfoCreateContextBackup();
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
- ConfNode *root = ConfGetNode("host-os-policy");
+ SCConfNode *root = SCConfGetNode("host-os-policy");
if (root == NULL)
goto end;
- ConfNode *policy;
+ SCConfNode *policy;
TAILQ_FOREACH(policy, &root->head, next) {
if (SCMapEnumNameToValue(policy->name, sc_hinfo_os_policy_map) == -1) {
printf("Invalid enum map inside\n");
result = 1;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
- SCHInfoRestoreContextBackup();
- return result;
+ SCHInfoRestoreContextBackup();
+ return result;
}
/**
SCHInfoCreateContextBackup();
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(config, strlen(config));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(config, strlen(config));
SCHInfoLoadFromConfig();
FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.1") != OS_POLICY_BSD_RIGHT);
FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.0") != -1);
FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.6") != -1);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
SCHInfoRestoreContextBackup();
PASS;
}
{
/* Read configuration variable and exit if no enforcement */
int conf_status;
- if (ConfGetBool("security.landlock.enabled", &conf_status) == 0) {
+ if (SCConfGetBool("security.landlock.enabled", &conf_status) == 0) {
conf_status = 0;
}
if (!conf_status) {
return;
}
- LandlockSandboxingWritePath(ruleset, ConfigGetLogDirectory());
+ LandlockSandboxingWritePath(ruleset, SCConfigGetLogDirectory());
struct stat sb;
if (stat(ConfigGetDataDirectory(), &sb) == 0) {
LandlockSandboxingAddRule(ruleset, ConfigGetDataDirectory(),
}
if (suri->run_mode == RUNMODE_PCAP_FILE) {
const char *pcap_file;
- if (ConfGet("pcap-file.file", &pcap_file) == 1) {
+ if (SCConfGet("pcap-file.file", &pcap_file) == 1) {
char *file_name = SCStrdup(pcap_file);
if (file_name != NULL) {
struct stat statbuf;
}
if (ConfUnixSocketIsEnable()) {
const char *socketname;
- if (ConfGet("unix-command.filename", &socketname) == 1) {
+ if (SCConfGet("unix-command.filename", &socketname) == 1) {
if (PathIsAbsolute(socketname)) {
char *file_name = SCStrdup(socketname);
if (file_name != NULL) {
}
if (!suri->sig_file_exclusive) {
const char *rule_path;
- if (ConfGet("default-rule-path", &rule_path) == 1 && rule_path) {
+ if (SCConfGet("default-rule-path", &rule_path) == 1 && rule_path) {
LandlockSandboxingReadPath(ruleset, rule_path);
}
}
- ConfNode *read_dirs = ConfGetNode("security.landlock.directories.read");
+ SCConfNode *read_dirs = SCConfGetNode("security.landlock.directories.read");
if (read_dirs) {
- if (!ConfNodeIsSequence(read_dirs)) {
+ if (!SCConfNodeIsSequence(read_dirs)) {
SCLogWarning("Invalid security.landlock.directories.read configuration section: "
"expected a list of directory names.");
} else {
- ConfNode *directory;
+ SCConfNode *directory;
TAILQ_FOREACH (directory, &read_dirs->head, next) {
LandlockSandboxingReadPath(ruleset, directory->val);
}
}
}
- ConfNode *write_dirs = ConfGetNode("security.landlock.directories.write");
+ SCConfNode *write_dirs = SCConfGetNode("security.landlock.directories.write");
if (write_dirs) {
- if (!ConfNodeIsSequence(write_dirs)) {
+ if (!SCConfNodeIsSequence(write_dirs)) {
SCLogWarning("Invalid security.landlock.directories.write configuration section: "
"expected a list of directory names.");
} else {
- ConfNode *directory;
+ SCConfNode *directory;
TAILQ_FOREACH (directory, &write_dirs->head, next) {
LandlockSandboxingWritePath(ruleset, directory->val);
}
* \param log_ctx Log file context allocated by caller
* \retval 0 on success
*/
-int SCConfLogOpenRedis(ConfNode *redis_node, void *lf_ctx)
+int SCConfLogOpenRedis(SCConfNode *redis_node, void *lf_ctx)
{
LogFileCtx *log_ctx = lf_ctx;
int is_async = 0;
if (redis_node) {
- log_ctx->redis_setup.server = ConfNodeLookupChildValue(redis_node, "server");
- log_ctx->redis_setup.key = ConfNodeLookupChildValue(redis_node, "key");
+ log_ctx->redis_setup.server = SCConfNodeLookupChildValue(redis_node, "server");
+ log_ctx->redis_setup.key = SCConfNodeLookupChildValue(redis_node, "key");
- redis_port = ConfNodeLookupChildValue(redis_node, "port");
- redis_mode = ConfNodeLookupChildValue(redis_node, "mode");
+ redis_port = SCConfNodeLookupChildValue(redis_node, "port");
+ redis_mode = SCConfNodeLookupChildValue(redis_node, "mode");
- (void)ConfGetChildValueBool(redis_node, "async", &is_async);
+ (void)SCConfGetChildValueBool(redis_node, "async", &is_async);
}
if (!log_ctx->redis_setup.server) {
log_ctx->redis_setup.server = redis_default_server;
log_ctx->redis_setup.is_async = is_async;
log_ctx->redis_setup.batch_size = 0;
if (redis_node) {
- ConfNode *pipelining = ConfNodeLookupChild(redis_node, "pipelining");
+ SCConfNode *pipelining = SCConfNodeLookupChild(redis_node, "pipelining");
if (pipelining) {
int enabled = 0;
int ret;
intmax_t val;
- ret = ConfGetChildValueBool(pipelining, "enabled", &enabled);
+ ret = SCConfGetChildValueBool(pipelining, "enabled", &enabled);
if (ret && enabled) {
- ret = ConfGetChildValueInt(pipelining, "batch-size", &val);
+ ret = SCConfGetChildValueInt(pipelining, "batch-size", &val);
if (ret) {
log_ctx->redis_setup.batch_size = val;
} else {
intmax_t maxlen;
log_ctx->redis_setup.command = redis_xadd_cmd;
log_ctx->redis_setup.format = redis_stream_format;
- if (ConfGetChildValueBool(redis_node, "stream-trim-exact", &exact) == 0) {
+ if (SCConfGetChildValueBool(redis_node, "stream-trim-exact", &exact) == 0) {
exact = 0;
}
- if (ConfGetChildValueInt(redis_node, "stream-maxlen", &maxlen) == 0) {
+ if (SCConfGetChildValueInt(redis_node, "stream-maxlen", &maxlen) == 0) {
maxlen = REDIS_MAX_STREAM_LENGTH_DEFAULT;
}
if (maxlen > 0) {
} SCLogRedisContext;
void SCLogRedisInit(void);
-int SCConfLogOpenRedis(ConfNode *, void *);
+int SCConfLogOpenRedis(SCConfNode *, void *);
int LogFileWriteRedis(void *, const char *, size_t);
#endif /* HAVE_LIBHIREDIS */
return NULL;
}
- if (ConfValIsTrue(append_setting)) {
+ if (SCConfValIsTrue(append_setting)) {
ret = fopen(filename, "a");
} else {
ret = fopen(filename, "w");
* \retval 0 on success
* \retval -1 on error
*/
-int
-SCConfLogOpenGeneric(ConfNode *conf,
- LogFileCtx *log_ctx,
- const char *default_filename,
- int rotate)
+int SCConfLogOpenGeneric(
+ SCConfNode *conf, LogFileCtx *log_ctx, const char *default_filename, int rotate)
{
char log_path[PATH_MAX];
const char *log_dir;
}
// Resolve the given config
- filename = ConfNodeLookupChildValue(conf, "filename");
+ filename = SCConfNodeLookupChildValue(conf, "filename");
if (filename == NULL)
filename = default_filename;
- log_dir = ConfigGetLogDirectory();
+ log_dir = SCConfigGetLogDirectory();
if (PathIsAbsolute(filename)) {
snprintf(log_path, PATH_MAX, "%s", filename);
}
/* Rotate log file based on time */
- const char *rotate_int = ConfNodeLookupChildValue(conf, "rotate-interval");
+ const char *rotate_int = SCConfNodeLookupChildValue(conf, "rotate-interval");
if (rotate_int != NULL) {
time_t now = time(NULL);
log_ctx->flags |= LOGFILE_ROTATE_INTERVAL;
}
}
- filetype = ConfNodeLookupChildValue(conf, "filetype");
+ filetype = SCConfNodeLookupChildValue(conf, "filetype");
if (filetype == NULL)
filetype = DEFAULT_LOG_FILETYPE;
* The default value is 0 (no buffering)
*/
uint32_t buffer_size = LOGFILE_EVE_BUFFER_SIZE;
- const char *buffer_size_value = ConfNodeLookupChildValue(conf, "buffer-size");
+ const char *buffer_size_value = SCConfNodeLookupChildValue(conf, "buffer-size");
if (buffer_size_value != NULL) {
uint32_t value;
if (ParseSizeStringU32(buffer_size_value, &value) < 0) {
}
SCLogDebug("buffering: %s -> %d", buffer_size_value, buffer_size);
- const char *filemode = ConfNodeLookupChildValue(conf, "filemode");
+ const char *filemode = SCConfNodeLookupChildValue(conf, "filemode");
uint32_t mode = 0;
if (filemode != NULL && StringParseUint32(&mode, 8, (uint16_t)strlen(filemode), filemode) > 0) {
log_ctx->filemode = mode;
}
- const char *append = ConfNodeLookupChildValue(conf, "append");
+ const char *append = SCConfNodeLookupChildValue(conf, "append");
if (append == NULL)
append = DEFAULT_LOG_MODE_APPEND;
log_ctx->json_flags = JSON_PRESERVE_ORDER|JSON_COMPACT|
JSON_ENSURE_ASCII|JSON_ESCAPE_SLASH;
- ConfNode *json_flags = ConfNodeLookupChild(conf, "json");
+ SCConfNode *json_flags = SCConfNodeLookupChild(conf, "json");
if (json_flags != 0) {
- const char *preserve_order = ConfNodeLookupChildValue(json_flags,
- "preserve-order");
- if (preserve_order != NULL && ConfValIsFalse(preserve_order))
+ const char *preserve_order = SCConfNodeLookupChildValue(json_flags, "preserve-order");
+ if (preserve_order != NULL && SCConfValIsFalse(preserve_order))
log_ctx->json_flags &= ~(JSON_PRESERVE_ORDER);
- const char *compact = ConfNodeLookupChildValue(json_flags, "compact");
- if (compact != NULL && ConfValIsFalse(compact))
+ const char *compact = SCConfNodeLookupChildValue(json_flags, "compact");
+ if (compact != NULL && SCConfValIsFalse(compact))
log_ctx->json_flags &= ~(JSON_COMPACT);
- const char *ensure_ascii = ConfNodeLookupChildValue(json_flags,
- "ensure-ascii");
- if (ensure_ascii != NULL && ConfValIsFalse(ensure_ascii))
+ const char *ensure_ascii = SCConfNodeLookupChildValue(json_flags, "ensure-ascii");
+ if (ensure_ascii != NULL && SCConfValIsFalse(ensure_ascii))
log_ctx->json_flags &= ~(JSON_ENSURE_ASCII);
- const char *escape_slash = ConfNodeLookupChildValue(json_flags,
- "escape-slash");
- if (escape_slash != NULL && ConfValIsFalse(escape_slash))
+ const char *escape_slash = SCConfNodeLookupChildValue(json_flags, "escape-slash");
+ if (escape_slash != NULL && SCConfValIsFalse(escape_slash))
log_ctx->json_flags &= ~(JSON_ESCAPE_SLASH);
}
void LogFileFlush(LogFileCtx *file_ctx);
LogFileCtx *LogFileEnsureExists(ThreadId thread_id, LogFileCtx *lf_ctx);
-int SCConfLogOpenGeneric(ConfNode *conf, LogFileCtx *, const char *, int);
+int SCConfLogOpenGeneric(SCConfNode *conf, LogFileCtx *, const char *, int);
int SCConfLogReopen(LogFileCtx *);
bool SCLogOpenThreadedFile(const char *log_path, const char *append, LogFileCtx *parent_ctx);
static int LuaCallbackLogPath(lua_State *luastate)
{
- const char *ld = ConfigGetLogDirectory();
+ const char *ld = SCConfigGetLogDirectory();
if (ld == NULL)
return LuaCallbackError(luastate, "internal error: no log dir");
void MacSetRegisterFlowStorage(void)
{
- ConfNode *root = ConfGetNode("outputs");
- ConfNode *node = NULL;
+ SCConfNode *root = SCConfGetNode("outputs");
+ SCConfNode *node = NULL;
/* we only need to register if at least one enabled 'eve-log' output
has the ethernet setting enabled */
if (root != NULL) {
TAILQ_FOREACH(node, &root->head, next) {
if (node->val && strcmp(node->val, "eve-log") == 0) {
- const char *enabled = ConfNodeLookupChildValue(node->head.tqh_first, "enabled");
- if (enabled != NULL && ConfValIsTrue(enabled)) {
- const char *ethernet = ConfNodeLookupChildValue(node->head.tqh_first, "ethernet");
- if (ethernet != NULL && ConfValIsTrue(ethernet)) {
+ const char *enabled = SCConfNodeLookupChildValue(node->head.tqh_first, "enabled");
+ if (enabled != NULL && SCConfValIsTrue(enabled)) {
+ const char *ethernet =
+ SCConfNodeLookupChildValue(node->head.tqh_first, "ethernet");
+ if (ethernet != NULL && SCConfValIsTrue(ethernet)) {
g_macset_storage_id = FlowStorageRegister("macset", sizeof(void *),
NULL, (void(*)(void *)) MacSetFree);
return;
goto error;
}
- (void)ConfGet("magic-file", &filename);
-
+ (void)SCConfGet("magic-file", &filename);
if (filename != NULL) {
if (strlen(filename) == 0) {
*/
static void SCACGetConfig(void)
{
- //ConfNode *ac_conf;
- //const char *hash_val = NULL;
+ // SCConfNode *ac_conf;
+ // const char *hash_val = NULL;
- // ConfNode *pm = ConfGetNode("pattern-matcher");
+ // SCConfNode *pm = SCConfGetNode("pattern-matcher");
}
/**
void SCPluginsLoad(const char *capture_plugin_name, const char *capture_plugin_args)
{
- ConfNode *conf = ConfGetNode("plugins");
+ SCConfNode *conf = SCConfGetNode("plugins");
if (conf == NULL) {
return;
}
- ConfNode *plugin = NULL;
+ SCConfNode *plugin = NULL;
TAILQ_FOREACH(plugin, &conf->head, next) {
struct stat statbuf;
if (stat(plugin->val, &statbuf) == -1) {
void SCProfilingKeywordsGlobalInit(void)
{
- ConfNode *conf;
+ SCConfNode *conf;
- conf = ConfGetNode("profiling.keywords");
+ conf = SCConfGetNode("profiling.keywords");
if (conf != NULL) {
- if (ConfNodeChildValueIsTrue(conf, "enabled")) {
+ if (SCConfNodeChildValueIsTrue(conf, "enabled")) {
profiling_keyword_enabled = 1;
- const char *filename = ConfNodeLookupChildValue(conf, "filename");
+ const char *filename = SCConfNodeLookupChildValue(conf, "filename");
if (filename != NULL) {
if (PathIsAbsolute(filename)) {
strlcpy(profiling_file_name, filename, sizeof(profiling_file_name));
} else {
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
snprintf(profiling_file_name, sizeof(profiling_file_name), "%s/%s", log_dir,
filename);
}
- const char *v = ConfNodeLookupChildValue(conf, "append");
- if (v == NULL || ConfValIsTrue(v)) {
+ const char *v = SCConfNodeLookupChildValue(conf, "append");
+ if (v == NULL || SCConfValIsTrue(v)) {
profiling_file_mode = "a";
} else {
profiling_file_mode = "w";
void SCProfilingPrefilterGlobalInit(void)
{
- ConfNode *conf;
+ SCConfNode *conf;
- conf = ConfGetNode("profiling.prefilter");
+ conf = SCConfGetNode("profiling.prefilter");
if (conf != NULL) {
- if (ConfNodeChildValueIsTrue(conf, "enabled")) {
+ if (SCConfNodeChildValueIsTrue(conf, "enabled")) {
profiling_prefilter_enabled = 1;
- const char *filename = ConfNodeLookupChildValue(conf, "filename");
+ const char *filename = SCConfNodeLookupChildValue(conf, "filename");
if (filename != NULL) {
if (PathIsAbsolute(filename)) {
strlcpy(profiling_file_name, filename, sizeof(profiling_file_name));
} else {
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
snprintf(profiling_file_name, sizeof(profiling_file_name), "%s/%s", log_dir,
filename);
}
- const char *v = ConfNodeLookupChildValue(conf, "append");
- if (v == NULL || ConfValIsTrue(v)) {
+ const char *v = SCConfNodeLookupChildValue(conf, "append");
+ if (v == NULL || SCConfValIsTrue(v)) {
profiling_file_mode = "a";
} else {
profiling_file_mode = "w";
void SCProfilingSghsGlobalInit(void)
{
- ConfNode *conf;
+ SCConfNode *conf;
- conf = ConfGetNode("profiling.rulegroups");
+ conf = SCConfGetNode("profiling.rulegroups");
if (conf != NULL) {
- if (ConfNodeChildValueIsTrue(conf, "enabled")) {
+ if (SCConfNodeChildValueIsTrue(conf, "enabled")) {
profiling_sghs_enabled = 1;
- const char *filename = ConfNodeLookupChildValue(conf, "filename");
+ const char *filename = SCConfNodeLookupChildValue(conf, "filename");
if (filename != NULL) {
if (PathIsAbsolute(filename)) {
strlcpy(profiling_file_name, filename, sizeof(profiling_file_name));
} else {
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
snprintf(profiling_file_name, sizeof(profiling_file_name), "%s/%s", log_dir,
filename);
}
- const char *v = ConfNodeLookupChildValue(conf, "append");
- if (v == NULL || ConfValIsTrue(v)) {
+ const char *v = SCConfNodeLookupChildValue(conf, "append");
+ if (v == NULL || SCConfValIsTrue(v)) {
profiling_file_mode = "a";
} else {
profiling_file_mode = "w";
profiling_sghs_output_to_file = 1;
}
- if (ConfNodeChildValueIsTrue(conf, "json")) {
+ if (SCConfNodeChildValueIsTrue(conf, "json")) {
profiling_rulegroup_json = 1;
}
}
profiling_rules_sort_orders[1] = -1; \
}
- ConfNode *conf;
+ SCConfNode *conf;
const char *val;
- conf = ConfGetNode("profiling.rules");
+ conf = SCConfGetNode("profiling.rules");
if (conf != NULL) {
- if (ConfNodeChildValueIsTrue(conf, "enabled")) {
+ if (SCConfNodeChildValueIsTrue(conf, "enabled")) {
profiling_rules_enabled = 1;
- val = ConfNodeLookupChildValue(conf, "sort");
+ val = SCConfNodeLookupChildValue(conf, "sort");
if (val != NULL) {
if (strcmp(val, "ticks") == 0) {
SET_ONE(SC_PROFILING_RULES_SORT_BY_TICKS);
}
}
- val = ConfNodeLookupChildValue(conf, "limit");
+ val = SCConfNodeLookupChildValue(conf, "limit");
if (val != NULL) {
if (StringParseUint32(&profiling_rules_limit, 10,
(uint16_t)strlen(val), val) <= 0) {
exit(EXIT_FAILURE);
}
}
- const char *filename = ConfNodeLookupChildValue(conf, "filename");
+ const char *filename = SCConfNodeLookupChildValue(conf, "filename");
if (filename != NULL) {
if (PathIsAbsolute(filename)) {
strlcpy(profiling_file_name, filename, sizeof(profiling_file_name));
} else {
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
snprintf(profiling_file_name, sizeof(profiling_file_name), "%s/%s", log_dir,
filename);
}
- const char *v = ConfNodeLookupChildValue(conf, "append");
- if (v == NULL || ConfValIsTrue(v)) {
+ const char *v = SCConfNodeLookupChildValue(conf, "append");
+ if (v == NULL || SCConfValIsTrue(v)) {
profiling_file_mode = "a";
} else {
profiling_file_mode = "w";
profiling_output_to_file = 1;
}
- if (ConfNodeChildValueIsTrue(conf, "json")) {
+ if (SCConfNodeChildValueIsTrue(conf, "json")) {
profiling_rule_json = 1;
}
}
void
SCProfilingInit(void)
{
- ConfNode *conf;
+ SCConfNode *conf;
SC_ATOMIC_INIT(samples);
intmax_t rate_v = 0;
- (void)ConfGetInt("profiling.sample-rate", &rate_v);
+ (void)SCConfGetInt("profiling.sample-rate", &rate_v);
if (rate_v > 0 && rate_v < INT_MAX) {
rate = (int)rate_v;
if (rate != 1)
SCLogInfo("profiling runs for every packet");
}
- conf = ConfGetNode("profiling.packets");
+ conf = SCConfGetNode("profiling.packets");
if (conf != NULL) {
- if (ConfNodeChildValueIsTrue(conf, "enabled")) {
+ if (SCConfNodeChildValueIsTrue(conf, "enabled")) {
profiling_packets_enabled = 1;
if (pthread_mutex_init(&packet_profile_lock, NULL) != 0) {
memset(&packet_profile_log_data6, 0, sizeof(packet_profile_log_data6));
memset(&packet_profile_flowworker_data, 0, sizeof(packet_profile_flowworker_data));
- const char *filename = ConfNodeLookupChildValue(conf, "filename");
+ const char *filename = SCConfNodeLookupChildValue(conf, "filename");
if (filename != NULL) {
if (PathIsAbsolute(filename)) {
strlcpy(profiling_packets_file_name, filename,
sizeof(profiling_packets_file_name));
} else {
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
snprintf(profiling_packets_file_name, sizeof(profiling_packets_file_name),
"%s/%s", log_dir, filename);
}
- const char *v = ConfNodeLookupChildValue(conf, "append");
- if (v == NULL || ConfValIsTrue(v)) {
+ const char *v = SCConfNodeLookupChildValue(conf, "append");
+ if (v == NULL || SCConfValIsTrue(v)) {
profiling_packets_file_mode = "a";
} else {
profiling_packets_file_mode = "w";
}
}
- conf = ConfGetNode("profiling.packets.csv");
+ conf = SCConfGetNode("profiling.packets.csv");
if (conf != NULL) {
- if (ConfNodeChildValueIsTrue(conf, "enabled")) {
- const char *filename = ConfNodeLookupChildValue(conf, "filename");
+ if (SCConfNodeChildValueIsTrue(conf, "enabled")) {
+ const char *filename = SCConfNodeLookupChildValue(conf, "filename");
if (filename == NULL) {
filename = "packet_profile.csv";
}
FatalError("out of memory");
}
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
snprintf(profiling_csv_file_name, PATH_MAX, "%s/%s", log_dir, filename);
}
}
}
- conf = ConfGetNode("profiling.locks");
+ conf = SCConfGetNode("profiling.locks");
if (conf != NULL) {
- if (ConfNodeChildValueIsTrue(conf, "enabled")) {
+ if (SCConfNodeChildValueIsTrue(conf, "enabled")) {
#ifndef PROFILE_LOCKING
SCLogWarning(
"lock profiling not compiled in. Add --enable-profiling-locks to configure.");
LockRecordInitHash();
- const char *filename = ConfNodeLookupChildValue(conf, "filename");
+ const char *filename = SCConfNodeLookupChildValue(conf, "filename");
if (filename != NULL) {
- const char *log_dir = ConfigGetLogDirectory();
+ const char *log_dir = SCConfigGetLogDirectory();
profiling_locks_file_name = SCMalloc(PATH_MAX);
if (unlikely(profiling_locks_file_name == NULL)) {
snprintf(profiling_locks_file_name, PATH_MAX, "%s/%s", log_dir, filename);
- const char *v = ConfNodeLookupChildValue(conf, "append");
- if (v == NULL || ConfValIsTrue(v)) {
+ const char *v = SCConfNodeLookupChildValue(conf, "append");
+ if (v == NULL || SCConfValIsTrue(v)) {
profiling_locks_file_mode = "a";
} else {
profiling_locks_file_mode = "w";
SC_ATOMIC_INIT(profiling_rules_active);
SC_ATOMIC_INIT(samples);
intmax_t rate_v = 0;
- ConfNode *conf;
+ SCConfNode *conf;
- (void)ConfGetInt("profiling.sample-rate", &rate_v);
+ (void)SCConfGetInt("profiling.sample-rate", &rate_v);
if (rate_v > 0 && rate_v < INT_MAX) {
int literal_rate = (int)rate_v;
for (int i = literal_rate; i >= 1; i--) {
SCLogInfo("profiling runs for every packet");
}
- conf = ConfGetNode("profiling.rules");
- if (ConfNodeChildValueIsTrue(conf, "active")) {
+ conf = SCConfGetNode("profiling.rules");
+ if (SCConfNodeChildValueIsTrue(conf, "active")) {
SC_ATOMIC_SET(profiling_rules_active, 1);
}
}
/* used to get the reference.config file path */
static const char *SCRConfGetConfFilename(const DetectEngineCtx *de_ctx);
-void SCReferenceConfInit(DetectEngineCtx *de_ctx)
+void SCReferenceSCConfInit(DetectEngineCtx *de_ctx)
{
int en;
PCRE2_SIZE eo;
/* try loading prefix setting, fall back to global if that
* fails. */
- if (ConfGet(config_value, &path) != 1) {
- if (ConfGet("reference-config-file", &path) != 1) {
+ if (SCConfGet(config_value, &path) != 1) {
+ if (SCConfGet("reference-config-file", &path) != 1) {
return (char *)SC_RCONF_DEFAULT_FILE_PATH;
}
}
} else {
- if (ConfGet("reference-config-file", &path) != 1) {
+ if (SCConfGet("reference-config-file", &path) != 1) {
return (char *)SC_RCONF_DEFAULT_FILE_PATH;
}
}
FILE *SCRConfGenerateInvalidDummyReferenceConfigFD02(void);
FILE *SCRConfGenerateInvalidDummyReferenceConfigFD03(void);
-void SCReferenceConfInit(DetectEngineCtx *de_ctx);
+void SCReferenceSCConfInit(DetectEngineCtx *de_ctx);
void SCReferenceConfDeinit(DetectEngineCtx *de_ctx);
#endif /* SURICATA_UTIL_REFERENCE_CONFIG_H */
}
}
- if (ConfGet(conf_var_full_name, &conf_var_full_name_value) != 1) {
+ if (SCConfGet(conf_var_full_name, &conf_var_full_name_value) != 1) {
SCLogError("Variable \"%s\" is not defined in "
"configuration file",
conf_var_name);
*/
static int SCRuleVarsPositiveTest01(void)
{
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
/* check for address-groups */
FAIL_IF_NOT(SCRuleVarsGetConfVar(NULL, "$HOME_NET", SC_RULE_VARS_ADDRESS_GROUPS) != NULL &&
SCRuleVarsGetConfVar(NULL, "$SSH_PORTS", SC_RULE_VARS_PORT_GROUPS) != NULL &&
strcmp(SCRuleVarsGetConfVar(NULL, "$SSH_PORTS", SC_RULE_VARS_PORT_GROUPS), "22") == 0);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
*/
static int SCRuleVarsNegativeTest02(void)
{
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
FAIL_IF_NOT(SCRuleVarsGetConfVar(NULL, "$HOME_NETW", SC_RULE_VARS_ADDRESS_GROUPS) == NULL);
FAIL_IF_NOT(SCRuleVarsGetConfVar(NULL, "$home_net", SC_RULE_VARS_ADDRESS_GROUPS) == NULL);
FAIL_IF_NOT(SCRuleVarsGetConfVar(NULL, "$TOMCAT_PORTSW", SC_RULE_VARS_PORT_GROUPS) == NULL);
FAIL_IF_NOT(SCRuleVarsGetConfVar(NULL, "$tomcat_ports", SC_RULE_VARS_PORT_GROUPS) == NULL);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
*/
static int SCRuleVarsPositiveTest03(void)
{
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
FAIL_IF_NULL(de_ctx);
"[80,[!$HTTP_PORTS,$ORACLE_PORTS]] (msg:\"Rule Vars Test\"; sid:1;)");
FAIL_IF_NULL(s);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
DetectEngineCtxFree(de_ctx);
PASS;
}
*/
static int SCRuleVarsNegativeTest04(void)
{
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_conf_string, strlen(dummy_conf_string));
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
FAIL_IF_NULL(de_ctx);
de_ctx->flags |= DE_QUIET;
FAIL_IF_NOT_NULL(s);
DetectEngineCtxFree(de_ctx);
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
PASS;
}
int result = 0;
DetectEngineCtx *de_ctx = NULL;
- ConfCreateContextBackup();
- ConfInit();
- ConfYamlLoadString(dummy_mt_conf_string, strlen(dummy_mt_conf_string));
+ SCConfCreateContextBackup();
+ SCConfInit();
+ SCConfYamlLoadString(dummy_mt_conf_string, strlen(dummy_mt_conf_string));
if ( (de_ctx = DetectEngineCtxInit()) == NULL)
return 0;
goto end;
end:
- ConfDeInit();
- ConfRestoreContextBackup();
+ SCConfDeInit();
+ SCConfRestoreContextBackup();
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
int ListAppLayerProtocols(const char *conf_filename)
{
EngineModeSetIDS();
- if (ConfYamlLoadFile(conf_filename) != -1)
+ if (SCConfYamlLoadFile(conf_filename) != -1)
SCLogLoadConfig(0, 0, 0, 0);
MpmTableSetup();
SpmTableSetup();
uint8_t SinglePatternMatchDefaultMatcher(void)
{
const char *spm_algo;
- if ((ConfGet("spm-algo", &spm_algo)) == 1) {
+ if ((SCConfGet("spm-algo", &spm_algo)) == 1) {
if (spm_algo != NULL) {
if (strcmp("auto", spm_algo) == 0) {
goto default_matcher;
static int StreamingBufferTest12(void)
{
- ConfCreateContextBackup();
- ConfInit();
+ SCConfCreateContextBackup();
+ SCConfInit();
HtpConfigCreateBackup();
- ConfYamlLoadString((const char *)dummy_conf_string, strlen(dummy_conf_string));
+ SCConfYamlLoadString((const char *)dummy_conf_string, strlen(dummy_conf_string));
HTPConfigure();
StreamingBufferConfig cfg = { 8, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT, HTPCalloc, HTPRealloc,
StreamingBufferFree(sb, &cfg);
HtpConfigRestoreBackup();
- ConfRestoreContextBackup();
+ SCConfRestoreContextBackup();
PASS;
}
/** set config values for memcap, prealloc and hash_size */
GET_VAR(cnf_prefix, "memcap");
- if ((ConfGet(varname, &conf_val)) == 1)
- {
+ if ((SCConfGet(varname, &conf_val)) == 1) {
uint64_t memcap;
if (ParseSizeStringU64(conf_val, &memcap) < 0) {
SCLogError("Error parsing %s "
SC_ATOMIC_SET(ctx->config.memcap, memcap);
}
GET_VAR(cnf_prefix, "hash-size");
- if ((ConfGet(varname, &conf_val)) == 1)
- {
+ if ((SCConfGet(varname, &conf_val)) == 1) {
if (StringParseUint32(&configval, 10, (uint16_t)strlen(conf_val), conf_val) > 0) {
ctx->config.hash_size = configval;
}
}
GET_VAR(cnf_prefix, "prealloc");
- if ((ConfGet(varname, &conf_val)) == 1)
- {
+ if ((SCConfGet(varname, &conf_val)) == 1) {
if (StringParseUint32(&configval, 10, (uint16_t)strlen(conf_val), conf_val) > 0) {
ctx->config.prealloc = configval;
} else {
/* try loading prefix setting, fall back to global if that
* fails. */
- if (ConfGet(config_value, &log_filename) != 1) {
- if (ConfGet("threshold-file", &log_filename) != 1) {
+ if (SCConfGet(config_value, &log_filename) != 1) {
+ if (SCConfGet("threshold-file", &log_filename) != 1) {
log_filename = (char *)THRESHOLD_CONF_DEF_CONF_FILEPATH;
}
}
} else {
- if (ConfGet("threshold-file", &log_filename) != 1) {
+ if (SCConfGet("threshold-file", &log_filename) != 1) {
log_filename = (char *)THRESHOLD_CONF_DEF_CONF_FILEPATH;
}
}