conf: remove ConfGetValue

All uses of ConfGetValue are satisfied by ConfGet
pull/7455/head
Jason Ish 3 years ago committed by Victor Julien
parent 5bd19135b0
commit adda8801d8

@ -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,

@ -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;

@ -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;

@ -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);

@ -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);

@ -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,"

@ -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;

@ -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,

@ -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) {

@ -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) {

Loading…
Cancel
Save