From: Jason Ish Date: Tue, 1 Apr 2025 16:04:19 +0000 (-0600) Subject: conf: prefix conf API with SC X-Git-Tag: suricata-8.0.0-beta1~118 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22b77b0c5637034b76fc2df367370557e2f6bf85;p=thirdparty%2Fsuricata.git conf: prefix conf API with SC --- diff --git a/doc/userguide/devguide/codebase/code-style.rst b/doc/userguide/devguide/codebase/code-style.rst index 1d1d00917e..fd6d24a220 100644 --- a/doc/userguide/devguide/codebase/code-style.rst +++ b/doc/userguide/devguide/codebase/code-style.rst @@ -437,7 +437,7 @@ Function names are NamedLikeThis(). .. code-block:: c - static ConfNode *ConfGetNodeOrCreate(char *name, int final) + static SCConfNode *SCConfGetNodeOrCreate(char *name, int final) static vs non-static ^^^^^^^^^^^^^^^^^^^^ @@ -459,7 +459,7 @@ A variable is ``named_like_this`` in all lowercase. .. code-block:: c - ConfNode *parent_node = root; + SCConfNode *parent_node = root; Generally, use descriptive variable names. @@ -527,7 +527,7 @@ We use Doxygen, functions are documented using Doxygen notation: * \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 ^^^^^^^^^^^^^^^^ diff --git a/doc/userguide/devguide/codebase/unittests-c.rst b/doc/userguide/devguide/codebase/unittests-c.rst index fd63072317..f7f92b5a88 100644 --- a/doc/userguide/devguide/codebase/unittests-c.rst +++ b/doc/userguide/devguide/codebase/unittests-c.rst @@ -99,20 +99,20 @@ From ``conf-yaml-loader.c``: ; 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; } diff --git a/examples/lib/custom/main.c b/examples/lib/custom/main.c index 088b489d79..3237777fd7 100644 --- a/examples/lib/custom/main.c +++ b/examples/lib/custom/main.c @@ -193,12 +193,12 @@ int main(int argc, char **argv) } /* 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"); diff --git a/examples/plugins/c-json-filetype/filetype.c b/examples/plugins/c-json-filetype/filetype.c index ad60b2e59b..ed8b42c6f1 100644 --- a/examples/plugins/c-json-filetype/filetype.c +++ b/examples/plugins/c-json-filetype/filetype.c @@ -64,7 +64,7 @@ typedef struct Context_ { * 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)); @@ -77,8 +77,8 @@ static int FiletypeInit(const ConfNode *conf, const bool threaded, void **data) /* 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); diff --git a/plugins/napatech/runmode-napatech.c b/plugins/napatech/runmode-napatech.c index 1deaee328d..ef08272d82 100644 --- a/plugins/napatech/runmode-napatech.c +++ b/plugins/napatech/runmode-napatech.c @@ -96,16 +96,16 @@ static int NapatechRegisterDeviceStreams(void) /* 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."); } diff --git a/plugins/napatech/source-napatech.c b/plugins/napatech/source-napatech.c index 3b1d8d728a..ac66aa0b85 100644 --- a/plugins/napatech/source-napatech.c +++ b/plugins/napatech/source-napatech.c @@ -721,7 +721,7 @@ static void RecommendNUMAConfig(void) 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; } @@ -774,7 +774,7 @@ TmEcode NapatechPacketLoop(ThreadVars *tv, void *data, void *slot) } #endif - if (ConfGetBool("napatech.auto-config", &is_autoconfig) == 0) { + if (SCConfGetBool("napatech.auto-config", &is_autoconfig) == 0) { is_autoconfig = 0; } @@ -785,7 +785,7 @@ TmEcode NapatechPacketLoop(ThreadVars *tv, void *data, void *slot) 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; } @@ -800,7 +800,7 @@ TmEcode NapatechPacketLoop(ThreadVars *tv, void *data, void *slot) RecommendNUMAConfig(); #ifdef NAPATECH_ENABLE_BYPASS - if (ConfGetBool("napatech.inline", &is_inline) == 0) { + if (SCConfGetBool("napatech.inline", &is_inline) == 0) { is_inline = 0; } diff --git a/plugins/napatech/util-napatech.c b/plugins/napatech/util-napatech.c index d9d2464133..942bba2b71 100644 --- a/plugins/napatech/util-napatech.c +++ b/plugins/napatech/util-napatech.c @@ -480,11 +480,11 @@ static void *NapatechStatsLoop(void *arg) 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; } @@ -710,8 +710,8 @@ static uint32_t CountWorkerThreads(void) { int worker_count = 0; - ConfNode *affinity; - ConfNode *root = ConfGetNode("threading.cpu-affinity"); + SCConfNode *affinity; + SCConfNode *root = SCConfGetNode("threading.cpu-affinity"); if (root != NULL) { @@ -724,8 +724,8 @@ static uint32_t CountWorkerThreads(void) } 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; @@ -800,7 +800,7 @@ int NapatechGetStreamConfig(NapatechStreamConfig stream_config[]) 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; @@ -811,7 +811,7 @@ int NapatechGetStreamConfig(NapatechStreamConfig stream_config[]) 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; } @@ -866,14 +866,14 @@ int NapatechGetStreamConfig(NapatechStreamConfig stream_config[]) } } 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 " @@ -883,7 +883,7 @@ int NapatechGetStreamConfig(NapatechStreamConfig stream_config[]) } /* 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; @@ -1246,7 +1246,7 @@ static uint32_t NapatechSetHashmode(void) 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); @@ -1358,7 +1358,7 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream) ports_spec.all = false; - ConfNode *ntports; + SCConfNode *ntports; int iteration = 0; int status = 0; NtConfigStream_t hconfig; @@ -1371,7 +1371,7 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream) 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; } @@ -1414,12 +1414,12 @@ uint32_t NapatechSetupTraffic(uint32_t first_stream, uint32_t last_stream) /* 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()) { diff --git a/plugins/pfring/runmode-pfring.c b/plugins/pfring/runmode-pfring.c index cf64c1be4e..40a546e4d4 100644 --- a/plugins/pfring/runmode-pfring.c +++ b/plugins/pfring/runmode-pfring.c @@ -111,7 +111,7 @@ static void *OldParsePfringConfig(const char *iface) (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) { @@ -134,7 +134,7 @@ static void *OldParsePfringConfig(const char *iface) 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) { @@ -152,7 +152,7 @@ static void *OldParsePfringConfig(const char *iface) } 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); @@ -185,9 +185,9 @@ static void *OldParsePfringConfig(const char *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; @@ -215,7 +215,7 @@ static void *ParsePfringConfig(const char *iface) (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; @@ -241,7 +241,7 @@ static void *ParsePfringConfig(const char *iface) 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) { @@ -275,7 +275,7 @@ static void *ParsePfringConfig(const char *iface) (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.", @@ -292,7 +292,7 @@ static void *ParsePfringConfig(const char *iface) } 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 { @@ -313,7 +313,7 @@ static void *ParsePfringConfig(const char *iface) 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 { @@ -323,7 +323,7 @@ static void *ParsePfringConfig(const char *iface) } 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 { @@ -358,12 +358,12 @@ static void *ParsePfringConfig(const char *iface) 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; @@ -372,7 +372,7 @@ static void *ParsePfringConfig(const char *iface) } } - 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)", @@ -406,7 +406,7 @@ static int PfringConfLevel(void) { 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; @@ -415,7 +415,7 @@ static int PfringConfLevel(void) 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) { @@ -425,7 +425,7 @@ static int GetDevAndParser(const char **live_dev, ConfigIfaceParserFunc *parser) *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 { diff --git a/rust/src/conf.rs b/rust/src/conf.rs index 50cc072570..9355f5ee98 100644 --- a/rust/src/conf.rs +++ b/rust/src/conf.rs @@ -33,12 +33,12 @@ use nom7::{ /// 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 { @@ -48,7 +48,7 @@ pub fn conf_get_node(key: &str) -> Option { return None; }; - let node = unsafe { ConfGetNode(key.as_ptr()) }; + let node = unsafe { SCConfGetNode(key.as_ptr()) }; if node.is_null() { None } else { @@ -62,7 +62,7 @@ pub fn conf_get(key: &str) -> Option<&str> { 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; } @@ -106,7 +106,7 @@ impl ConfNode { unsafe { let s = CString::new(key).unwrap(); - if ConfGetChildValue(self.conf, + if SCConfGetChildValue(self.conf, s.as_ptr(), &mut vptr) != 1 { return None; @@ -129,7 +129,7 @@ impl ConfNode { unsafe { let s = CString::new(key).unwrap(); - if ConfGetChildValueBool(self.conf, + if SCConfGetChildValueBool(self.conf, s.as_ptr(), &mut vptr) != 1 { return false; diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index 95d29b2c65..f04aad78af 100644 --- a/src/alert-debuglog.c +++ b/src/alert-debuglog.c @@ -425,11 +425,11 @@ static void AlertDebugLogDeInitCtx(OutputCtx *output_ctx) /** * \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; diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index 8ced31debd..75854900ba 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -231,7 +231,7 @@ TmEcode AlertFastLogThreadDeinit(ThreadVars *t, void *data) * \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(); diff --git a/src/alert-fastlog.h b/src/alert-fastlog.h index acae191972..c997395826 100644 --- a/src/alert-fastlog.h +++ b/src/alert-fastlog.h @@ -25,6 +25,6 @@ #define SURICATA_ALERT_FASTLOG_H void AlertFastLogRegister(void); -OutputInitResult AlertFastLogInitCtx(ConfNode *); +OutputInitResult AlertFastLogInitCtx(SCConfNode *); #endif /* SURICATA_ALERT_FASTLOG_H */ diff --git a/src/alert-syslog.c b/src/alert-syslog.c index f22f650105..7beaaa1be7 100644 --- a/src/alert-syslog.c +++ b/src/alert-syslog.c @@ -85,12 +85,12 @@ static void AlertSyslogDeInitCtx(OutputCtx *output_ctx) * \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; } @@ -109,7 +109,7 @@ static OutputInitResult AlertSyslogInitCtx(ConfNode *conf) 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) { @@ -117,7 +117,7 @@ static OutputInitResult AlertSyslogInitCtx(ConfNode *conf) } } - 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. */ diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index dc02cf61a9..a64ffe96ba 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -1574,8 +1574,8 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name, 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.", @@ -1585,7 +1585,7 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name, } 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.", @@ -1595,15 +1595,15 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name, } 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, @@ -1615,9 +1615,9 @@ int AppLayerProtoDetectPPParseConfPorts(const char *ipproto_name, } /* 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, @@ -1885,7 +1885,7 @@ int AppLayerProtoDetectConfProtoDetectionEnabledDefault( int enabled = 1; char param[100]; - ConfNode *node; + SCConfNode *node; int r; if (RunmodeIsUnittests()) @@ -1904,7 +1904,7 @@ int AppLayerProtoDetectConfProtoDetectionEnabledDefault( 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.", @@ -1915,7 +1915,7 @@ int AppLayerProtoDetectConfProtoDetectionEnabledDefault( 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) { @@ -1927,9 +1927,9 @@ int AppLayerProtoDetectConfProtoDetectionEnabledDefault( } 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; diff --git a/src/app-layer-htp-mem.c b/src/app-layer-htp-mem.c index 2825b6be7c..e72416bec8 100644 --- a/src/app-layer-htp-mem.c +++ b/src/app-layer-htp-mem.c @@ -48,8 +48,7 @@ void HTPParseMemcap(void) /** 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", diff --git a/src/app-layer-htp-range.c b/src/app-layer-htp-range.c index 9e8a4e1e64..6fbefc6642 100644 --- a/src/app-layer-htp-range.c +++ b/src/app-layer-htp-range.c @@ -174,7 +174,7 @@ void HttpRangeContainersInit(void) 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", @@ -182,7 +182,7 @@ void HttpRangeContainersInit(void) 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," diff --git a/src/app-layer-htp-xff.c b/src/app-layer-htp-xff.c index a4096f0c8e..96e2ab8f40 100644 --- a/src/app-layer-htp-xff.c +++ b/src/app-layer-htp-xff.c @@ -199,17 +199,17 @@ end: /** * \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; @@ -224,7 +224,7 @@ void HttpXFFGetCfg(ConfNode *conf, HttpXFFCfg *result) 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; @@ -240,7 +240,7 @@ void HttpXFFGetCfg(ConfNode *conf, HttpXFFCfg *result) 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; @@ -248,8 +248,7 @@ void HttpXFFGetCfg(ConfNode *conf, HttpXFFCfg *result) SCLogWarning("The XFF header hasn't been defined, using the default %s", XFF_DEFAULT); result->header = XFF_DEFAULT; } - } - else { + } else { result->flags = XFF_DISABLED; } } diff --git a/src/app-layer-htp-xff.h b/src/app-layer-htp-xff.h index 2d14f3f55b..62d1ef47da 100644 --- a/src/app-layer-htp-xff.h +++ b/src/app-layer-htp-xff.h @@ -43,7 +43,7 @@ typedef struct HttpXFFCfg_ { 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); diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index 7293e8671c..6f43033dd4 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -2178,17 +2178,17 @@ static void HTPConfigSetDefaultsPhase2(const char *name, HTPCfgRec *cfg_prec) 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); @@ -2274,13 +2274,13 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, struct HT } } 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); } @@ -2317,9 +2317,8 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, struct HT 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, @@ -2330,29 +2329,23 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, struct HT "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) { @@ -2370,17 +2363,15 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, struct HT 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) { @@ -2415,9 +2406,9 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, struct HT #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' " @@ -2481,7 +2472,7 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, struct HT #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; @@ -2496,9 +2487,9 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, struct HT } 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) { @@ -2511,13 +2502,13 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, struct HT } } } 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"); @@ -2581,20 +2572,20 @@ void HTPConfigure(void) } 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; @@ -2602,11 +2593,11 @@ void HTPConfigure(void) } 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; @@ -3473,11 +3464,11 @@ libhtp:\n\ personality: IDS\n\ "; - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); HtpConfigCreateBackup(); - ConfYamlLoadString(input, strlen(input)); + SCConfYamlLoadString(input, strlen(input)); HTPConfigure(); HtpState *htp_state = NULL; @@ -3510,8 +3501,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); StreamTcpFreeConfig(true); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); UTHFreeFlow(f); PASS; @@ -3536,11 +3527,11 @@ libhtp:\n\ personality: Apache_2_2\n\ "; - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); HtpConfigCreateBackup(); - ConfYamlLoadString(input, strlen(input)); + SCConfYamlLoadString(input, strlen(input)); HTPConfigure(); HtpState *htp_state = NULL; @@ -3575,8 +3566,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); StreamTcpFreeConfig(true); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); UTHFreeFlow(f); PASS; @@ -3845,19 +3836,19 @@ libhtp:\n\ 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); @@ -3865,13 +3856,13 @@ libhtp:\n\ 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) { @@ -3895,7 +3886,7 @@ libhtp:\n\ 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); @@ -3905,11 +3896,11 @@ libhtp:\n\ 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; @@ -3931,8 +3922,8 @@ libhtp:\n\ i++; } - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); PASS; } @@ -3961,10 +3952,10 @@ libhtp:\n\ 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); @@ -3995,8 +3986,8 @@ libhtp:\n\ SCLogDebug("LIBHTP using config: %p", htp); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); PASS; @@ -4034,11 +4025,11 @@ libhtp:\n\ personality: IIS_7_0\n\ "; - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); HtpConfigCreateBackup(); - ConfYamlLoadString(input, strlen(input)); + SCConfYamlLoadString(input, strlen(input)); HTPConfigure(); @@ -4093,8 +4084,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4128,10 +4119,10 @@ libhtp:\n\ 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)); @@ -4197,8 +4188,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4225,10 +4216,10 @@ libhtp:\n\ 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)); @@ -4288,8 +4279,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4326,10 +4317,10 @@ libhtp:\n\ 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)); @@ -4396,8 +4387,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4432,10 +4423,10 @@ libhtp:\n\ 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)); @@ -4491,8 +4482,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4523,10 +4514,10 @@ libhtp:\n\ 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)); @@ -4569,8 +4560,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4601,10 +4592,10 @@ libhtp:\n\ 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)); @@ -4647,8 +4638,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4679,10 +4670,10 @@ libhtp:\n\ 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)); @@ -4725,8 +4716,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4758,10 +4749,10 @@ libhtp:\n\ 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)); @@ -4804,8 +4795,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4834,10 +4825,10 @@ libhtp:\n\ 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)); @@ -4880,8 +4871,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -4911,10 +4902,10 @@ libhtp:\n\ 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)); @@ -4957,8 +4948,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); @@ -5033,10 +5024,10 @@ libhtp:\n\ response-body-limit: 0\n\ "; - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); HtpConfigCreateBackup(); - ConfYamlLoadString(input, strlen(input)); + SCConfYamlLoadString(input, strlen(input)); HTPConfigure(); TcpSession ssn; @@ -5069,8 +5060,8 @@ libhtp:\n\ AppLayerParserThreadCtxFree(alp_tctx); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); StreamTcpFreeConfig(true); UTHFreeFlow(f); @@ -5099,10 +5090,10 @@ libhtp:\n\ memset(&ssn, 0, sizeof(ssn)); - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); HtpConfigCreateBackup(); - ConfYamlLoadString(input, strlen(input)); + SCConfYamlLoadString(input, strlen(input)); HTPConfigure(); char *httpbuf = SCMalloc(len); @@ -5166,8 +5157,8 @@ libhtp:\n\ UTHFreeFlow(f); SCFree(httpbuf); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); PASS; } @@ -5198,10 +5189,10 @@ libhtp:\n\ memset(&ssn, 0, sizeof(ssn)); - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); HtpConfigCreateBackup(); - ConfYamlLoadString(input, strlen(input)); + SCConfYamlLoadString(input, strlen(input)); HTPConfigure(); httpbuf = SCMalloc(len); @@ -5265,8 +5256,8 @@ libhtp:\n\ UTHFreeFlow(f); SCFree(httpbuf); HTPFreeConfig(); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); PASS; } @@ -5732,10 +5723,10 @@ libhtp:\n\ 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; @@ -5850,8 +5841,8 @@ libhtp:\n\ FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); HtpConfigRestoreBackup(); PASS; } diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 7601da2592..0237bbb7a0 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -342,7 +342,7 @@ int AppLayerParserConfParserEnabled(const char *ipproto, int enabled = 1; char param[100]; - ConfNode *node; + SCConfNode *node; int r; if (RunmodeIsUnittests()) @@ -356,7 +356,7 @@ int AppLayerParserConfParserEnabled(const char *ipproto, 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.", @@ -367,16 +367,16 @@ int AppLayerParserConfParserEnabled(const char *ipproto, 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; diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index 35d51c7f6a..2d4b2a424f 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -316,27 +316,27 @@ static void SMTPConfigure(void) { 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"); @@ -344,7 +344,7 @@ static void SMTPConfigure(void) { SCMimeSmtpConfigHeaderValueDepth((uint32_t)imval); } - ret = ConfGetChildValueBool(config, "extract-urls", &val); + ret = SCConfGetChildValueBool(config, "extract-urls", &val); if (ret) { SCMimeSmtpConfigExtractUrls(val); } @@ -352,9 +352,9 @@ static void SMTPConfigure(void) { /* 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); @@ -385,19 +385,19 @@ static void SMTPConfigure(void) { 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) { @@ -429,7 +429,7 @@ static void SMTPConfigure(void) { 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; } @@ -443,7 +443,7 @@ static void SMTPConfigure(void) { 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", diff --git a/src/app-layer-ssh.c b/src/app-layer-ssh.c index 276e0fbee3..e82183c0a3 100644 --- a/src/app-layer-ssh.c +++ b/src/app-layer-ssh.c @@ -90,13 +90,13 @@ void RegisterSSHParsers(void) /* 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; } diff --git a/src/app-layer-ssl.c b/src/app-layer-ssl.c index e3a6312205..c77654b31e 100644 --- a/src/app-layer-ssl.c +++ b/src/app-layer-ssl.c @@ -3192,14 +3192,14 @@ static void CheckJA3Enabled(void) 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); @@ -3217,14 +3217,14 @@ static void CheckJA4Enabled(void) 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); @@ -3309,7 +3309,7 @@ void RegisterSSLParsers(void) 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) { @@ -3323,13 +3323,14 @@ void RegisterSSLParsers(void) } } 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; } } diff --git a/src/conf-yaml-loader.c b/src/conf-yaml-loader.c index d228efb5f8..b5d6c4380c 100644 --- a/src/conf-yaml-loader.c +++ b/src/conf-yaml-loader.c @@ -48,7 +48,8 @@ static int mangle_errors = 0; 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 { @@ -111,7 +112,7 @@ ConfYamlSetConfDirname(const char *filename) * * \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]; @@ -164,9 +165,10 @@ done: * * \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; @@ -235,7 +237,7 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int 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; } } @@ -243,7 +245,7 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int } 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)) { @@ -254,7 +256,7 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int } // 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 @@ -264,7 +266,7 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int TAILQ_REMOVE(&parent->head, seq_node, next); } else { - seq_node = ConfNodeNew(); + seq_node = SCConfNodeNew(); if (unlikely(seq_node == NULL)) { goto fail; } @@ -288,7 +290,7 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int 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; @@ -315,21 +317,21 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int } 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; } @@ -362,7 +364,7 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int 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) @@ -395,7 +397,7 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int 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)) { @@ -406,7 +408,7 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int } // 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 @@ -416,7 +418,7 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int TAILQ_REMOVE(&node->head, seq_node, next); } else { - seq_node = ConfNodeNew(); + seq_node = SCConfNodeNew(); if (unlikely(seq_node == NULL)) { goto fail; } @@ -472,13 +474,12 @@ static int ConfYamlParse(yaml_parser_t *parser, ConfNode *parent, int inseq, int * * \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."); @@ -519,10 +520,9 @@ ConfYamlLoadFile(const char *filename) /** * \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; @@ -550,13 +550,12 @@ ConfYamlLoadString(const char *string, size_t len) * * \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] */ @@ -588,8 +587,8 @@ ConfYamlLoadFileWithPrefix(const char *filename, const char *prefix) if (root == NULL) { /* if node at 'prefix' doesn't yet exist, add a place holder */ - ConfSet(prefix, ""); - root = ConfGetNode(prefix); + SCConfSet(prefix, ""); + root = SCConfGetNode(prefix); if (root == NULL) { fclose(infile); yaml_parser_delete(&parser); @@ -619,34 +618,34 @@ rule-files:\n\ 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; } @@ -665,17 +664,17 @@ logging:\n\ 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); @@ -707,8 +706,8 @@ logging:\n\ FAIL_IF(strcmp(output_param->name, "log-level") != 0); FAIL_IF(strcmp(output_param->val, "info") != 0); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); PASS; } @@ -719,13 +718,13 @@ logging:\n\ 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; } @@ -745,13 +744,13 @@ logging:\n\ 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; } @@ -780,16 +779,16 @@ libhtp:\n\ - 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); @@ -799,7 +798,7 @@ libhtp:\n\ 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); @@ -807,8 +806,8 @@ libhtp:\n\ FAIL_IF(strcmp(node->name, "0") != 0); FAIL_IF(strcmp(node->val, "192.168.1.0/24") != 0); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); PASS; } @@ -838,8 +837,8 @@ ConfYamlFileIncludeTest(void) "unix-command:\n" " enabled: no\n"; - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); /* Write out the test files. */ FAIL_IF_NULL((config_file = fopen(config_filename, "w"))); @@ -856,30 +855,30 @@ ConfYamlFileIncludeTest(void) 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); @@ -912,38 +911,39 @@ ConfYamlOverrideTest(void) "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; } @@ -955,8 +955,8 @@ ConfYamlOverrideTest(void) static int ConfYamlOverrideFinalTest(void) { - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); char config[] = "%YAML 1.1\n" @@ -964,24 +964,24 @@ ConfYamlOverrideFinalTest(void) "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" @@ -996,65 +996,64 @@ static int ConfYamlNull(void) "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); diff --git a/src/conf-yaml-loader.h b/src/conf-yaml-loader.h index 0355ebc5c9..324d62f977 100644 --- a/src/conf-yaml-loader.h +++ b/src/conf-yaml-loader.h @@ -26,11 +26,11 @@ #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 */ diff --git a/src/conf.c b/src/conf.c index 3cb9fd0801..93706843fc 100644 --- a/src/conf.c +++ b/src/conf.c @@ -46,8 +46,8 @@ /** 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 @@ -63,9 +63,9 @@ static ConfNode *root_backup = NULL; * \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; @@ -80,15 +80,15 @@ ConfNode *ConfNodeGetNodeOrCreate(ConfNode *parent, const char *name, int final) 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; @@ -106,24 +106,24 @@ 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."); @@ -136,9 +136,9 @@ void ConfInit(void) * * \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)) { @@ -150,17 +150,17 @@ ConfNode *ConfNodeNew(void) } /** - * \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) @@ -171,16 +171,16 @@ void ConfNodeFree(ConfNode *node) } /** - * \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; @@ -194,7 +194,7 @@ ConfNode *ConfGetNode(const char *name) do { if ((next = strchr(key, '.')) != NULL) *next++ = '\0'; - node = ConfNodeLookupChild(node, key); + node = SCConfNodeLookupChild(node, key); key = next; } while (next != NULL && node != NULL); @@ -204,7 +204,7 @@ ConfNode *ConfGetNode(const char *name) /** * \brief Get the root configuration node. */ -ConfNode *ConfGetRootNode(void) +SCConfNode *SCConfGetRootNode(void) { return root; } @@ -221,9 +221,9 @@ ConfNode *ConfGetRootNode(void) * * \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; } @@ -246,7 +246,7 @@ int ConfSet(const char *name, const char *val) * * \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; @@ -268,12 +268,12 @@ int ConfSetFromString(const char *input, int final) } if (final) { - if (!ConfSetFinal(name, val)) { + if (!SCConfSetFinal(name, val)) { goto done; } } else { - if (!ConfSet(name, val)) { + if (!SCConfSet(name, val)) { goto done; } } @@ -300,9 +300,9 @@ 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; } @@ -323,7 +323,7 @@ int ConfSetFinal(const char *name, const char *val) * 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. @@ -332,9 +332,9 @@ int ConfSetFinal(const char *name, const char *val) * \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; @@ -345,9 +345,9 @@ int ConfGet(const char *name, const char **vptr) } } -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); @@ -361,27 +361,27 @@ int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr) } } -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; } @@ -396,13 +396,13 @@ int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, * \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) { @@ -431,13 +431,13 @@ int ConfGetInt(const char *name, intmax_t *val) 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); @@ -458,13 +458,13 @@ int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val) 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; } @@ -479,44 +479,44 @@ int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, * \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; } @@ -533,7 +533,7 @@ int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, * * \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; @@ -558,7 +558,7 @@ int ConfValIsTrue(const char *val) * * \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; @@ -582,13 +582,13 @@ int ConfValIsFalse(const char *val) * \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; @@ -612,13 +612,13 @@ int ConfGetDouble(const char *name, double *val) * \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; @@ -635,11 +635,11 @@ int ConfGetFloat(const char *name, float *val) /** * \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); } /** @@ -650,15 +650,15 @@ void ConfNodeRemove(ConfNode *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; } } @@ -666,7 +666,7 @@ int ConfRemove(const char *name) /** * \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; @@ -676,7 +676,7 @@ void ConfCreateContextBackup(void) * \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; @@ -685,10 +685,10 @@ void ConfRestoreContextBackup(void) /** * \brief De-initializes the configuration system. */ -void ConfDeInit(void) +void SCConfDeInit(void) { if (root != NULL) { - ConfNodeFree(root); + SCConfNodeFree(root); root = NULL; } @@ -713,9 +713,9 @@ static char *ConfPrintNameArray(char **name_arr, int level) /** * \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; @@ -734,7 +734,7 @@ void ConfNodeDump(const ConfNode *node, const char *prefix) printf("%s.%s = %s\n", prefix, ConfPrintNameArray(name, level), child->val); } - ConfNodeDump(child, prefix); + SCConfNodeDump(child, prefix); SCFree(name[level]); } level--; @@ -743,9 +743,9 @@ void ConfNodeDump(const ConfNode *node, const char *prefix) /** * \brief Dump configuration to stdout. */ -void ConfDump(void) +void SCConfDump(void) { - ConfNodeDump(root, NULL); + SCConfNodeDump(root, NULL); } /** @@ -759,7 +759,7 @@ void ConfDump(void) * \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; @@ -770,17 +770,17 @@ bool ConfNodeHasChildren(const ConfNode *node) /** * \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; @@ -797,20 +797,20 @@ ConfNode *ConfNodeLookupChild(const ConfNode *node, const char *name) /** * \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; @@ -820,17 +820,16 @@ const char *ConfNodeLookupChildValue(const ConfNode *node, const char *name) /** * \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; @@ -851,13 +850,13 @@ ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key, * \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; } /** @@ -876,14 +875,14 @@ int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key) * * \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) @@ -908,7 +907,7 @@ void ConfNodePrune(ConfNode *node) * * \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; } @@ -919,12 +918,12 @@ int ConfNodeIsSequence(const ConfNode *node) * @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; @@ -945,12 +944,12 @@ ConfNode *ConfSetIfaceNode(const char *ifaces_node_name, const char *iface) * @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 " @@ -977,7 +976,7 @@ static int ConfTestGetNonExistant(void) char name[] = "non-existant-value"; const char *value; - FAIL_IF(ConfGet(name, &value)); + FAIL_IF(SCConfGet(name, &value)); PASS; } @@ -990,13 +989,13 @@ static int ConfTestSetAndGet(void) 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; } @@ -1012,14 +1011,14 @@ static int ConfTestOverrideValue1(void) 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; } @@ -1034,14 +1033,14 @@ static int ConfTestOverrideValue2(void) 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; } @@ -1054,20 +1053,20 @@ static int ConfTestGetInt(void) 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; } @@ -1095,14 +1094,14 @@ static int ConfTestGetBool(void) 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); } @@ -1114,38 +1113,38 @@ static int ConfNodeLookupChildTest(void) 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; @@ -1156,33 +1155,33 @@ static int ConfNodeLookupChildValueTest(void) 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; } @@ -1190,47 +1189,47 @@ static int ConfNodeLookupChildValueTest(void) 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; } @@ -1238,23 +1237,23 @@ static int ConfGetChildValueIntWithDefaultTest(void) 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; } @@ -1264,197 +1263,197 @@ static int ConfGetChildValueBoolWithDefaultTest(void) */ 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); diff --git a/src/conf.h b/src/conf.h index 1857efee98..f857d1bfa9 100644 --- a/src/conf.h +++ b/src/conf.h @@ -29,7 +29,7 @@ /** * Structure of a configuration parameter. */ -typedef struct ConfNode_ { +typedef struct SCConfNode_ { char *name; char *val; @@ -38,11 +38,10 @@ typedef struct ConfNode_ { /**< 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. @@ -55,47 +54,50 @@ typedef struct ConfNode_ { #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 */ diff --git a/src/counters.c b/src/counters.c index 97a904eac2..6b2446a623 100644 --- a/src/counters.c +++ b/src/counters.c @@ -224,13 +224,14 @@ void StatsSetUI64(ThreadVars *tv, uint16_t id, uint64_t x) 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) { @@ -247,16 +248,16 @@ static ConfNode *GetConfig(void) { 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. " @@ -264,7 +265,7 @@ static void StatsInitCtxPreOutput(void) 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 " @@ -274,17 +275,17 @@ static void StatsInitCtxPreOutput(void) } 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; diff --git a/src/datasets.c b/src/datasets.c index 0f50afebbc..c0c8a9b3d7 100644 --- a/src/datasets.c +++ b/src/datasets.c @@ -580,7 +580,7 @@ void DatasetPostReloadCleanup(void) 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", @@ -590,7 +590,7 @@ static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize) } *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," @@ -603,18 +603,18 @@ static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize) 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); } @@ -630,7 +630,7 @@ int DatasetsInit(void) } int list_pos = 0; - ConfNode *iter = NULL; + SCConfNode *iter = NULL; TAILQ_FOREACH(iter, &datasets->head, next) { if (iter->name == NULL) { list_pos++; @@ -649,27 +649,24 @@ int DatasetsInit(void) 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" @@ -678,7 +675,7 @@ int DatasetsInit(void) 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" diff --git a/src/decode-erspan.c b/src/decode-erspan.c index 76cb9bd5af..0b1a37425b 100644 --- a/src/decode-erspan.c +++ b/src/decode-erspan.c @@ -53,7 +53,7 @@ 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."); } diff --git a/src/decode-geneve.c b/src/decode-geneve.c index 21ac947caf..2945d8f9d0 100644 --- a/src/decode-geneve.c +++ b/src/decode-geneve.c @@ -128,7 +128,7 @@ static void DecodeGeneveConfigPorts(const char *pstr) 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 { @@ -137,7 +137,7 @@ void DecodeGeneveConfig(void) } if (g_geneve_enabled) { - ConfNode *node = ConfGetNode("decoder.geneve.ports"); + SCConfNode *node = SCConfGetNode("decoder.geneve.ports"); if (node && node->val) { DecodeGeneveConfigPorts(node->val); } else { diff --git a/src/decode-teredo.c b/src/decode-teredo.c index 9fd46f0118..2beee446c3 100644 --- a/src/decode-teredo.c +++ b/src/decode-teredo.c @@ -104,7 +104,7 @@ static void DecodeTeredoConfigPorts(const char *pstr) 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 { @@ -112,7 +112,7 @@ void DecodeTeredoConfig(void) } } if (g_teredo_enabled) { - ConfNode *node = ConfGetNode("decoder.teredo.ports"); + SCConfNode *node = SCConfGetNode("decoder.teredo.ports"); if (node && node->val) { DecodeTeredoConfigPorts(node->val); } diff --git a/src/decode-vxlan.c b/src/decode-vxlan.c index a8473de052..92433a0fcd 100644 --- a/src/decode-vxlan.c +++ b/src/decode-vxlan.c @@ -98,7 +98,7 @@ static void DecodeVXLANConfigPorts(const char *pstr) 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 { @@ -107,7 +107,7 @@ void DecodeVXLANConfig(void) } if (g_vxlan_enabled) { - ConfNode *node = ConfGetNode("decoder.vxlan.ports"); + SCConfNode *node = SCConfGetNode("decoder.vxlan.ports"); if (node && node->val) { DecodeVXLANConfigPorts(node->val); } else { diff --git a/src/decode.c b/src/decode.c index 77739ed0bd..1933745f69 100644 --- a/src/decode.c +++ b/src/decode.c @@ -1008,7 +1008,7 @@ void DecodeGlobalConfig(void) 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 { @@ -1021,7 +1021,7 @@ void DecodeGlobalConfig(void) 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 { diff --git a/src/defrag-config.c b/src/defrag-config.c index d22ac44a0b..e2b5ec5eca 100644 --- a/src/defrag-config.c +++ b/src/defrag-config.c @@ -107,9 +107,9 @@ int DefragPolicyGetHostTimeout(Packet *p) 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) { @@ -121,7 +121,7 @@ static void DefragParseParameters(ConfNode *n) } } if (strcasecmp("address", si->name) == 0) { - ConfNode *pval; + SCConfNode *pval; TAILQ_FOREACH(pval, &si->head, next) { DefragPolicyAddHostInfo(pval->val, timeout); } @@ -139,17 +139,17 @@ void DefragPolicyLoadFromConfig(void) { 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); diff --git a/src/defrag-hash.c b/src/defrag-hash.c index b5b21f3778..2f1e4e832f 100644 --- a/src/defrag-hash.c +++ b/src/defrag-hash.c @@ -190,8 +190,7 @@ void DefragInitConfig(bool quiet) 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", @@ -201,8 +200,7 @@ void DefragInitConfig(bool quiet) 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; @@ -211,9 +209,7 @@ void DefragInitConfig(bool quiet) } } - - 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; @@ -256,9 +252,8 @@ void DefragInitConfig(bool quiet) (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)))) { diff --git a/src/defrag.c b/src/defrag.c index e870c99068..e48ee1776b 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -162,13 +162,13 @@ DefragContextNew(void) /* 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; } @@ -184,10 +184,9 @@ DefragContextNew(void) /* 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."); } @@ -1113,7 +1112,7 @@ void 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; } @@ -2309,7 +2308,7 @@ static int DefragTimeoutTest(void) 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(); diff --git a/src/detect-dataset.c b/src/detect-dataset.c index 173a69cb1b..6aec3fde68 100644 --- a/src/detect-dataset.c +++ b/src/detect-dataset.c @@ -313,7 +313,7 @@ static int SetupSavePath(const DetectEngineCtx *de_ctx, 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; @@ -321,7 +321,7 @@ static int SetupSavePath(const DetectEngineCtx *de_ctx, } 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 { diff --git a/src/detect-engine-address.c b/src/detect-engine-address.c index fb649c1df7..208534e8ba 100644 --- a/src/detect-engine-address.c +++ b/src/detect-engine-address.c @@ -1220,7 +1220,7 @@ int DetectAddressTestConfVars(void) 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; } @@ -1228,7 +1228,7 @@ int DetectAddressTestConfVars(void) 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); @@ -4666,15 +4666,15 @@ static int AddressConfVarsTest01(void) 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; } @@ -4702,15 +4702,15 @@ static int AddressConfVarsTest02(void) 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; } @@ -4738,15 +4738,15 @@ static int AddressConfVarsTest03(void) 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; } @@ -4774,15 +4774,15 @@ static int AddressConfVarsTest04(void) 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; } @@ -4810,9 +4810,9 @@ static int AddressConfVarsTest05(void) 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; @@ -4820,10 +4820,10 @@ static int AddressConfVarsTest05(void) result = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); - return result; + return result; } static int AddressConfVarsTest06(void) @@ -4977,14 +4977,14 @@ 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; } diff --git a/src/detect-engine-analyzer.c b/src/detect-engine-analyzer.c index b17e8929ec..aff29b43e1 100644 --- a/src/detect-engine-analyzer.c +++ b/src/detect-engine-analyzer.c @@ -301,15 +301,14 @@ static int SetupFPAnalyzer(DetectEngineCtx *de_ctx) { 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"); @@ -379,11 +378,11 @@ static bool PerCentEncodingSetup(EngineAnalysisCtx *ea_ctx) */ 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; @@ -391,7 +390,7 @@ static int SetupRuleAnalyzer(DetectEngineCtx *de_ctx) } 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"); @@ -1369,7 +1368,7 @@ void EngineAnalysisRules2(const DetectEngineCtx *de_ctx, const Signature *s) 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); @@ -1447,7 +1446,7 @@ void DumpPatterns(DetectEngineCtx *de_ctx) 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); diff --git a/src/detect-engine-build.c b/src/detect-engine-build.c index e348103ce3..5582b277f5 100644 --- a/src/detect-engine-build.c +++ b/src/detect-engine-build.c @@ -941,7 +941,7 @@ static void RulesDumpGrouping(const DetectEngineCtx *de_ctx, 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); @@ -1999,13 +1999,13 @@ int SigPrepareStage4(DetectEngineCtx *de_ctx) } 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); } @@ -2164,7 +2164,7 @@ int SigGroupBuild(DetectEngineCtx *de_ctx) 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 diff --git a/src/detect-engine-loader.c b/src/detect-engine-loader.c index c2d2d344be..3dd6954d45 100644 --- a/src/detect-engine-loader.c +++ b/src/detect-engine-loader.c @@ -74,11 +74,11 @@ char *DetectLoadCompleteSigPath(const DetectEngineCtx *de_ctx, const char *sig_f /* 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; @@ -287,8 +287,8 @@ int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, bool sig_file_exc { 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; @@ -308,13 +308,12 @@ int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, bool sig_file_exc /* 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; @@ -503,7 +502,7 @@ static void DetectLoaderInit(DetectLoaderControl *loader) 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); diff --git a/src/detect-engine-mpm.c b/src/detect-engine-mpm.c index dca7bf4b95..688b1d544c 100644 --- a/src/detect-engine-mpm.c +++ b/src/detect-engine-mpm.c @@ -260,7 +260,7 @@ void DetectMpmInitializeAppMpms(DetectEngineCtx *de_ctx) 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) { @@ -432,7 +432,7 @@ void DetectEngineFrameMpmRegister(DetectEngineCtx *de_ctx, const char *name, int 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) { @@ -487,7 +487,7 @@ void DetectMpmInitializeFrameMpms(DetectEngineCtx *de_ctx) 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) { @@ -654,7 +654,7 @@ void DetectMpmInitializePktMpms(DetectEngineCtx *de_ctx) 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) { @@ -709,7 +709,7 @@ static int32_t SetupBuiltinMpm(DetectEngineCtx *de_ctx, const char *name) 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; @@ -857,7 +857,7 @@ uint8_t PatternMatchDefaultMatcher(void) 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) { diff --git a/src/detect-engine-port.c b/src/detect-engine-port.c index 4b0031d200..a541d512a8 100644 --- a/src/detect-engine-port.c +++ b/src/detect-engine-port.c @@ -1109,12 +1109,12 @@ int DetectPortTestConfVars(void) 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); diff --git a/src/detect-engine-profile.c b/src/detect-engine-profile.c index 36cf6e106b..a20b78c466 100644 --- a/src/detect-engine-profile.c +++ b/src/detect-engine-profile.c @@ -62,7 +62,7 @@ void RulesDumpTxMatchArray(const DetectEngineThreadCtx *det_ctx, const SigGroupH 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); @@ -106,7 +106,7 @@ void RulesDumpMatchArray(const DetectEngineThreadCtx *det_ctx, 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); diff --git a/src/detect-engine-threshold.c b/src/detect-engine-threshold.c index a4ccc39b00..307e9c08cf 100644 --- a/src/detect-engine-threshold.c +++ b/src/detect-engine-threshold.c @@ -195,7 +195,7 @@ static int ThresholdsInit(struct Thresholds *t) 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; @@ -203,7 +203,7 @@ static int ThresholdsInit(struct Thresholds *t) } 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.", diff --git a/src/detect-engine.c b/src/detect-engine.c index 15423ead65..a185d24b6b 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -2580,11 +2580,11 @@ retry: 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; } @@ -2596,7 +2596,7 @@ const char *DetectEngineMpmCachingGetPath(void) char yamlpath[] = "detect.sgh-mpm-caching-path"; const char *strval = NULL; - ConfGet(yamlpath, &strval); + SCConfGet(yamlpath, &strval); if (strval != NULL) { return strval; @@ -2635,7 +2635,7 @@ static DetectEngineCtx *DetectEngineCtxInitReal( } 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); @@ -2686,7 +2686,7 @@ static DetectEngineCtx *DetectEngineCtxInitReal( /* 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; @@ -2695,7 +2695,7 @@ static DetectEngineCtx *DetectEngineCtxInitReal( if (ActionInitConfig() < 0) { goto error; } - SCReferenceConfInit(de_ctx); + SCReferenceSCConfInit(de_ctx); if (SCRConfLoadReferenceConfigFile(de_ctx, NULL) < 0) { if (SCRunmodeGet() == RUNMODE_CONF_TEST) goto error; @@ -2822,9 +2822,9 @@ void DetectEngineCtxFree(DetectEngineCtx *de_ctx) /* 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(); @@ -2865,11 +2865,11 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) 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) { @@ -2953,29 +2953,27 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) 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"); } } } @@ -3022,15 +3020,14 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) 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) { @@ -3039,7 +3036,7 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) 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"); @@ -3073,7 +3070,7 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) // 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 { @@ -3082,7 +3079,7 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) } } 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; } @@ -3091,11 +3088,11 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) /* 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); @@ -3122,11 +3119,11 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) } 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); @@ -3153,7 +3150,7 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx) 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) { @@ -4024,7 +4021,7 @@ static int DetectEngineMultiTenantLoadTenant(uint32_t tenant_id, const char *fil goto error; } - ConfNode *node = ConfGetNode(prefix); + SCConfNode *node = SCConfGetNode(prefix); if (node == NULL) { SCLogError("failed to properly setup yaml %s", filename); goto error; @@ -4079,12 +4076,12 @@ static int DetectEngineMultiTenantReloadTenant(uint32_t tenant_id, const char *f 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; @@ -4285,18 +4282,18 @@ int DetectEngineReloadTenantsBlocking(const int reload_cnt) 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; @@ -4344,18 +4341,18 @@ error: 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; @@ -4413,10 +4410,10 @@ int DetectEngineMultiTenantSetup(const bool unix_socket) 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(); @@ -4427,14 +4424,14 @@ int DetectEngineMultiTenantSetup(const bool unix_socket) 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); @@ -4463,7 +4460,7 @@ int DetectEngineMultiTenantSetup(const bool unix_socket) 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, @@ -4499,23 +4496,23 @@ int DetectEngineMultiTenantSetup(const bool unix_socket) } /* 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; } @@ -4539,10 +4536,10 @@ int DetectEngineMultiTenantSetup(const bool unix_socket) 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; } @@ -4911,12 +4908,12 @@ int DetectEngineReload(const SCInstance *suri) 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; @@ -4925,7 +4922,7 @@ int DetectEngineReload(const SCInstance *suri) 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]); } } @@ -5131,15 +5128,15 @@ void DetectEngineSetEvent(DetectEngineThreadCtx *det_ctx, uint8_t e) 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) diff --git a/src/detect-flowbits.c b/src/detect-flowbits.c index 5679bfa99e..26bbef19a3 100644 --- a/src/detect-flowbits.c +++ b/src/detect-flowbits.c @@ -793,7 +793,7 @@ static void DetectFlowbitsAnalyzeDump(const DetectEngineCtx *de_ctx, 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); diff --git a/src/detect-geoip.c b/src/detect-geoip.c index b50d12abd7..63593fde3a 100644 --- a/src/detect-geoip.c +++ b/src/detect-geoip.c @@ -100,7 +100,7 @@ static bool InitGeolocationEngine(DetectGeoipData *geoipdata) 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" diff --git a/src/detect-lua.c b/src/detect-lua.c index 1003484621..fc715d54e2 100644 --- a/src/detect-lua.c +++ b/src/detect-lua.c @@ -881,7 +881,7 @@ static int DetectLuaSetup (DetectEngineCtx *de_ctx, Signature *s, const char *st /* 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; @@ -894,13 +894,13 @@ static int DetectLuaSetup (DetectEngineCtx *de_ctx, Signature *s, const char *st /* 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) { @@ -1053,7 +1053,7 @@ static void DetectLuaFree(DetectEngineCtx *de_ctx, void *ptr) /** \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" diff --git a/src/detect-pcre.c b/src/detect-pcre.c index fdbd8fd87a..435ffc0628 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -108,11 +108,10 @@ void DetectPcreRegister (void) 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); @@ -123,11 +122,10 @@ void DetectPcreRegister (void) 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); diff --git a/src/detect-uricontent.c b/src/detect-uricontent.c index 65d2c868f7..2203f66b3b 100644 --- a/src/detect-uricontent.c +++ b/src/detect-uricontent.c @@ -113,7 +113,7 @@ int DetectUricontentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *con 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 " diff --git a/src/flow-manager.c b/src/flow-manager.c index 4e1efd03c0..c2b799a567 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -1000,7 +1000,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data) 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); @@ -1195,7 +1195,7 @@ static bool FlowRecyclerReadyToShutdown(void) 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); diff --git a/src/flow.c b/src/flow.c index 07c5b12918..07562abac7 100644 --- a/src/flow.c +++ b/src/flow.c @@ -535,7 +535,7 @@ void FlowInitConfig(bool quiet) /* 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 { @@ -554,8 +554,7 @@ void FlowInitConfig(bool quiet) /** 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"); } @@ -569,8 +568,7 @@ void FlowInitConfig(bool quiet) 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"); } @@ -582,8 +580,7 @@ void FlowInitConfig(bool quiet) "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"); } @@ -756,25 +753,22 @@ void FlowInitFlowProto(void) 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) { @@ -830,19 +824,16 @@ void FlowInitFlowProto(void) } /* 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) { @@ -898,16 +889,14 @@ void FlowInitFlowProto(void) } /* 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) { @@ -950,16 +939,14 @@ void FlowInitFlowProto(void) } /* 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) { diff --git a/src/host.c b/src/host.c index a351b6daec..83ce5bc193 100644 --- a/src/host.c +++ b/src/host.c @@ -192,7 +192,7 @@ void HostInitConfig(bool quiet) 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 " @@ -203,14 +203,14 @@ void HostInitConfig(bool quiet) 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; diff --git a/src/ippair.c b/src/ippair.c index 82dc3b30c1..12480ee6cd 100644 --- a/src/ippair.c +++ b/src/ippair.c @@ -187,8 +187,7 @@ void IPPairInitConfig(bool quiet) /** 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", @@ -198,16 +197,14 @@ void IPPairInitConfig(bool quiet) 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; diff --git a/src/log-flush.c b/src/log-flush.c index a8c94e5b3e..155154f38d 100644 --- a/src/log-flush.c +++ b/src/log-flush.c @@ -122,7 +122,7 @@ error: 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) { diff --git a/src/log-httplog.c b/src/log-httplog.c index 3a6fa079ec..b7dabe1f73 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -532,7 +532,7 @@ TmEcode LogHttpLogThreadDeinit(ThreadVars *t, void *data) * \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 }; @@ -555,12 +555,12 @@ OutputInitResult LogHttpLogInitCtx(ConfNode *conf) 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) { @@ -577,7 +577,7 @@ OutputInitResult LogHttpLogInitCtx(ConfNode *conf) if (extended == NULL) { httplog_ctx->flags |= LOG_HTTP_DEFAULT; } else { - if (ConfValIsTrue(extended)) { + if (SCConfValIsTrue(extended)) { httplog_ctx->flags |= LOG_HTTP_EXTENDED; } } diff --git a/src/log-httplog.h b/src/log-httplog.h index 9423358efc..8ec6ba2171 100644 --- a/src/log-httplog.h +++ b/src/log-httplog.h @@ -25,6 +25,6 @@ #define SURICATA_LOG_HTTPLOG_H void LogHttpLogRegister(void); -OutputInitResult LogHttpLogInitCtx(ConfNode *); +OutputInitResult LogHttpLogInitCtx(SCConfNode *); #endif /* SURICATA_LOG_HTTPLOG_H */ diff --git a/src/log-pcap.c b/src/log-pcap.c index de506ee255..c92eb399de 100644 --- a/src/log-pcap.c +++ b/src/log-pcap.c @@ -203,7 +203,7 @@ static int PcapLog(ThreadVars *, void *, const Packet *); 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 *); @@ -1301,7 +1301,7 @@ error: * \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; @@ -1346,7 +1346,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) const char *filename = NULL; if (conf != NULL) { /* To facilitate unit tests. */ - filename = ConfNodeLookupChildValue(conf, "filename"); + filename = SCConfNodeLookupChildValue(conf, "filename"); } if (filename == NULL) @@ -1361,7 +1361,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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); @@ -1382,7 +1382,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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; @@ -1394,10 +1394,10 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) } 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); @@ -1407,7 +1407,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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); @@ -1422,8 +1422,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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) { @@ -1459,14 +1458,13 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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) { @@ -1522,7 +1520,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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; @@ -1549,7 +1547,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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) { @@ -1569,7 +1567,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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) { @@ -1584,12 +1582,12 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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"); @@ -1598,12 +1596,12 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) 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"); @@ -1897,15 +1895,15 @@ static void PcapLogProfilingDump(PcapLogData *pl) 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)) { @@ -1914,8 +1912,8 @@ void PcapLogProfileSetup(void) 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"; diff --git a/src/log-stats.c b/src/log-stats.c index 76cb01cdbf..bfb6cae32c 100644 --- a/src/log-stats.c +++ b/src/log-stats.c @@ -207,7 +207,7 @@ TmEcode LogStatsLogThreadDeinit(ThreadVars *t, void *data) * \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(); @@ -230,26 +230,26 @@ static OutputInitResult LogStatsLogInitCtx(ConfNode *conf) 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); diff --git a/src/log-tcp-data.c b/src/log-tcp-data.c index b4e8b18a86..a6ec869624 100644 --- a/src/log-tcp-data.c +++ b/src/log-tcp-data.c @@ -208,7 +208,7 @@ TmEcode LogTcpDataLogThreadDeinit(ThreadVars *t, void *data) * \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] = ""; @@ -242,7 +242,7 @@ OutputInitResult LogTcpDataLogInitCtx(ConfNode *conf) } } - const char *logtype = ConfNodeLookupChildValue(conf, "type"); + const char *logtype = SCConfNodeLookupChildValue(conf, "type"); if (logtype == NULL) logtype = "file"; @@ -269,7 +269,7 @@ OutputInitResult LogTcpDataLogInitCtx(ConfNode *conf) } if (tcpdatalog_ctx->dir == 1) { - tcpdatalog_ctx->log_dir = ConfigGetLogDirectory(); + tcpdatalog_ctx->log_dir = SCConfigGetLogDirectory(); char dirfull[PATH_MAX]; /* create the filename to use */ diff --git a/src/log-tcp-data.h b/src/log-tcp-data.h index 6c4371793e..c577c54a03 100644 --- a/src/log-tcp-data.h +++ b/src/log-tcp-data.h @@ -28,6 +28,6 @@ #include "output.h" void LogTcpDataLogRegister(void); -OutputInitResult LogTcpDataLogInitCtx(ConfNode *); +OutputInitResult LogTcpDataLogInitCtx(SCConfNode *); #endif /* SURICATA_LOG_TCPDATALOG_H */ diff --git a/src/log-tlslog.c b/src/log-tlslog.c index 8d88047e99..f684b7a98f 100644 --- a/src/log-tlslog.c +++ b/src/log-tlslog.c @@ -176,7 +176,7 @@ static void LogTlsLogDeInitCtx(OutputCtx *output_ctx) * \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."); @@ -199,12 +199,12 @@ static OutputInitResult LogTlsLogInitCtx(ConfNode *conf) } 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; @@ -219,15 +219,14 @@ static OutputInitResult LogTlsLogInitCtx(ConfNode *conf) 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; } diff --git a/src/log-tlsstore.c b/src/log-tlsstore.c index 9f8d69f577..d0c48a5c56 100644 --- a/src/log-tlsstore.c +++ b/src/log-tlsstore.c @@ -399,7 +399,7 @@ static void LogTlsStoreLogDeInitCtx(OutputCtx *output_ctx) * \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)); @@ -409,8 +409,8 @@ static OutputInitResult LogTlsStoreLogInitCtx(ConfNode *conf) 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)); diff --git a/src/output-eve-null.c b/src/output-eve-null.c index 368836e783..7b9ebafe76 100644 --- a/src/output-eve-null.c +++ b/src/output-eve-null.c @@ -37,7 +37,7 @@ void NullLogInitialize(void) #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; diff --git a/src/output-eve-stream.c b/src/output-eve-stream.c index 3fcd12ea41..cfca4fdb43 100644 --- a/src/output-eve-stream.c +++ b/src/output-eve-stream.c @@ -126,16 +126,16 @@ static void EveStreamLogDeInitCtxSub(OutputCtx *output_ctx) 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; diff --git a/src/output-eve-syslog.c b/src/output-eve-syslog.c index 4560bc73e3..ac587bd77b 100644 --- a/src/output-eve-syslog.c +++ b/src/output-eve-syslog.c @@ -41,14 +41,14 @@ typedef struct Context_ { 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; } @@ -61,7 +61,7 @@ static int SyslogInit(const ConfNode *conf, const bool threaded, void **init_dat 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) { @@ -69,7 +69,7 @@ static int SyslogInit(const ConfNode *conf, const bool threaded, void **init_dat } } - 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. */ diff --git a/src/output-eve.h b/src/output-eve.h index 7e55ce28f8..0f3ffe43f6 100644 --- a/src/output-eve.h +++ b/src/output-eve.h @@ -101,7 +101,7 @@ typedef struct SCEveFileType_ { * * \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. diff --git a/src/output-filestore.c b/src/output-filestore.c index f9a660f56e..2a7894c468 100644 --- a/src/output-filestore.c +++ b/src/output-filestore.c @@ -310,9 +310,9 @@ static void OutputFilestoreLogDeInitCtx(OutputCtx *output_ctx) 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; @@ -320,7 +320,7 @@ static void GetLogDirectory(const ConfNode *conf, char *out, size_t out_size) 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); } } @@ -377,12 +377,12 @@ static bool InitFilestoreDirectory(const char *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; } @@ -427,22 +427,20 @@ static OutputInitResult OutputFilestoreLogInitCtx(ConfNode *conf) 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"); } @@ -454,8 +452,7 @@ static OutputInitResult OutputFilestoreLogInitCtx(ConfNode *conf) 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, @@ -478,8 +475,7 @@ static OutputInitResult OutputFilestoreLogInitCtx(ConfNode *conf) } } - 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, diff --git a/src/output-json-alert.c b/src/output-json-alert.c index 9e03128270..44835670dc 100644 --- a/src/output-json-alert.c +++ b/src/output-json-alert.c @@ -918,12 +918,12 @@ static void JsonAlertLogDeInitCtxSub(OutputCtx *output_ctx) 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; @@ -931,8 +931,7 @@ static void SetFlag(const ConfNode *conf, const char *name, uint16_t flag, uint1 } } -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; @@ -940,12 +939,12 @@ static void JsonAlertLogSetupMetadata(AlertJsonOutputCtx *json_output_ctx, 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, @@ -973,13 +972,13 @@ static void JsonAlertLogSetupMetadata(AlertJsonOutputCtx *json_output_ctx, 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; @@ -1012,10 +1011,10 @@ static void JsonAlertLogSetupMetadata(AlertJsonOutputCtx *json_output_ctx, 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); @@ -1029,7 +1028,7 @@ static HttpXFFCfg *JsonAlertLogGetXffCfg(ConfNode *conf) * \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; diff --git a/src/output-json-anomaly.c b/src/output-json-anomaly.c index 00c4cbd570..937dff96f2 100644 --- a/src/output-json-anomaly.c +++ b/src/output-json-anomaly.c @@ -357,12 +357,12 @@ static void JsonAnomalyLogDeInitCtxSub(OutputCtx *output_ctx) 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; @@ -370,15 +370,14 @@ static void SetFlag(const ConfNode *conf, const char *name, uint16_t flag, uint1 } } -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); @@ -401,7 +400,7 @@ static void JsonAnomalyLogConf(AnomalyJsonOutputCtx *json_output_ctx, 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; @@ -437,7 +436,7 @@ error: * \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()) { diff --git a/src/output-json-common.c b/src/output-json-common.c index 1ec08b6905..3ac80774b4 100644 --- a/src/output-json-common.c +++ b/src/output-json-common.c @@ -79,7 +79,7 @@ int OutputJsonLogFlush(ThreadVars *tv, void *thread_data, const Packet *p) return 0; } -OutputInitResult OutputJsonLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) +OutputInitResult OutputJsonLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx) { OutputInitResult result = { NULL, false }; diff --git a/src/output-json-dcerpc.c b/src/output-json-dcerpc.c index 7011bd7931..25ae0f0c38 100644 --- a/src/output-json-dcerpc.c +++ b/src/output-json-dcerpc.c @@ -57,7 +57,7 @@ error: 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); diff --git a/src/output-json-dhcp.c b/src/output-json-dhcp.c index b2bccc7999..fd92931099 100644 --- a/src/output-json-dhcp.c +++ b/src/output-json-dhcp.c @@ -86,8 +86,7 @@ static void OutputDHCPLogDeInitCtxSub(OutputCtx *output_ctx) SCFree(output_ctx); } -static OutputInitResult OutputDHCPLogInitSub(ConfNode *conf, - OutputCtx *parent_ctx) +static OutputInitResult OutputDHCPLogInitSub(SCConfNode *conf, OutputCtx *parent_ctx) { OutputInitResult result = { NULL, false }; diff --git a/src/output-json-dnp3.c b/src/output-json-dnp3.c index ea557ff206..32a70bd66c 100644 --- a/src/output-json-dnp3.c +++ b/src/output-json-dnp3.c @@ -294,7 +294,7 @@ static void OutputDNP3LogDeInitCtxSub(OutputCtx *output_ctx) 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; diff --git a/src/output-json-dns.c b/src/output-json-dns.c index cb60a4509a..87d2f87cb5 100644 --- a/src/output-json-dns.c +++ b/src/output-json-dns.c @@ -489,13 +489,12 @@ static void LogDnsLogDeInitCtxSub(OutputCtx *output_ctx) 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; @@ -504,9 +503,9 @@ static void JsonDnsLogParseConfig(LogDnsFileCtx *dnslog_ctx, ConfNode *conf, 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; @@ -515,10 +514,10 @@ static void JsonDnsLogParseConfig(LogDnsFileCtx *dnslog_ctx, ConfNode *conf, 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++) { @@ -533,14 +532,14 @@ static void JsonDnsLogParseConfig(LogDnsFileCtx *dnslog_ctx, ConfNode *conf, } } -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; } @@ -561,7 +560,7 @@ static uint8_t GetDnsLogVersion(ConfNode *conf) 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); @@ -593,17 +592,17 @@ static uint8_t JsonDnsCheckVersion(ConfNode *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; @@ -626,11 +625,11 @@ static void JsonDnsLogInitFilters(LogDnsFileCtx *dnslog_ctx, ConfNode *conf) } } -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; } diff --git a/src/output-json-drop.c b/src/output-json-drop.c index 79e663c437..a464ceabfb 100644 --- a/src/output-json-drop.c +++ b/src/output-json-drop.c @@ -257,7 +257,7 @@ static void JsonDropLogDeInitCtxSub(OutputCtx *output_ctx) 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) { @@ -279,13 +279,13 @@ static OutputInitResult JsonDropLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ } 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; @@ -296,9 +296,9 @@ static OutputInitResult JsonDropLogInitCtxSub(ConfNode *conf, OutputCtx *parent_ "'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; } } diff --git a/src/output-json-email-common.c b/src/output-json-email-common.c index b5951d3581..80aab4651e 100644 --- a/src/output-json-email-common.c +++ b/src/output-json-email-common.c @@ -201,21 +201,21 @@ bool EveEmailAddMetadata(const Flow *f, uint64_t tx_id, JsonBuilder *js) 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) { @@ -230,9 +230,9 @@ void OutputEmailInitConf(ConfNode *conf, OutputJsonEmailCtx *email_ctx) } 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"); diff --git a/src/output-json-email-common.h b/src/output-json-email-common.h index 6b62e28108..0c48150244 100644 --- a/src/output-json-email-common.h +++ b/src/output-json-email-common.h @@ -38,6 +38,6 @@ typedef struct JsonEmailLogThread_ { 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 */ diff --git a/src/output-json-file.c b/src/output-json-file.c index e1f3389380..351b5dddfd 100644 --- a/src/output-json-file.c +++ b/src/output-json-file.c @@ -299,7 +299,7 @@ static void OutputFileLogDeinitSub(OutputCtx *output_ctx) * \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; @@ -315,14 +315,14 @@ static OutputInitResult OutputFileLogInitSub(ConfNode *conf, OutputCtx *parent_c } 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"); } @@ -330,7 +330,7 @@ static OutputInitResult OutputFileLogInitSub(ConfNode *conf, OutputCtx *parent_c 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); diff --git a/src/output-json-frame.c b/src/output-json-frame.c index 3ae80b820f..c8bbcfa8f1 100644 --- a/src/output-json-frame.c +++ b/src/output-json-frame.c @@ -506,7 +506,7 @@ static void JsonFrameLogDeInitCtxSub(OutputCtx *output_ctx) * \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; @@ -523,7 +523,7 @@ static OutputInitResult JsonFrameLogInitCtxSub(ConfNode *conf, OutputCtx *parent 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) { diff --git a/src/output-json-http.c b/src/output-json-http.c index ede4835742..78da8f6c8d 100644 --- a/src/output-json-http.c +++ b/src/output-json-http.c @@ -522,7 +522,7 @@ static void OutputHttpLogDeinitSub(OutputCtx *output_ctx) 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; @@ -542,15 +542,15 @@ static OutputInitResult OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_c 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; @@ -561,13 +561,13 @@ static OutputInitResult OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_c 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++) { @@ -581,7 +581,7 @@ static OutputInitResult OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_c } } - 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); diff --git a/src/output-json-ike.c b/src/output-json-ike.c index a13ef0e1d9..3380a804a2 100644 --- a/src/output-json-ike.c +++ b/src/output-json-ike.c @@ -107,7 +107,7 @@ static void OutputIKELogDeInitCtxSub(OutputCtx *output_ctx) 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; @@ -125,9 +125,9 @@ static OutputInitResult OutputIKELogInitSub(ConfNode *conf, OutputCtx *parent_ct } 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; } } diff --git a/src/output-json-mqtt.c b/src/output-json-mqtt.c index 9ddef80de9..a7f20000a2 100644 --- a/src/output-json-mqtt.c +++ b/src/output-json-mqtt.c @@ -102,11 +102,11 @@ static void OutputMQTTLogDeInitCtxSub(OutputCtx *output_ctx) 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; @@ -115,7 +115,7 @@ static void JsonMQTTLogParseConfig(ConfNode *conf, LogMQTTFileCtx *mqttlog_ctx) 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); @@ -125,8 +125,7 @@ static void JsonMQTTLogParseConfig(ConfNode *conf, LogMQTTFileCtx *mqttlog_ctx) 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; diff --git a/src/output-json-nfs.c b/src/output-json-nfs.c index 0b08c0e510..a00f503055 100644 --- a/src/output-json-nfs.c +++ b/src/output-json-nfs.c @@ -99,8 +99,7 @@ static int JsonNFSLogger(ThreadVars *tv, void *thread_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); diff --git a/src/output-json-pgsql.c b/src/output-json-pgsql.c index 9cba28d25d..2ba6ea4341 100644 --- a/src/output-json-pgsql.c +++ b/src/output-json-pgsql.c @@ -97,13 +97,13 @@ static void OutputPgsqlLogDeInitCtxSub(OutputCtx *output_ctx) 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; @@ -113,7 +113,7 @@ static void JsonPgsqlLogParseConfig(ConfNode *conf, OutputPgsqlCtx *pgsqllog_ctx } } -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; @@ -184,7 +184,7 @@ static TmEcode JsonPgsqlLogThreadDeinit(ThreadVars *t, void *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; } diff --git a/src/output-json-smb.c b/src/output-json-smb.c index 2b74b051dd..73646ad57c 100644 --- a/src/output-json-smb.c +++ b/src/output-json-smb.c @@ -69,7 +69,7 @@ error: 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); diff --git a/src/output-json-smtp.c b/src/output-json-smtp.c index 592645cb3c..0f374df287 100644 --- a/src/output-json-smtp.c +++ b/src/output-json-smtp.c @@ -117,7 +117,7 @@ static void OutputSmtpLogDeInitCtxSub(OutputCtx *output_ctx) 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; diff --git a/src/output-json-stats.c b/src/output-json-stats.c index 7b532d77ee..bdcaa10d48 100644 --- a/src/output-json-stats.c +++ b/src/output-json-stats.c @@ -421,7 +421,7 @@ static void OutputStatsLogDeinitSub(OutputCtx *output_ctx) 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; @@ -447,29 +447,29 @@ static OutputInitResult OutputStatsLogInitSub(ConfNode *conf, OutputCtx *parent_ 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); diff --git a/src/output-json-tls.c b/src/output-json-tls.c index c4ba0e249e..eb5aff6436 100644 --- a/src/output-json-tls.c +++ b/src/output-json-tls.c @@ -550,7 +550,7 @@ static TmEcode JsonTlsLogThreadDeinit(ThreadVars *t, void *data) 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)) @@ -562,17 +562,17 @@ static OutputTlsCtx *OutputTlsInitCtx(ConfNode *conf) 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; @@ -591,8 +591,8 @@ static OutputTlsCtx *OutputTlsInitCtx(ConfNode *conf) } } - 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; } @@ -631,7 +631,7 @@ static void OutputTlsLogDeinitSub(OutputCtx *output_ctx) 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; diff --git a/src/output-json.c b/src/output-json.c index 72bf2b9772..a571b89fa0 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -1057,7 +1057,7 @@ static inline enum LogFileType FileTypeFromConf(const char *typestr) } 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 || @@ -1070,7 +1070,7 @@ static int LogFileTypePrepare( #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); @@ -1113,7 +1113,7 @@ static int LogFileTypePrepare( * \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; @@ -1126,13 +1126,13 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) /* 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(); @@ -1159,10 +1159,10 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) 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); @@ -1175,7 +1175,7 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) 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); @@ -1188,8 +1188,8 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) } /* 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 { @@ -1199,7 +1199,7 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) 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, " @@ -1209,8 +1209,8 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) } /* 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 { @@ -1218,8 +1218,8 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) } /* 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 { @@ -1227,14 +1227,14 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) } /* 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) @@ -1246,7 +1246,7 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) } /* 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)) { @@ -1254,8 +1254,8 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf) } } - 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); } diff --git a/src/output-json.h b/src/output-json.h index 82989a1156..20f8945540 100644 --- a/src/output-json.h +++ b/src/output-json.h @@ -106,9 +106,9 @@ JsonBuilder *CreateEveHeaderWithTxId(const Packet *p, enum OutputJsonLogDirectio 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); diff --git a/src/output-lua.c b/src/output-lua.c index ad2a8fffc1..e7438c6d36 100644 --- a/src/output-lua.c +++ b/src/output-lua.c @@ -620,7 +620,7 @@ static void LogLuaSubFree(OutputCtx *oc) { * * 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) @@ -691,14 +691,14 @@ static void LogLuaMasterFree(OutputCtx *oc) * 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"); @@ -719,12 +719,12 @@ static OutputInitResult OutputLuaLogInit(ConfNode *conf) 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)); } @@ -732,7 +732,7 @@ static OutputInitResult OutputLuaLogInit(ConfNode *conf) 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; @@ -832,7 +832,7 @@ error: 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) { diff --git a/src/output.c b/src/output.c index ffe939d16c..2af4e4acb9 100644 --- a/src/output.c +++ b/src/output.c @@ -1142,7 +1142,7 @@ void OutputRegisterLoggers(void) /* 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, diff --git a/src/output.h b/src/output.h index bc8086fc4a..9ab3d1bc27 100644 --- a/src/output.h +++ b/src/output.h @@ -48,8 +48,8 @@ typedef struct OutputInitResult_ { 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); diff --git a/src/reputation.c b/src/reputation.c index 417b60a524..c0077fe0b2 100644 --- a/src/reputation.c +++ b/src/reputation.c @@ -524,7 +524,7 @@ static char *SRepCompleteFilePath(char *file) /* 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); @@ -565,8 +565,8 @@ static char *SRepCompleteFilePath(char *file) */ int SRepInit(DetectEngineCtx *de_ctx) { - ConfNode *files; - ConfNode *file = NULL; + SCConfNode *files; + SCConfNode *file = NULL; const char *filename = NULL; int init = 0; @@ -587,8 +587,8 @@ int SRepInit(DetectEngineCtx *de_ctx) } /* 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; diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index 3315aac173..cfb87ed295 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -72,13 +72,13 @@ static bool AFPRunModeIsIPS(void) 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); @@ -86,7 +86,7 @@ static bool AFPRunModeIsIPS(void) 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( @@ -99,8 +99,8 @@ static bool AFPRunModeIsIPS(void) 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 { @@ -174,9 +174,9 @@ static int cluster_id_auto = 1; 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; @@ -222,7 +222,7 @@ static void *ParseAFPConfig(const char *iface) #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; @@ -246,7 +246,7 @@ static void *ParseAFPConfig(const char *iface) 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) { @@ -263,7 +263,7 @@ static void *ParseAFPConfig(const char *iface) } } - 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; @@ -278,19 +278,19 @@ static void *ParseAFPConfig(const char *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", @@ -308,7 +308,7 @@ static void *ParseAFPConfig(const char *iface) } } - 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); @@ -333,7 +333,7 @@ static void *ParseAFPConfig(const char *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) { @@ -343,7 +343,7 @@ static void *ParseAFPConfig(const char *iface) 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"; } @@ -365,7 +365,7 @@ static void *ParseAFPConfig(const char *iface) 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; @@ -402,7 +402,7 @@ static void *ParseAFPConfig(const char *iface) } 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); @@ -414,7 +414,7 @@ static void *ParseAFPConfig(const char *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 @@ -426,15 +426,14 @@ static void *ParseAFPConfig(const char *iface) #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; @@ -460,7 +459,7 @@ static void *ParseAFPConfig(const char *iface) } #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 @@ -469,7 +468,7 @@ static void *ParseAFPConfig(const char *iface) 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); @@ -495,14 +494,14 @@ static void *ParseAFPConfig(const char *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; @@ -526,7 +525,7 @@ static void *ParseAFPConfig(const char *iface) #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")) { @@ -542,7 +541,7 @@ static void *ParseAFPConfig(const char *iface) } 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); @@ -572,10 +571,11 @@ static void *ParseAFPConfig(const char *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 { @@ -596,16 +596,16 @@ static void *ParseAFPConfig(const char *iface) #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()); @@ -614,13 +614,13 @@ static void *ParseAFPConfig(const char *iface) } } - 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()); @@ -629,18 +629,18 @@ static void *ParseAFPConfig(const char *iface) } } - (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; @@ -790,7 +790,7 @@ int RunModeIdsAFPAutoFp(void) TimeModeSetLive(); - (void)ConfGet("af-packet.live-interface", &live_dev); + (void)SCConfGet("af-packet.live-interface", &live_dev); SCLogDebug("live_dev %s", live_dev); @@ -827,7 +827,7 @@ int RunModeIdsAFPSingle(void) 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."); @@ -868,7 +868,7 @@ int RunModeIdsAFPWorkers(void) 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."); diff --git a/src/runmode-af-xdp.c b/src/runmode-af-xdp.c index 8eebfeb89a..cfcea80b66 100644 --- a/src/runmode-af-xdp.c +++ b/src/runmode-af-xdp.c @@ -156,9 +156,9 @@ static TmEcode ConfigSetThreads(AFXDPIfaceConfig *aconf, const char *entry_str) 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; @@ -186,7 +186,7 @@ static void *ParseAFXDPConfig(const char *iface) 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; @@ -210,7 +210,7 @@ static void *ParseAFXDPConfig(const char *iface) /* 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; @@ -220,7 +220,7 @@ static void *ParseAFXDPConfig(const char *iface) (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; @@ -228,7 +228,7 @@ static void *ParseAFXDPConfig(const char *iface) #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) { @@ -240,7 +240,7 @@ static void *ParseAFXDPConfig(const char *iface) } /* 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) { @@ -252,28 +252,29 @@ static void *ParseAFXDPConfig(const char *iface) } /* 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; @@ -281,12 +282,12 @@ static void *ParseAFXDPConfig(const char *iface) } /* 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; } @@ -329,7 +330,7 @@ int RunModeIdsAFXDPSingle(void) 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."); @@ -363,7 +364,7 @@ int RunModeIdsAFXDPWorkers(void) 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."); diff --git a/src/runmode-dpdk.c b/src/runmode-dpdk.c index ee0665d27d..37b333937a 100644 --- a/src/runmode-dpdk.c +++ b/src/runmode-dpdk.c @@ -290,8 +290,8 @@ static void InitEal(void) { 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; @@ -303,9 +303,9 @@ static void InitEal(void) 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); } @@ -849,8 +849,8 @@ static int ConfigLoad(DPDKIfaceConfig *iconf, const char *iface) { 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; @@ -865,19 +865,19 @@ static int ConfigLoad(DPDKIfaceConfig *iconf, const char *iface) 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 { @@ -887,12 +887,12 @@ static int ConfigLoad(DPDKIfaceConfig *iconf, const char *iface) 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) @@ -901,7 +901,7 @@ static int ConfigLoad(DPDKIfaceConfig *iconf, const char *iface) 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) @@ -927,54 +927,54 @@ static int ConfigLoad(DPDKIfaceConfig *iconf, const char *iface) 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) @@ -982,7 +982,7 @@ static int ConfigLoad(DPDKIfaceConfig *iconf, const char *iface) 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); @@ -990,14 +990,14 @@ static int ConfigLoad(DPDKIfaceConfig *iconf, const char *iface) 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; @@ -1848,13 +1848,13 @@ static int DPDKRunModeIsIPS(void) { /* 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; @@ -1863,7 +1863,7 @@ static int DPDKRunModeIsIPS(void) 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); @@ -1873,8 +1873,8 @@ static int DPDKRunModeIsIPS(void) 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 { diff --git a/src/runmode-erf-file.c b/src/runmode-erf-file.c index ee56341bad..39ff305efd 100644 --- a/src/runmode-erf-file.c +++ b/src/runmode-erf-file.c @@ -53,7 +53,7 @@ int RunModeErfFileSingle(void) SCEnter(); - if (ConfGet("erf-file.file", &file) == 0) { + if (SCConfGet("erf-file.file", &file) == 0) { FatalError("Failed to get erf-file.file from config."); } @@ -110,7 +110,7 @@ int RunModeErfFileAutoFp(void) 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"); } diff --git a/src/runmode-netmap.c b/src/runmode-netmap.c index 26fc2c4546..4c1e913e81 100644 --- a/src/runmode-netmap.c +++ b/src/runmode-netmap.c @@ -61,19 +61,19 @@ static int NetmapRunModeIsIPS(void) { 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); @@ -81,7 +81,7 @@ static int NetmapRunModeIsIPS(void) 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) { @@ -93,8 +93,8 @@ static int NetmapRunModeIsIPS(void) 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 { @@ -150,8 +150,8 @@ static void NetmapDerefConfig(void *conf) } } -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; @@ -198,7 +198,7 @@ static int ParseNetmapSettings(NetmapIfaceSettings *ns, const char *iface, } 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 { @@ -217,21 +217,21 @@ static int ParseNetmapSettings(NetmapIfaceSettings *ns, const char *iface, 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); @@ -239,7 +239,7 @@ static int ParseNetmapSettings(NetmapIfaceSettings *ns, const char *iface, } const char *copymodestr; - if (ConfGetChildValueWithDefault(if_root, if_default, + if (SCConfGetChildValueWithDefault(if_root, if_default, "copy-mode", ©modestr) == 1) { if (strcmp(copymodestr, "ips") == 0) { @@ -283,8 +283,8 @@ finalize: */ 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) { @@ -302,7 +302,7 @@ static void *ParseNetmapConfig(const char *iface_name) (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 { @@ -315,7 +315,7 @@ static void *ParseNetmapConfig(const char *iface_name) /* 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); @@ -383,7 +383,7 @@ static int NetmapRunModeInit(NetmapRunMode_t runmode) 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; diff --git a/src/runmode-nflog.c b/src/runmode-nflog.c index cc92a0e803..57624d7eaf 100644 --- a/src/runmode-nflog.c +++ b/src/runmode-nflog.c @@ -44,9 +44,9 @@ static void NflogDerefConfig(void *data) 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; @@ -63,16 +63,16 @@ static void *ParseNflogConfig(const char *group) } 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 " @@ -88,8 +88,7 @@ static void *ParseNflogConfig(const char *group) 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; @@ -99,8 +98,8 @@ static void *ParseNflogConfig(const char *group) 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; @@ -116,8 +115,8 @@ static void *ParseNflogConfig(const char *group) 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; @@ -127,8 +126,7 @@ static void *ParseNflogConfig(const char *group) return NULL; } - boolval = ConfGetChildValueIntWithDefault(group_root, group_default, - "qtimeout", &qtimeout); + boolval = SCConfGetChildValueIntWithDefault(group_root, group_default, "qtimeout", &qtimeout); if (boolval) nflogconf->qtimeout = qtimeout; diff --git a/src/runmode-pcap-file.c b/src/runmode-pcap-file.c index e820eca10c..f07ae2a411 100644 --- a/src/runmode-pcap-file.c +++ b/src/runmode-pcap-file.c @@ -55,7 +55,7 @@ int RunModeFilePcapSingle(void) 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"); } @@ -125,7 +125,7 @@ int RunModeFilePcapAutoFp(void) 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); diff --git a/src/runmode-pcap.c b/src/runmode-pcap.c index 6990aabea0..374fd0233b 100644 --- a/src/runmode-pcap.c +++ b/src/runmode-pcap.c @@ -62,9 +62,9 @@ static void PcapDerefConfig(void *conf) 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; @@ -86,7 +86,7 @@ static void *ParsePcapConfig(const char *iface) 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; @@ -100,7 +100,7 @@ static void *ParsePcapConfig(const char *iface) 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; } @@ -109,7 +109,7 @@ static void *ParsePcapConfig(const char *iface) 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; @@ -132,7 +132,7 @@ static void *ParsePcapConfig(const char *iface) 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) { @@ -152,7 +152,7 @@ static void *ParsePcapConfig(const char *iface) 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; @@ -176,7 +176,7 @@ static void *ParsePcapConfig(const char *iface) 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; @@ -185,12 +185,12 @@ static void *ParsePcapConfig(const char *iface) 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); @@ -198,14 +198,14 @@ static void *ParsePcapConfig(const char *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"); @@ -234,7 +234,7 @@ int RunModeIdsPcapSingle(void) TimeModeSetLive(); - (void)ConfGet("pcap.single-pcap-dev", &live_dev); + (void)SCConfGet("pcap.single-pcap-dev", &live_dev); ret = RunModeSetLiveCaptureSingle(ParsePcapConfig, PcapConfigGeThreadsCount, @@ -273,7 +273,7 @@ int RunModeIdsPcapAutoFp(void) 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); @@ -300,7 +300,7 @@ int RunModeIdsPcapWorkers(void) 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); diff --git a/src/runmode-unittests.c b/src/runmode-unittests.c index 6e49c24f8d..634c918435 100644 --- a/src/runmode-unittests.c +++ b/src/runmode-unittests.c @@ -165,8 +165,8 @@ static void RegisterUnittests(void) DecodeMPLSRegisterTests(); DecodeNSHRegisterTests(); AppLayerProtoDetectUnittestsRegister(); - ConfRegisterTests(); - ConfYamlRegisterTests(); + SCConfRegisterTests(); + SCConfYamlRegisterTests(); TmqhFlowRegisterTests(); FlowRegisterTests(); HostRegisterUnittests(); diff --git a/src/runmode-unix-socket.c b/src/runmode-unix-socket.c index 3c390e99a6..c07a2a475d 100644 --- a/src/runmode-unix-socket.c +++ b/src/runmode-unix-socket.c @@ -469,7 +469,7 @@ static TmEcode UnixSocketPcapFilesCheck(void *data) 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; @@ -477,9 +477,9 @@ static TmEcode UnixSocketPcapFilesCheck(void *data) 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"); @@ -487,9 +487,9 @@ static TmEcode UnixSocketPcapFilesCheck(void *data) 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"); @@ -500,7 +500,7 @@ static TmEcode UnixSocketPcapFilesCheck(void *data) 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; @@ -510,7 +510,7 @@ static TmEcode UnixSocketPcapFilesCheck(void *data) 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; @@ -520,7 +520,7 @@ static TmEcode UnixSocketPcapFilesCheck(void *data) 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; @@ -530,7 +530,7 @@ static TmEcode UnixSocketPcapFilesCheck(void *data) } 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; @@ -1035,10 +1035,10 @@ TmEcode UnixSocketRegisterTenant(json_t *cmd, json_t* answer, void *data) 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; diff --git a/src/runmodes.c b/src/runmodes.c index 897aba6d37..398dc3fd6f 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -287,7 +287,7 @@ static const char *RunModeGetConfOrDefault(int capture_mode, const char *capture { 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; @@ -651,15 +651,16 @@ static void SetupOutput( } } -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]; @@ -673,11 +674,10 @@ static void RunModeInitializeEveOutput(ConfNode *conf, OutputCtx *parent_ctx, Lo 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; } } @@ -717,19 +717,20 @@ static void RunModeInitializeEveOutput(ConfNode *conf, OutputCtx *parent_ctx, Lo } } -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) { @@ -757,13 +758,13 @@ extern bool g_filedata_logger_enabled; */ 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; @@ -773,7 +774,7 @@ void RunModeInitializeOutputs(void) 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); @@ -783,8 +784,8 @@ void RunModeInitializeOutputs(void) 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; } @@ -866,7 +867,7 @@ void RunModeInitializeOutputs(void) 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) { @@ -943,7 +944,7 @@ float threading_detect_ratio = 1; 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; @@ -953,8 +954,8 @@ void RunModeInitializeThreadSettings(void) 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; } @@ -966,7 +967,7 @@ void RunModeInitializeThreadSettings(void) * 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); diff --git a/src/source-nfq.c b/src/source-nfq.c index 9e81688e9e..a83d0362b4 100644 --- a/src/source-nfq.c +++ b/src/source-nfq.c @@ -213,7 +213,7 @@ void NFQInitConfig(bool quiet) 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)) { @@ -227,7 +227,7 @@ void NFQInitConfig(bool quiet) } } - (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"); @@ -237,27 +237,27 @@ void NFQInitConfig(bool quiet) #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."); diff --git a/src/source-pcap-file.c b/src/source-pcap-file.c index 53249e4c4b..0f124878ca 100644 --- a/src/source-pcap-file.c +++ b/src/source-pcap-file.c @@ -152,7 +152,7 @@ void PcapFileGlobalInit(void) 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); @@ -239,7 +239,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d 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); @@ -248,7 +248,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d } } - 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); @@ -263,7 +263,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d 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; } @@ -324,13 +324,13 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d 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); } @@ -345,7 +345,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d 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); @@ -356,7 +356,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d 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); @@ -373,14 +373,14 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d 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; } } diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 346ae2d58f..de0c44c448 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -472,7 +472,7 @@ int StreamTcpAppLayerIsDisabled(Flow *f) 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) { @@ -488,7 +488,7 @@ static int StreamTcpReassemblyConfig(bool quiet) 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(); } @@ -497,7 +497,7 @@ static int StreamTcpReassemblyConfig(bool quiet) } 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) { diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 02123de0c4..7b276e16ec 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -497,20 +497,20 @@ void StreamTcpInitConfig(bool quiet) 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); @@ -523,7 +523,7 @@ void StreamTcpInitConfig(bool quiet) } 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 " @@ -542,7 +542,7 @@ void StreamTcpInitConfig(bool quiet) } int imidstream; - (void)ConfGetBool("stream.midstream", &imidstream); + (void)SCConfGetBool("stream.midstream", &imidstream); stream_config.midstream = imidstream != 0; if (!quiet) { @@ -550,7 +550,7 @@ void StreamTcpInitConfig(bool 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) { @@ -559,7 +559,7 @@ void StreamTcpInitConfig(bool 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; } @@ -575,7 +575,7 @@ void StreamTcpInitConfig(bool quiet) } 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 @@ -584,7 +584,7 @@ void StreamTcpInitConfig(bool quiet) 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; } @@ -607,7 +607,7 @@ void StreamTcpInitConfig(bool quiet) } 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; } @@ -620,7 +620,7 @@ void StreamTcpInitConfig(bool quiet) } 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; } @@ -629,7 +629,7 @@ void StreamTcpInitConfig(bool quiet) } 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) { @@ -649,7 +649,7 @@ void StreamTcpInitConfig(bool quiet) } 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; @@ -668,7 +668,7 @@ void StreamTcpInitConfig(bool quiet) } } - 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 { @@ -681,7 +681,7 @@ void StreamTcpInitConfig(bool quiet) 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 { @@ -695,7 +695,7 @@ void StreamTcpInitConfig(bool quiet) } 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) { @@ -717,7 +717,7 @@ void StreamTcpInitConfig(bool quiet) } 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 " @@ -735,7 +735,7 @@ void StreamTcpInitConfig(bool quiet) } 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())) @@ -744,7 +744,7 @@ void StreamTcpInitConfig(bool quiet) 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 " @@ -759,7 +759,7 @@ void StreamTcpInitConfig(bool quiet) } 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) { @@ -781,7 +781,7 @@ void StreamTcpInitConfig(bool quiet) 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) { @@ -810,7 +810,7 @@ void StreamTcpInitConfig(bool quiet) } 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; } @@ -823,7 +823,7 @@ void StreamTcpInitConfig(bool quiet) /* 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) diff --git a/src/suricata.c b/src/suricata.c index ebd411af27..ebabf5068a 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -419,7 +419,7 @@ void GlobalsDestroy(void) MpmHSGlobalCleanup(); #endif - ConfDeInit(); + SCConfDeInit(); DetectParseFreeRegexes(); @@ -494,7 +494,7 @@ static int SetBpfString(int argc, char *argv[]) } 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; @@ -569,7 +569,7 @@ static void SetBpfStringFromFile(char *filename) 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"); } @@ -969,7 +969,7 @@ TmEcode SCLoadYamlConfig(void) 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); } @@ -977,7 +977,7 @@ TmEcode SCLoadYamlConfig(void) 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]); } } @@ -1001,7 +1001,7 @@ static TmEcode ParseInterfacesList(const int runmode, char *pcap_dev) 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); } @@ -1020,7 +1020,7 @@ static TmEcode ParseInterfacesList(const int runmode, char *pcap_dev) } 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); } @@ -1036,7 +1036,7 @@ static TmEcode ParseInterfacesList(const int runmode, char *pcap_dev) } 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); } @@ -1052,7 +1052,7 @@ static TmEcode ParseInterfacesList(const int runmode, char *pcap_dev) } 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); } @@ -1450,7 +1450,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) } 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; } @@ -1462,7 +1462,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) } 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; } @@ -1536,7 +1536,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) 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; } @@ -1545,11 +1545,10 @@ TmEcode SCParseCommandLine(int argc, char **argv) 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 " @@ -1639,7 +1638,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) #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; } @@ -1669,7 +1668,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) #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; } @@ -1741,30 +1740,30 @@ TmEcode SCParseCommandLine(int argc, char **argv) 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; } @@ -1834,7 +1833,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) 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; } @@ -1968,7 +1967,7 @@ TmEcode SCParseCommandLine(int argc, char **argv) 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; } @@ -2114,7 +2113,7 @@ static int MayDaemonize(SCInstance *suri) 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; @@ -2159,11 +2158,11 @@ static int InitRunAs(SCInstance *suri) 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; } @@ -2189,7 +2188,7 @@ static int InitSignalHandler(SCInstance *suri) 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; } @@ -2391,13 +2390,14 @@ static void SetupDelayedDetect(SCInstance *suri) 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); } } } @@ -2427,7 +2427,7 @@ static int ConfigGetCaptureValue(SCInstance *suri) /* 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. " @@ -2443,7 +2443,7 @@ static int ConfigGetCaptureValue(SCInstance *suri) /* 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; @@ -2544,10 +2544,10 @@ void PostConfLoadedDetectSetup(SCInstance *suri) 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."); @@ -2578,7 +2578,7 @@ static void PostConfLoadedSetupHostMode(void) { 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")) { @@ -2636,7 +2636,7 @@ int PostConfLoadedSetup(SCInstance *suri) 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(); @@ -2646,7 +2646,7 @@ int PostConfLoadedSetup(SCInstance *suri) 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) { @@ -2656,15 +2656,15 @@ int PostConfLoadedSetup(SCInstance *suri) } 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(); @@ -2698,9 +2698,9 @@ int PostConfLoadedSetup(SCInstance *suri) 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; } } @@ -2714,14 +2714,13 @@ int PostConfLoadedSetup(SCInstance *suri) /* 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); } @@ -2737,7 +2736,7 @@ int PostConfLoadedSetup(SCInstance *suri) 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."); @@ -2781,7 +2780,7 @@ int PostConfLoadedSetup(SCInstance *suri) /* 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\" " @@ -2801,7 +2800,7 @@ int PostConfLoadedSetup(SCInstance *suri) 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); @@ -2888,7 +2887,7 @@ int InitGlobal(void) RunModeRegisterRunModes(); /* Initialize the configuration module. */ - ConfInit(); + SCConfInit(); DatalinkTableInit(); VarNameStoreInit(); @@ -2914,21 +2913,21 @@ void SuricataInit(void) 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; } @@ -3015,7 +3014,7 @@ void SuricataPostInit(void) } int limit_nproc = 0; - if (ConfGetBool("security.limit-noproc", &limit_nproc) == 0) { + if (SCConfGetBool("security.limit-noproc", &limit_nproc) == 0) { limit_nproc = 0; } diff --git a/src/tests/detect-http-client-body.c b/src/tests/detect-http-client-body.c index 707c7492cb..85544f9df3 100644 --- a/src/tests/detect-http-client-body.c +++ b/src/tests/detect-http-client-body.c @@ -125,11 +125,11 @@ static int RunTest (struct TestSteps *steps, const char *sig, const char *yaml) memset(&ssn, 0, sizeof(ssn)); if (yaml) { - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); HtpConfigCreateBackup(); - ConfYamlLoadString(yaml, strlen(yaml)); + SCConfYamlLoadString(yaml, strlen(yaml)); HTPConfigure(); } @@ -190,7 +190,7 @@ static int RunTest (struct TestSteps *steps, const char *sig, const char *yaml) if (yaml) { HtpConfigRestoreBackup(); - ConfRestoreContextBackup(); + SCConfRestoreContextBackup(); } PASS; } diff --git a/src/tests/detect-http-server-body.c b/src/tests/detect-http-server-body.c index 63a1111477..a12ac28b82 100644 --- a/src/tests/detect-http-server-body.c +++ b/src/tests/detect-http-server-body.c @@ -86,11 +86,11 @@ static int RunTest(struct TestSteps *steps, const char *sig, const char *yaml) memset(&ssn, 0, sizeof(ssn)); if (yaml) { - ConfCreateContextBackup(); - ConfInit(); + SCConfCreateContextBackup(); + SCConfInit(); HtpConfigCreateBackup(); - ConfYamlLoadString(yaml, strlen(yaml)); + SCConfYamlLoadString(yaml, strlen(yaml)); HTPConfigure(); EngineModeSetIPS(); } @@ -152,7 +152,7 @@ static int RunTest(struct TestSteps *steps, const char *sig, const char *yaml) if (yaml) { HtpConfigRestoreBackup(); - ConfRestoreContextBackup(); + SCConfRestoreContextBackup(); EngineModeSetIDS(); } PASS; diff --git a/src/tests/detect.c b/src/tests/detect.c index be6fb91305..0baf2fc822 100644 --- a/src/tests/detect.c +++ b/src/tests/detect.c @@ -943,9 +943,9 @@ static int SigTest15 (void) 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) { @@ -974,8 +974,8 @@ static int SigTest15 (void) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); return result; } @@ -995,9 +995,9 @@ static int SigTest16 (void) 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) { @@ -1024,8 +1024,8 @@ static int SigTest16 (void) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); UTHFreePackets(&p, 1); return result; } @@ -1048,9 +1048,9 @@ static int SigTest17 (void) 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); @@ -1071,8 +1071,8 @@ static int SigTest17 (void) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); UTHFreePackets(&p, 1); PASS; @@ -1154,9 +1154,9 @@ static int SigTest19 (void) 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) { @@ -1184,8 +1184,8 @@ static int SigTest19 (void) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); return result; } @@ -1214,9 +1214,9 @@ static int SigTest20 (void) 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) { @@ -1245,8 +1245,8 @@ static int SigTest20 (void) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); return result; } @@ -4789,9 +4789,9 @@ static int DetectAddressYamlParsing01 (void) { 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) { @@ -4811,8 +4811,8 @@ static int DetectAddressYamlParsing01 (void) DetectEngineCtxFree(de_ctx); end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); return result; } @@ -4836,9 +4836,9 @@ static int DetectAddressYamlParsing02 (void) { 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) { @@ -4858,8 +4858,8 @@ static int DetectAddressYamlParsing02 (void) DetectEngineCtxFree(de_ctx); end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); return result; } @@ -4883,9 +4883,9 @@ static int DetectAddressYamlParsing03 (void) { 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) { @@ -4905,8 +4905,8 @@ static int DetectAddressYamlParsing03 (void) DetectEngineCtxFree(de_ctx); end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); return result; } @@ -4931,9 +4931,9 @@ static int DetectAddressYamlParsing04 (void) { 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) { @@ -4953,8 +4953,8 @@ static int DetectAddressYamlParsing04 (void) DetectEngineCtxFree(de_ctx); end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); return result; } diff --git a/src/tests/fuzz/fuzz_applayerparserparse.c b/src/tests/fuzz/fuzz_applayerparserparse.c index c4a9aa1344..759dcd371f 100644 --- a/src/tests/fuzz/fuzz_applayerparserparse.c +++ b/src/tests/fuzz/fuzz_applayerparserparse.c @@ -72,7 +72,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 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(); } diff --git a/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c b/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c index e5fb8f6ade..7233c61ad9 100644 --- a/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c +++ b/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c @@ -32,7 +32,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) //global init InitGlobal(); SCRunmodeSet(RUNMODE_UNITTEST); - if (ConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) { + if (SCConfYamlLoadString(configNoChecksum, strlen(configNoChecksum)) != 0) { abort(); } MpmTableSetup(); diff --git a/src/tests/fuzz/fuzz_confyamlloadstring.c b/src/tests/fuzz/fuzz_confyamlloadstring.c index 4e9e7335ac..8decbb4494 100644 --- a/src/tests/fuzz/fuzz_confyamlloadstring.c +++ b/src/tests/fuzz/fuzz_confyamlloadstring.c @@ -1,10 +1,9 @@ /** * @file * @author Philippe Antoine - * fuzz target for ConfYamlLoadString + * fuzz target for SCConfYamlLoadString */ - #include "suricata-common.h" #include "suricata.h" #include "conf-yaml-loader.h" @@ -25,7 +24,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) initialized = 1; } - ConfYamlLoadString((const char *) data, size); + SCConfYamlLoadString((const char *)data, size); return 0; } diff --git a/src/tests/fuzz/fuzz_decodepcapfile.c b/src/tests/fuzz/fuzz_decodepcapfile.c index 20fbeb8c4d..886f8285a5 100644 --- a/src/tests/fuzz/fuzz_decodepcapfile.c +++ b/src/tests/fuzz/fuzz_decodepcapfile.c @@ -48,7 +48,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 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(); } diff --git a/src/tests/fuzz/fuzz_mimedecparseline.c b/src/tests/fuzz/fuzz_mimedecparseline.c index da0d350c49..9331c65693 100644 --- a/src/tests/fuzz/fuzz_mimedecparseline.c +++ b/src/tests/fuzz/fuzz_mimedecparseline.c @@ -1,10 +1,9 @@ /** * @file * @author Philippe Antoine - * fuzz target for ConfYamlLoadString + * fuzz target for SCConfYamlLoadString */ - #include "suricata-common.h" #include "suricata.h" #include "rust.h" diff --git a/src/tests/fuzz/fuzz_predefpcap_aware.c b/src/tests/fuzz/fuzz_predefpcap_aware.c index e04d6aef3e..74c7dab8d4 100644 --- a/src/tests/fuzz/fuzz_predefpcap_aware.c +++ b/src/tests/fuzz/fuzz_predefpcap_aware.c @@ -73,7 +73,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 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(); } surifuzz.sig_file = malloc(strlen(filepath) + strlen("/fuzz.rules") + 1); diff --git a/src/tests/fuzz/fuzz_sigpcap.c b/src/tests/fuzz/fuzz_sigpcap.c index 06e26ccc94..6b2efae327 100644 --- a/src/tests/fuzz/fuzz_sigpcap.c +++ b/src/tests/fuzz/fuzz_sigpcap.c @@ -67,7 +67,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 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 @@ -103,7 +103,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) break; } } - if (ConfYamlLoadString(data, pos) != 0) { + if (SCConfYamlLoadString(data, pos) != 0) { return 0; } if (pos < size) { diff --git a/src/tests/fuzz/fuzz_sigpcap_aware.c b/src/tests/fuzz/fuzz_sigpcap_aware.c index 3c564f25f7..05be5813ab 100644 --- a/src/tests/fuzz/fuzz_sigpcap_aware.c +++ b/src/tests/fuzz/fuzz_sigpcap_aware.c @@ -92,7 +92,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 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 diff --git a/src/tests/stream-tcp.c b/src/tests/stream-tcp.c index aad79597f7..1b897248ed 100644 --- a/src/tests/stream-tcp.c +++ b/src/tests/stream-tcp.c @@ -1074,7 +1074,7 @@ static const char *StreamTcpParseOSPolicy(char *conf_var_name) 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; } @@ -1124,9 +1124,9 @@ static int StreamTcpTest14(void) 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); @@ -1242,8 +1242,8 @@ static int StreamTcpTest14(void) ret = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); FLOW_DESTROY(&f); StreamTcpUTDeinit(stt.ra_ctx); @@ -1514,9 +1514,9 @@ static int StreamTcpTest15(void) 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); @@ -1632,8 +1632,8 @@ static int StreamTcpTest15(void) ret = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); FLOW_DESTROY(&f); StreamTcpUTDeinit(stt.ra_ctx); @@ -1676,9 +1676,9 @@ static int StreamTcpTest16(void) 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); @@ -1794,8 +1794,8 @@ static int StreamTcpTest16(void) ret = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); FLOW_DESTROY(&f); StreamTcpUTDeinit(stt.ra_ctx); @@ -1839,9 +1839,9 @@ static int StreamTcpTest17(void) 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); @@ -1957,8 +1957,8 @@ static int StreamTcpTest17(void) ret = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); FLOW_DESTROY(&f); StreamTcpUTDeinit(stt.ra_ctx); @@ -1987,9 +1987,9 @@ static int StreamTcpTest18(void) 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); @@ -2006,8 +2006,8 @@ static int StreamTcpTest18(void) ret = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); StreamTcpUTDeinit(stt.ra_ctx); return ret; @@ -2034,9 +2034,9 @@ static int StreamTcpTest19(void) 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); @@ -2056,8 +2056,8 @@ static int StreamTcpTest19(void) ret = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); StreamTcpUTDeinit(stt.ra_ctx); return ret; @@ -2084,9 +2084,9 @@ static int StreamTcpTest20(void) 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); @@ -2106,8 +2106,8 @@ static int StreamTcpTest20(void) ret = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); StreamTcpUTDeinit(stt.ra_ctx); return ret; @@ -2134,9 +2134,9 @@ static int StreamTcpTest21(void) 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); @@ -2156,8 +2156,8 @@ static int StreamTcpTest21(void) ret = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); StreamTcpUTDeinit(stt.ra_ctx); return ret; @@ -2184,9 +2184,9 @@ static int StreamTcpTest22(void) 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); @@ -2206,8 +2206,8 @@ static int StreamTcpTest22(void) ret = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCFree(p); StreamTcpUTDeinit(stt.ra_ctx); return ret; diff --git a/src/tmqh-flow.c b/src/tmqh-flow.c index 6ce4f29795..fa5d924352 100644 --- a/src/tmqh-flow.c +++ b/src/tmqh-flow.c @@ -57,7 +57,7 @@ void TmqhFlowRegister(void) 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; diff --git a/src/unix-manager.c b/src/unix-manager.c index d364985741..c77e2b91df 100644 --- a/src/unix-manager.c +++ b/src/unix-manager.c @@ -121,7 +121,7 @@ static int UnixNew(UnixCommand * this) 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 { @@ -885,7 +885,7 @@ static TmEcode UnixManagerConfGetCommand(json_t *cmd, } 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); } @@ -1061,7 +1061,7 @@ int UnixManagerInit(void) { 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) { diff --git a/src/util-action.c b/src/util-action.c index d3ea1b631a..4ade93a473 100644 --- a/src/util-action.c +++ b/src/util-action.c @@ -109,11 +109,11 @@ int ActionInitConfig(void) 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; @@ -189,16 +189,16 @@ action-order:\n\ - 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; @@ -223,16 +223,16 @@ action-order:\n\ - 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; @@ -256,16 +256,16 @@ action-order:\n\ - 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; @@ -286,16 +286,16 @@ static int UtilActionTest04(void) ---\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; @@ -322,16 +322,16 @@ action-order:\n\ - 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; @@ -355,16 +355,16 @@ action-order:\n\ - 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; @@ -388,16 +388,16 @@ action-order:\n\ - 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; @@ -416,9 +416,9 @@ static int UtilActionTest08(void) 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); @@ -426,7 +426,7 @@ static int UtilActionTest08(void) FAIL_IF_NOT(action_order_sigs[2] == ACTION_REJECT); FAIL_IF_NOT(action_order_sigs[3] == ACTION_ALERT); - ConfRestoreContextBackup(); + SCConfRestoreContextBackup(); PASS; } diff --git a/src/util-affinity.c b/src/util-affinity.c index 9281b7239e..bc12e634ab 100644 --- a/src/util-affinity.c +++ b/src/util-affinity.c @@ -94,11 +94,10 @@ static void AffinitySetupInit(void) } } -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; @@ -149,7 +148,7 @@ static void AffinityCallback(int i, void *data) 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); } @@ -162,8 +161,8 @@ static void BuildCpuset(const char *name, ConfNode *node, cpu_set_t *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(); @@ -189,8 +188,8 @@ void AffinitySetupLoadFromConfig(void) 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"); @@ -199,7 +198,7 @@ void AffinitySetupLoadFromConfig(void) } 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 { @@ -209,29 +208,29 @@ void AffinitySetupLoadFromConfig(void) 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; @@ -247,7 +246,7 @@ void AffinitySetupLoadFromConfig(void) } } - 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; @@ -258,7 +257,7 @@ void AffinitySetupLoadFromConfig(void) } } - 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 " diff --git a/src/util-affinity.h b/src/util-affinity.h index 2fa4509ffa..c4e0aab285 100644 --- a/src/util-affinity.h +++ b/src/util-affinity.h @@ -93,8 +93,7 @@ uint16_t UtilAffinityCpusOverlap(ThreadsAffinityType *taf1, ThreadsAffinityType 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 */ diff --git a/src/util-bpf.c b/src/util-bpf.c index dda910d2c8..bf54819d76 100644 --- a/src/util-bpf.c +++ b/src/util-bpf.c @@ -28,7 +28,7 @@ #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"); @@ -36,11 +36,11 @@ void ConfSetBPFFilter( } /* 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); diff --git a/src/util-bpf.h b/src/util-bpf.h index 5291ba7f7d..7c1c00d7ac 100644 --- a/src/util-bpf.h +++ b/src/util-bpf.h @@ -27,7 +27,7 @@ #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, diff --git a/src/util-classification-config.c b/src/util-classification-config.c index c42c2d1a55..d7f4e9cc83 100644 --- a/src/util-classification-config.c +++ b/src/util-classification-config.c @@ -58,7 +58,7 @@ static SCClassConfClasstype *SCClassConfAllocClasstype(uint16_t classtype_id, 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; @@ -160,13 +160,13 @@ static const char *SCClassConfGetConfFilename(const DetectEngineCtx *de_ctx) /* 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; } } diff --git a/src/util-classification-config.h b/src/util-classification-config.h index a5d8026ca3..926e9022cb 100644 --- a/src/util-classification-config.h +++ b/src/util-classification-config.h @@ -51,7 +51,7 @@ SCClassConfClasstype *SCClassConfGetClasstype(const char *, DetectEngineCtx *); void SCClassConfDeInitContext(DetectEngineCtx *); -void SCClassConfInit(DetectEngineCtx *de_ctx); +void SCClassSCConfInit(DetectEngineCtx *de_ctx); void SCClassConfDeinit(DetectEngineCtx *de_ctx); /* for unittests */ diff --git a/src/util-conf.c b/src/util-conf.c index 302c918dcf..734aab80a9 100644 --- a/src/util-conf.c +++ b/src/util-conf.c @@ -32,14 +32,14 @@ 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) { @@ -74,14 +74,14 @@ TmEcode ConfigSetDataDirectory(char *name) 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) { @@ -118,9 +118,9 @@ TmEcode ConfigCheckDataDirectory(const char *data_dir) * * \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 && @@ -137,7 +137,7 @@ int ConfUnixSocketIsEnable(void) { const char *value; - if (ConfGet("unix-command.enabled", &value) != 1) { + if (SCConfGet("unix-command.enabled", &value) != 1) { return 0; } @@ -159,5 +159,5 @@ int ConfUnixSocketIsEnable(void) #endif } - return ConfValIsTrue(value); + return SCConfValIsTrue(value); } diff --git a/src/util-conf.h b/src/util-conf.h index 30fa5f4e46..4155a674d8 100644 --- a/src/util-conf.h +++ b/src/util-conf.h @@ -28,14 +28,14 @@ #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); diff --git a/src/util-coredump-config.c b/src/util-coredump-config.c index 4fa43579cc..c35ba37595 100644 --- a/src/util-coredump-config.c +++ b/src/util-coredump-config.c @@ -94,7 +94,7 @@ int32_t CoredumpLoadConfig (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; } diff --git a/src/util-daemon.c b/src/util-daemon.c index 9092189101..d191077f91 100644 --- a/src/util-daemon.c +++ b/src/util-daemon.c @@ -131,7 +131,7 @@ void Daemonize (void) 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"); } diff --git a/src/util-debug.c b/src/util-debug.c index d881c6e87a..cd85f7a70c 100644 --- a/src/util-debug.c +++ b/src/util-debug.c @@ -1419,7 +1419,7 @@ void SCLogInitLogModule(SCLogInitData *sc_lid) 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; @@ -1431,7 +1431,7 @@ void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid) 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; @@ -1445,7 +1445,7 @@ void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid) /* 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) { @@ -1453,34 +1453,33 @@ void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid) 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; @@ -1489,9 +1488,9 @@ void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid) } } - 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) { @@ -1512,7 +1511,7 @@ void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid) 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"); } @@ -1530,8 +1529,7 @@ void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid) } 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) { @@ -1583,7 +1581,7 @@ void SCLogLoadConfig(int daemon, int verbose, uint32_t userid, uint32_t groupid) */ 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; diff --git a/src/util-debug.h b/src/util-debug.h index 6ed0eccf5b..78586de6cd 100644 --- a/src/util-debug.h +++ b/src/util-debug.h @@ -512,7 +512,7 @@ void SCLogErr(int x, const char *file, const char *func, const int line, const c 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); \ diff --git a/src/util-device.c b/src/util-device.c index fd4cf5685f..18450937e5 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -278,15 +278,15 @@ int LiveBuildDeviceList(const char *runmode) 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")) diff --git a/src/util-ebpf.c b/src/util-ebpf.c index 6b00fe2b4c..fea3916425 100644 --- a/src/util-ebpf.c +++ b/src/util-ebpf.c @@ -966,7 +966,7 @@ static void EBPFRedirectMapAddCPU(int i, void *data) } } -void EBPFBuildCPUSet(ConfNode *node, char *iface) +void EBPFBuildCPUSet(SCConfNode *node, char *iface) { uint32_t key0 = 0; int mapfd = EBPFGetMapFDByName(iface, "cpus_count"); diff --git a/src/util-ebpf.h b/src/util-ebpf.h index c4f524c3bd..fe31f59120 100644 --- a/src/util-ebpf.h +++ b/src/util-ebpf.h @@ -86,7 +86,7 @@ int EBPFCheckBypassedFlowCreate(ThreadVars *th_v, struct timespec *curtime, void void EBPFRegisterExtension(void); -void EBPFBuildCPUSet(ConfNode *node, char *iface); +void EBPFBuildCPUSet(SCConfNode *node, char *iface); int EBPFSetPeerIface(const char *iface, const char *out_iface); diff --git a/src/util-exception-policy.c b/src/util-exception-policy.c index da95a186b0..f467f70f4b 100644 --- a/src/util-exception-policy.c +++ b/src/util-exception-policy.c @@ -304,7 +304,7 @@ enum ExceptionPolicy ExceptionPolicyParse(const char *option, bool support_flow) 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 { @@ -329,7 +329,7 @@ enum ExceptionPolicy ExceptionPolicyMidstreamParse(bool midstream_enabled) 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); diff --git a/src/util-file.c b/src/util-file.c index e9faf3f04d..fe1b4e7684 100644 --- a/src/util-file.c +++ b/src/util-file.c @@ -167,19 +167,19 @@ void FileForceTrackingEnable(void) /** * \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"); @@ -191,10 +191,10 @@ void FileForceHashParseCfg(ConfNode *conf) } 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) { diff --git a/src/util-file.h b/src/util-file.h index 784d5de398..3e42efda65 100644 --- a/src/util-file.h +++ b/src/util-file.h @@ -232,7 +232,7 @@ int FileForceSha256(void); void FileUpdateFlowFileFlags(Flow *f, uint16_t set_file_flags, uint8_t direction); -void FileForceHashParseCfg(ConfNode *); +void FileForceHashParseCfg(SCConfNode *); void FileForceTrackingEnable(void); diff --git a/src/util-host-os-info.c b/src/util-host-os-info.c index 1b5443bc77..2b40717040 100644 --- a/src/util-host-os-info.c +++ b/src/util-host-os-info.c @@ -280,13 +280,13 @@ void SCHInfoCleanResources(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) @@ -1212,9 +1212,9 @@ host-os-policy:\n\ SCHInfoCreateContextBackup(); - ConfCreateContextBackup(); - ConfInit(); - ConfYamlLoadString(config, strlen(config)); + SCConfCreateContextBackup(); + SCConfInit(); + SCConfYamlLoadString(config, strlen(config)); SCHInfoLoadFromConfig(); if (SCHInfoGetHostOSFlavour("10.0.0.4") != OS_POLICY_WINDOWS) @@ -1229,12 +1229,12 @@ host-os-policy:\n\ result = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); - SCHInfoRestoreContextBackup(); + SCHInfoRestoreContextBackup(); - return result; + return result; } /** @@ -1257,17 +1257,17 @@ host-os-policy:\n\ 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: @@ -1297,12 +1297,12 @@ host-os-policy:\n\ result = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); - SCHInfoRestoreContextBackup(); + SCHInfoRestoreContextBackup(); - return result; + return result; } /** @@ -1325,15 +1325,15 @@ host-os-policy:\n\ 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"); @@ -1344,11 +1344,11 @@ host-os-policy:\n\ result = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); - SCHInfoRestoreContextBackup(); - return result; + SCHInfoRestoreContextBackup(); + return result; } /** @@ -1371,15 +1371,15 @@ host-os-policy:\n\ 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"); @@ -1390,11 +1390,11 @@ host-os-policy:\n\ result = 1; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); - SCHInfoRestoreContextBackup(); - return result; + SCHInfoRestoreContextBackup(); + return result; } /** @@ -1415,9 +1415,9 @@ host-os-policy:\n\ 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); @@ -1428,8 +1428,8 @@ host-os-policy:\n\ FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.0") != -1); FAIL_IF (SCHInfoGetHostOSFlavour("0.0.0.6") != -1); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); SCHInfoRestoreContextBackup(); PASS; } diff --git a/src/util-landlock.c b/src/util-landlock.c index 27c01427f9..198c3abe71 100644 --- a/src/util-landlock.c +++ b/src/util-landlock.c @@ -183,7 +183,7 @@ void LandlockSandboxing(SCInstance *suri) { /* 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) { @@ -196,7 +196,7 @@ void LandlockSandboxing(SCInstance *suri) return; } - LandlockSandboxingWritePath(ruleset, ConfigGetLogDirectory()); + LandlockSandboxingWritePath(ruleset, SCConfigGetLogDirectory()); struct stat sb; if (stat(ConfigGetDataDirectory(), &sb) == 0) { LandlockSandboxingAddRule(ruleset, ConfigGetDataDirectory(), @@ -208,7 +208,7 @@ void LandlockSandboxing(SCInstance *suri) } 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; @@ -241,7 +241,7 @@ void LandlockSandboxing(SCInstance *suri) } 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) { @@ -257,30 +257,30 @@ void LandlockSandboxing(SCInstance *suri) } 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); } diff --git a/src/util-log-redis.c b/src/util-log-redis.c index 6d29caccbb..dc8af8b969 100644 --- a/src/util-log-redis.c +++ b/src/util-log-redis.c @@ -457,7 +457,7 @@ int LogFileWriteRedis(void *lf_ctx, const char *string, size_t string_len) * \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; @@ -471,13 +471,13 @@ int SCConfLogOpenRedis(ConfNode *redis_node, void *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; @@ -501,14 +501,14 @@ int SCConfLogOpenRedis(ConfNode *redis_node, void *lf_ctx) 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 { @@ -532,10 +532,10 @@ int SCConfLogOpenRedis(ConfNode *redis_node, void *lf_ctx) 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) { diff --git a/src/util-log-redis.h b/src/util-log-redis.h index 80c9da2c57..ecee95a125 100644 --- a/src/util-log-redis.h +++ b/src/util-log-redis.h @@ -61,7 +61,7 @@ typedef struct SCLogRedisContext_ { } SCLogRedisContext; void SCLogRedisInit(void); -int SCConfLogOpenRedis(ConfNode *, void *); +int SCConfLogOpenRedis(SCConfNode *, void *); int LogFileWriteRedis(void *, const char *, size_t); #endif /* HAVE_LIBHIREDIS */ diff --git a/src/util-logopenfile.c b/src/util-logopenfile.c index e793850e0f..423cf15278 100644 --- a/src/util-logopenfile.c +++ b/src/util-logopenfile.c @@ -417,7 +417,7 @@ static FILE *SCLogOpenFileFp( return NULL; } - if (ConfValIsTrue(append_setting)) { + if (SCConfValIsTrue(append_setting)) { ret = fopen(filename, "a"); } else { ret = fopen(filename, "w"); @@ -463,11 +463,8 @@ error_exit: * \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; @@ -487,11 +484,11 @@ SCConfLogOpenGeneric(ConfNode *conf, } // 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); @@ -500,7 +497,7 @@ SCConfLogOpenGeneric(ConfNode *conf, } /* 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; @@ -527,7 +524,7 @@ SCConfLogOpenGeneric(ConfNode *conf, } } - filetype = ConfNodeLookupChildValue(conf, "filetype"); + filetype = SCConfNodeLookupChildValue(conf, "filetype"); if (filetype == NULL) filetype = DEFAULT_LOG_FILETYPE; @@ -536,7 +533,7 @@ SCConfLogOpenGeneric(ConfNode *conf, * 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) { @@ -548,13 +545,13 @@ SCConfLogOpenGeneric(ConfNode *conf, } 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; @@ -562,26 +559,23 @@ SCConfLogOpenGeneric(ConfNode *conf, 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); } diff --git a/src/util-logopenfile.h b/src/util-logopenfile.h index 735d93b56a..e12df01af6 100644 --- a/src/util-logopenfile.h +++ b/src/util-logopenfile.h @@ -180,7 +180,7 @@ int LogFileWrite(LogFileCtx *file_ctx, MemBuffer *buffer); 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); diff --git a/src/util-lua-common.c b/src/util-lua-common.c index f24863f172..921ddf315d 100644 --- a/src/util-lua-common.c +++ b/src/util-lua-common.c @@ -289,7 +289,7 @@ static int LuaCallbackRuleClass(lua_State *luastate) 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"); diff --git a/src/util-macset.c b/src/util-macset.c index bf50c098bb..5fb8e81743 100644 --- a/src/util-macset.c +++ b/src/util-macset.c @@ -61,17 +61,18 @@ FlowStorageId g_macset_storage_id = { .id = -1 }; 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; diff --git a/src/util-magic.c b/src/util-magic.c index 1308964717..68fd2cbf8c 100644 --- a/src/util-magic.c +++ b/src/util-magic.c @@ -50,8 +50,7 @@ magic_t MagicInitContext(void) goto error; } - (void)ConfGet("magic-file", &filename); - + (void)SCConfGet("magic-file", &filename); if (filename != NULL) { if (strlen(filename) == 0) { diff --git a/src/util-mpm-ac.c b/src/util-mpm-ac.c index 086f321e2a..9f4607f50e 100644 --- a/src/util-mpm-ac.c +++ b/src/util-mpm-ac.c @@ -104,10 +104,10 @@ typedef struct StateQueue_ { */ 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"); } /** diff --git a/src/util-plugin.c b/src/util-plugin.c index ed534f2470..1a90b1f5d2 100644 --- a/src/util-plugin.c +++ b/src/util-plugin.c @@ -101,11 +101,11 @@ static void InitPlugin(char *path) 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) { diff --git a/src/util-profiling-keywords.c b/src/util-profiling-keywords.c index 37db34b4a5..d33462752b 100644 --- a/src/util-profiling-keywords.c +++ b/src/util-profiling-keywords.c @@ -60,24 +60,24 @@ static const char *profiling_file_mode = "a"; 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"; diff --git a/src/util-profiling-prefilter.c b/src/util-profiling-prefilter.c index b6277a16d4..d7ff071790 100644 --- a/src/util-profiling-prefilter.c +++ b/src/util-profiling-prefilter.c @@ -60,24 +60,24 @@ static const char *profiling_file_mode = "a"; 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"; diff --git a/src/util-profiling-rulegroups.c b/src/util-profiling-rulegroups.c index b25e89b01b..00852787bd 100644 --- a/src/util-profiling-rulegroups.c +++ b/src/util-profiling-rulegroups.c @@ -63,24 +63,24 @@ static int profiling_rulegroup_json = 0; 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"; @@ -88,7 +88,7 @@ void SCProfilingSghsGlobalInit(void) profiling_sghs_output_to_file = 1; } - if (ConfNodeChildValueIsTrue(conf, "json")) { + if (SCConfNodeChildValueIsTrue(conf, "json")) { profiling_rulegroup_json = 1; } } diff --git a/src/util-profiling-rules.c b/src/util-profiling-rules.c index 2b017f2464..80965c1b7d 100644 --- a/src/util-profiling-rules.c +++ b/src/util-profiling-rules.c @@ -93,15 +93,15 @@ void SCProfilingRulesGlobalInit(void) 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); @@ -130,7 +130,7 @@ void SCProfilingRulesGlobalInit(void) } } - val = ConfNodeLookupChildValue(conf, "limit"); + val = SCConfNodeLookupChildValue(conf, "limit"); if (val != NULL) { if (StringParseUint32(&profiling_rules_limit, 10, (uint16_t)strlen(val), val) <= 0) { @@ -138,18 +138,18 @@ void SCProfilingRulesGlobalInit(void) 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"; @@ -157,7 +157,7 @@ void SCProfilingRulesGlobalInit(void) profiling_output_to_file = 1; } - if (ConfNodeChildValueIsTrue(conf, "json")) { + if (SCConfNodeChildValueIsTrue(conf, "json")) { profiling_rule_json = 1; } } diff --git a/src/util-profiling.c b/src/util-profiling.c index 6a4c73a45b..fb1f525cc8 100644 --- a/src/util-profiling.c +++ b/src/util-profiling.c @@ -132,12 +132,12 @@ static void FormatNumber(uint64_t num, char *str, size_t size) 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) @@ -146,9 +146,9 @@ SCProfilingInit(void) 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) { @@ -174,19 +174,19 @@ SCProfilingInit(void) 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"; @@ -196,10 +196,10 @@ SCProfilingInit(void) } } - 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"; } @@ -214,7 +214,7 @@ SCProfilingInit(void) 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); } @@ -232,9 +232,9 @@ SCProfilingInit(void) } } - 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."); @@ -243,9 +243,9 @@ SCProfilingInit(void) 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)) { @@ -254,8 +254,8 @@ SCProfilingInit(void) 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"; @@ -1436,9 +1436,9 @@ void SCProfilingInit(void) 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--) { @@ -1454,8 +1454,8 @@ void SCProfilingInit(void) 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); } } diff --git a/src/util-reference-config.c b/src/util-reference-config.c index 9b2b09337c..677a891c31 100644 --- a/src/util-reference-config.c +++ b/src/util-reference-config.c @@ -49,7 +49,7 @@ void SCRConfReferenceHashFree(void *ch); /* 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; @@ -150,13 +150,13 @@ static const char *SCRConfGetConfFilename(const DetectEngineCtx *de_ctx) /* 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; } } diff --git a/src/util-reference-config.h b/src/util-reference-config.h index c21c51622b..06f3f0318e 100644 --- a/src/util-reference-config.h +++ b/src/util-reference-config.h @@ -53,7 +53,7 @@ FILE *SCRConfGenerateValidDummyReferenceConfigFD01(void); 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 */ diff --git a/src/util-rule-vars.c b/src/util-rule-vars.c index 47193c2d26..0ce1015e72 100644 --- a/src/util-rule-vars.c +++ b/src/util-rule-vars.c @@ -97,7 +97,7 @@ const char *SCRuleVarsGetConfVar(const DetectEngineCtx *de_ctx, } } - 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); @@ -187,9 +187,9 @@ static const char *dummy_conf_string = */ 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 && @@ -238,8 +238,8 @@ static int SCRuleVarsPositiveTest01(void) 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; } @@ -249,17 +249,17 @@ static int SCRuleVarsPositiveTest01(void) */ 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; } @@ -269,9 +269,9 @@ static int SCRuleVarsNegativeTest02(void) */ 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); @@ -282,8 +282,8 @@ static int SCRuleVarsPositiveTest03(void) "[80,[!$HTTP_PORTS,$ORACLE_PORTS]] (msg:\"Rule Vars Test\"; sid:1;)"); FAIL_IF_NULL(s); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); DetectEngineCtxFree(de_ctx); PASS; } @@ -294,9 +294,9 @@ static int SCRuleVarsPositiveTest03(void) */ 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; @@ -315,8 +315,8 @@ static int SCRuleVarsNegativeTest04(void) FAIL_IF_NOT_NULL(s); DetectEngineCtxFree(de_ctx); - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); PASS; } @@ -350,9 +350,9 @@ static int SCRuleVarsMTest01(void) 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; @@ -387,8 +387,8 @@ static int SCRuleVarsMTest01(void) goto end; end: - ConfDeInit(); - ConfRestoreContextBackup(); + SCConfDeInit(); + SCConfRestoreContextBackup(); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); diff --git a/src/util-running-modes.c b/src/util-running-modes.c index 02aeefece8..ce2ee7ca41 100644 --- a/src/util-running-modes.c +++ b/src/util-running-modes.c @@ -44,7 +44,7 @@ int ListKeywords(const char *keyword_info) int ListAppLayerProtocols(const char *conf_filename) { EngineModeSetIDS(); - if (ConfYamlLoadFile(conf_filename) != -1) + if (SCConfYamlLoadFile(conf_filename) != -1) SCLogLoadConfig(0, 0, 0, 0); MpmTableSetup(); SpmTableSetup(); diff --git a/src/util-spm.c b/src/util-spm.c index dce8c737e1..9aec072ab6 100644 --- a/src/util-spm.c +++ b/src/util-spm.c @@ -68,7 +68,7 @@ SpmTableElmt spm_table[SPM_TABLE_SIZE]; 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; diff --git a/src/util-streaming-buffer.c b/src/util-streaming-buffer.c index 34c3b0a0b3..55be438231 100644 --- a/src/util-streaming-buffer.c +++ b/src/util-streaming-buffer.c @@ -2409,10 +2409,10 @@ static const char *dummy_conf_string = "%YAML 1.1\n" 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, @@ -2431,7 +2431,7 @@ static int StreamingBufferTest12(void) StreamingBufferFree(sb, &cfg); HtpConfigRestoreBackup(); - ConfRestoreContextBackup(); + SCConfRestoreContextBackup(); PASS; } diff --git a/src/util-thash.c b/src/util-thash.c index a511049e07..78a3b0ff05 100644 --- a/src/util-thash.c +++ b/src/util-thash.c @@ -226,8 +226,7 @@ static int THashInitConfig(THashTableContext *ctx, const char *cnf_prefix) /** 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 " @@ -239,16 +238,14 @@ static int THashInitConfig(THashTableContext *ctx, const char *cnf_prefix) 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 { diff --git a/src/util-threshold-config.c b/src/util-threshold-config.c index 6bedfcd94c..d9c31b0cc2 100644 --- a/src/util-threshold-config.c +++ b/src/util-threshold-config.c @@ -139,13 +139,13 @@ static const char *SCThresholdConfGetConfFilename(const DetectEngineCtx *de_ctx) /* 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; } }