From: Jason Ish Date: Mon, 30 May 2022 22:52:29 +0000 (-0600) Subject: conf: remove ConfGetValue X-Git-Tag: suricata-7.0.0-beta1~531 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adda8801d8b2cf5461d8b233594da460dc5c3373;p=thirdparty%2Fsuricata.git conf: remove ConfGetValue All uses of ConfGetValue are satisfied by ConfGet --- diff --git a/src/app-layer-htp-range.c b/src/app-layer-htp-range.c index 9e837f3604..4826142e16 100644 --- a/src/app-layer-htp-range.c +++ b/src/app-layer-htp-range.c @@ -153,7 +153,7 @@ void HttpRangeContainersInit(void) const char *str = NULL; uint64_t memcap = HTTP_RANGE_DEFAULT_MEMCAP; uint32_t timeout = HTTP_RANGE_DEFAULT_TIMEOUT; - if (ConfGetValue("app-layer.protocols.http.byterange.memcap", &str) == 1) { + if (ConfGet("app-layer.protocols.http.byterange.memcap", &str) == 1) { if (ParseSizeStringU64(str, &memcap) < 0) { SCLogWarning(SC_ERR_INVALID_VALUE, "memcap value cannot be deduced: %s," @@ -162,7 +162,7 @@ void HttpRangeContainersInit(void) memcap = 0; } } - if (ConfGetValue("app-layer.protocols.http.byterange.timeout", &str) == 1) { + if (ConfGet("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(SC_ERR_INVALID_VALUE, diff --git a/src/app-layer-ssh.c b/src/app-layer-ssh.c index 05fbf53138..cfc1a0c06d 100644 --- a/src/app-layer-ssh.c +++ b/src/app-layer-ssh.c @@ -90,7 +90,7 @@ void RegisterSSHParsers(void) /* Check if we should generate Hassh fingerprints */ int enable_hassh = SSH_CONFIG_DEFAULT_HASSH; const char *strval = NULL; - if (ConfGetValue("app-layer.protocols.ssh.hassh", &strval) != 1) { + if (ConfGet("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; diff --git a/src/app-layer-ssl.c b/src/app-layer-ssl.c index fed5eaca13..2013a6cc96 100644 --- a/src/app-layer-ssl.c +++ b/src/app-layer-ssl.c @@ -3067,7 +3067,7 @@ void RegisterSSLParsers(void) /* Check if we should generate JA3 fingerprints */ int enable_ja3 = SSL_CONFIG_DEFAULT_JA3; const char *strval = NULL; - if (ConfGetValue("app-layer.protocols.tls.ja3-fingerprints", &strval) != 1) { + if (ConfGet("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; diff --git a/src/conf.c b/src/conf.c index af469660e7..202a25da04 100644 --- a/src/conf.c +++ b/src/conf.c @@ -340,50 +340,6 @@ int ConfGet(const char *name, const char **vptr) } } -/** - * \brief Retrieve the value of a configuration node. - * - * This function will return the value for a configuration node based - * on the full name of the node. This function notifies if vptr returns NULL - * or if name is set to NULL. - * - * \param name Name of configuration parameter to get. - * \param vptr Pointer that will be set to the configuration value parameter. - * Note that this is just a reference to the actual value, not a copy. - * - * \retval 0 will be returned if name was not found, - * 1 will be returned if the name and it's value was found, - * -1 if the value returns NULL, - * -2 if name is NULL. - */ -int ConfGetValue(const char *name, const char **vptr) -{ - ConfNode *node; - - if (name == NULL) { - SCLogError(SC_ERR_INVALID_ARGUMENT,"parameter 'name' is NULL"); - return -2; - } - - node = ConfGetNode(name); - - if (node == NULL) { - SCLogDebug("failed to lookup configuration parameter '%s'", name); - return 0; - } - else { - - if (node->val == NULL) { - SCLogDebug("value for configuration parameter '%s' is NULL", name); - return -1; - } - - *vptr = node->val; - return 1; - } - -} - int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr) { ConfNode *node = ConfNodeLookupChild(base, name); @@ -518,7 +474,7 @@ int ConfGetBool(const char *name, int *val) const char *strval = NULL; *val = 0; - if (ConfGetValue(name, &strval) != 1) + if (ConfGet(name, &strval) != 1) return 0; *val = ConfValIsTrue(strval); diff --git a/src/conf.h b/src/conf.h index f9e5f6e32c..e2944d868f 100644 --- a/src/conf.h +++ b/src/conf.h @@ -59,7 +59,6 @@ void ConfInit(void); void ConfDeInit(void); ConfNode *ConfGetRootNode(void); int ConfGet(const char *name, const char **vptr); -int ConfGetValue(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); diff --git a/src/datasets.c b/src/datasets.c index 2a4d2e8797..8b20aa45e2 100644 --- a/src/datasets.c +++ b/src/datasets.c @@ -605,7 +605,7 @@ void DatasetPostReloadCleanup(void) static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize) { const char *str = NULL; - if (ConfGetValue("datasets.defaults.memcap", &str) == 1) { + if (ConfGet("datasets.defaults.memcap", &str) == 1) { if (ParseSizeStringU64(str, memcap) < 0) { SCLogWarning(SC_ERR_INVALID_VALUE, "memcap value cannot be deduced: %s," @@ -614,7 +614,7 @@ static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize) *memcap = 0; } } - if (ConfGetValue("datasets.defaults.hashsize", &str) == 1) { + if (ConfGet("datasets.defaults.hashsize", &str) == 1) { if (ParseSizeStringU32(str, hashsize) < 0) { SCLogWarning(SC_ERR_INVALID_VALUE, "hashsize value cannot be deduced: %s," diff --git a/src/host.c b/src/host.c index 157a5a71fa..015a0889e0 100644 --- a/src/host.c +++ b/src/host.c @@ -199,8 +199,7 @@ void HostInitConfig(bool quiet) uint32_t configval = 0; /** set config values for memcap, prealloc and hash_size */ - if ((ConfGetValue("host.memcap", &conf_val)) == 1) - { + if ((ConfGet("host.memcap", &conf_val)) == 1) { uint64_t host_memcap = 0; if (ParseSizeStringU64(conf_val, &host_memcap) < 0) { SCLogError(SC_ERR_SIZE_PARSE, "Error parsing host.memcap " @@ -211,16 +210,14 @@ void HostInitConfig(bool quiet) SC_ATOMIC_SET(host_config.memcap, host_memcap); } } - if ((ConfGetValue("host.hash-size", &conf_val)) == 1) - { + if ((ConfGet("host.hash-size", &conf_val)) == 1) { if (StringParseUint32(&configval, 10, strlen(conf_val), conf_val) > 0) { host_config.hash_size = configval; } } - if ((ConfGetValue("host.prealloc", &conf_val)) == 1) - { + if ((ConfGet("host.prealloc", &conf_val)) == 1) { if (StringParseUint32(&configval, 10, strlen(conf_val), conf_val) > 0) { host_config.prealloc = configval; diff --git a/src/runmodes.c b/src/runmodes.c index 2aca1b4ac8..0e88dae308 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -952,7 +952,7 @@ void RunModeInitialize(void) * in case the default per-thread stack size is to be adjusted */ const char *ss = NULL; - if ((ConfGetValue("threading.stack-size", &ss)) == 1) { + if ((ConfGet("threading.stack-size", &ss)) == 1) { if (ss != NULL) { if (ParseSizeStringU64(ss, &threading_set_stack_size) < 0) { FatalError(SC_ERR_INVALID_ARGUMENT, diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 4fa19c74a7..d1c5371c8e 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -392,7 +392,7 @@ void StreamTcpInitConfig(bool quiet) } const char *temp_stream_memcap_str; - if (ConfGetValue("stream.memcap", &temp_stream_memcap_str) == 1) { + if (ConfGet("stream.memcap", &temp_stream_memcap_str) == 1) { uint64_t stream_memcap_copy; if (ParseSizeStringU64(temp_stream_memcap_str, &stream_memcap_copy) < 0) { SCLogError(SC_ERR_SIZE_PARSE, "Error parsing stream.memcap " @@ -442,7 +442,7 @@ void StreamTcpInitConfig(bool quiet) } const char *temp_stream_inline_str; - if (ConfGetValue("stream.inline", &temp_stream_inline_str) == 1) { + if (ConfGet("stream.inline", &temp_stream_inline_str) == 1) { int inl = 0; /* checking for "auto" and falling back to boolean to provide @@ -505,7 +505,7 @@ void StreamTcpInitConfig(bool quiet) } const char *temp_stream_reassembly_memcap_str; - if (ConfGetValue("stream.reassembly.memcap", &temp_stream_reassembly_memcap_str) == 1) { + if (ConfGet("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) { @@ -527,7 +527,7 @@ void StreamTcpInitConfig(bool quiet) } const char *temp_stream_reassembly_depth_str; - if (ConfGetValue("stream.reassembly.depth", &temp_stream_reassembly_depth_str) == 1) { + if (ConfGet("stream.reassembly.depth", &temp_stream_reassembly_depth_str) == 1) { if (ParseSizeStringU32(temp_stream_reassembly_depth_str, &stream_config.reassembly_depth) < 0) { SCLogError(SC_ERR_SIZE_PARSE, "Error parsing " @@ -554,8 +554,7 @@ void StreamTcpInitConfig(bool quiet) if (randomize) { const char *temp_rdrange; - if (ConfGetValue("stream.reassembly.randomize-chunk-range", - &temp_rdrange) == 1) { + if (ConfGet("stream.reassembly.randomize-chunk-range", &temp_rdrange) == 1) { if (ParseSizeStringU16(temp_rdrange, &rdrange) < 0) { SCLogError(SC_ERR_SIZE_PARSE, "Error parsing " "stream.reassembly.randomize-chunk-range " @@ -571,7 +570,7 @@ void StreamTcpInitConfig(bool quiet) } const char *temp_stream_reassembly_toserver_chunk_size_str; - if (ConfGetValue("stream.reassembly.toserver-chunk-size", + if (ConfGet("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) { @@ -593,7 +592,7 @@ void StreamTcpInitConfig(bool quiet) rdrange / 100); } const char *temp_stream_reassembly_toclient_chunk_size_str; - if (ConfGetValue("stream.reassembly.toclient-chunk-size", + if (ConfGet("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) { diff --git a/src/suricata.c b/src/suricata.c index b246ce13f1..f4f3b0c52d 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -2516,7 +2516,7 @@ static void PostConfLoadedSetupHostMode(void) { const char *hostmode = NULL; - if (ConfGetValue("host-mode", &hostmode) == 1) { + if (ConfGet("host-mode", &hostmode) == 1) { if (!strcmp(hostmode, "router")) { host_mode = SURI_HOST_IS_ROUTER; } else if (!strcmp(hostmode, "sniffer-only")) { @@ -2542,7 +2542,6 @@ static void PostConfLoadedSetupHostMode(void) "default setting 'sniffer-only'"); } } - } static void SetupUserMode(SCInstance *suri) @@ -2592,7 +2591,7 @@ int PostConfLoadedSetup(SCInstance *suri) if (suri->checksum_validation == -1) { const char *cv = NULL; - if (ConfGetValue("capture.checksum-validation", &cv) == 1) { + if (ConfGet("capture.checksum-validation", &cv) == 1) { if (strcmp(cv, "none") == 0) { suri->checksum_validation = 0; } else if (strcmp(cv, "all") == 0) {