]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
conf: remove ConfGetValue
authorJason Ish <jason.ish@oisf.net>
Mon, 30 May 2022 22:52:29 +0000 (16:52 -0600)
committerVictor Julien <vjulien@oisf.net>
Wed, 1 Jun 2022 07:49:57 +0000 (09:49 +0200)
All uses of ConfGetValue are satisfied by ConfGet

src/app-layer-htp-range.c
src/app-layer-ssh.c
src/app-layer-ssl.c
src/conf.c
src/conf.h
src/datasets.c
src/host.c
src/runmodes.c
src/stream-tcp.c
src/suricata.c

index 9e837f36048d6762810f19a62bea7b86c47e43e2..4826142e167057f5d040e9f62ef2473ad0f12a9b 100644 (file)
@@ -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,
index 05fbf53138637a300833b5f28f81c6d4f8805ed7..cfc1a0c06df1cc1e633647b32b6ca74cfbd2123d 100644 (file)
@@ -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;
index fed5eaca1306559a2c51edbd49479389a13edf0c..2013a6cc96dfc2c3eb220ae55e94c1fd04a0015d 100644 (file)
@@ -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;
index af469660e749c23433039a53598367357438c068..202a25da04da8bcf30d1ea6b9636f632d51caa8d 100644 (file)
@@ -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);
index f9e5f6e32cd7581e31ed567deadb05bce011d798..e2944d868f0c65e0357e2d4d878adbe117128cb8 100644 (file)
@@ -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);
index 2a4d2e87973869b5df1a2d2d63e54ed1221323b5..8b20aa45e2565b8c640a4778a6b2ecd48aa01357 100644 (file)
@@ -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,"
index 157a5a71fab48577ade13579f0d328665549c60a..015a0889e02fbf7bec8df626abc10c35c43f26b9 100644 (file)
@@ -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;
index 2aca1b4ac812f0f1c3d832308074750c0b5472d2..0e88dae3082143619ea5f5a03f8f50c6daf47a71 100644 (file)
@@ -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,
index 4fa19c74a760179f1b725b46c77b9182cc956feb..d1c5371c8ef148c4d405ebd18bcb43cafc7979e4 100644 (file)
@@ -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) {
index b246ce13f1619a230eefdc79d5c757b5efffcd9d..f4f3b0c52d0045b558d59dc67813b571417a28a5 100644 (file)
@@ -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) {