suricata
conf.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2023 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Endace Technology Limited - Jason Ish <jason.ish@endace.com>
22 */
23
24#ifndef SURICATA_CONF_H
25#define SURICATA_CONF_H
26
27#ifdef __cplusplus
28extern "C"
29{
30#endif
31
32#include "queue.h"
33
34/**
35 * Structure of a configuration parameter.
36 */
37typedef struct SCConfNode_ {
38 char *name;
39 char *val;
40
41 int is_seq;
42
43 /**< Flag that sets this nodes value as final. */
44 int final;
45
50
51/**
52 * The default log directory.
53 */
54#ifdef OS_WIN32
55#define DEFAULT_LOG_DIR "C:\\WINDOWS\\Temp"
56#define DEFAULT_DATA_DIR "C:\\WINDOWS\\Temp"
57#else
58#define DEFAULT_LOG_DIR "/var/log/suricata"
59#define DEFAULT_DATA_DIR DATA_DIR
60#endif /* OS_WIN32 */
61
62void SCConfInit(void);
63void SCConfDeInit(void);
65int SCConfGet(const char *name, const char **vptr);
66int SCConfGetInt(const char *name, intmax_t *val);
67int SCConfGetBool(const char *name, int *val);
68int SCConfGetDouble(const char *name, double *val);
69int SCConfGetFloat(const char *name, float *val);
70int SCConfSet(const char *name, const char *val);
71int SCConfSetFromString(const char *input, int final);
72int SCConfSetFinal(const char *name, const char *val);
73void SCConfDump(void);
74void SCConfNodeDump(const SCConfNode *node, const char *prefix);
77SCConfNode *SCConfGetNode(const char *key);
80SCConfNode *SCConfNodeLookupChild(const SCConfNode *node, const char *key);
81const char *SCConfNodeLookupChildValue(const SCConfNode *node, const char *key);
83void SCConfRegisterTests(void);
84int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key);
85int SCConfValIsTrue(const char *val);
86int SCConfValIsFalse(const char *val);
87void SCConfNodePrune(SCConfNode *node);
88int SCConfRemove(const char *name);
89bool SCConfNodeHasChildren(const SCConfNode *node);
90
92 const SCConfNode *base, const SCConfNode *dflt, const char *name);
93SCConfNode *SCConfNodeLookupKeyValue(const SCConfNode *base, const char *key, const char *value);
94int SCConfGetChildValue(const SCConfNode *base, const char *name, const char **vptr);
95int SCConfGetChildValueInt(const SCConfNode *base, const char *name, intmax_t *val);
96int SCConfGetChildValueBool(const SCConfNode *base, const char *name, int *val);
98 const SCConfNode *base, const SCConfNode *dflt, const char *name, const char **vptr);
100 const SCConfNode *base, const SCConfNode *dflt, const char *name, intmax_t *val);
102 const SCConfNode *base, const SCConfNode *dflt, const char *name, int *val);
103int SCConfNodeIsSequence(const SCConfNode *node);
104SCConfNode *SCConfSetIfaceNode(const char *ifaces_node_name, const char *iface);
105int SCConfSetRootAndDefaultNodes(const char *ifaces_node_name, const char *iface,
106 SCConfNode **if_root, SCConfNode **if_default);
108
111const char *SCConfGetValueNode(const SCConfNode *node);
112
113#ifdef __cplusplus
114}
115#endif
116
117#endif /* ! SURICATA_CONF_H */
struct HtpBodyChunk_ * next
void SCConfInit(void)
Initialize the configuration system.
Definition conf.c:120
bool SCConfNodeHasChildren(const SCConfNode *node)
Check if a node has any children.
Definition conf.c:777
int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key)
Test if a configuration node has a true value.
Definition conf.c:868
int SCConfSetRootAndDefaultNodes(const char *ifaces_node_name, const char *iface, SCConfNode **if_root, SCConfNode **if_default)
Finds and sets root and default node of the interface.
Definition conf.c:962
void SCConfRegisterTests(void)
Definition conf.c:1471
SCConfNode * SCConfGetChildWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name)
Definition conf.c:379
SCConfNode * SCConfGetFirstNode(const SCConfNode *parent)
Definition conf.c:204
void SCConfNodeRemove(SCConfNode *)
Remove (and SCFree) the provided configuration node.
Definition conf.c:653
int SCConfValIsTrue(const char *val)
Check if a value is true.
Definition conf.c:551
void SCConfDeInit(void)
De-initializes the configuration system.
Definition conf.c:703
SCConfNode * SCConfGetNextNode(const SCConfNode *node)
Definition conf.c:209
SCConfNode * SCConfGetNode(const char *key)
Get a SCConfNode by name.
Definition conf.c:181
void SCConfDump(void)
Dump configuration to stdout.
Definition conf.c:761
int SCConfGetChildValueWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name, const char **vptr)
Definition conf.c:393
int SCConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition conf.c:414
int SCConfNodeIsSequence(const SCConfNode *node)
Check if a node is a sequence or node.
Definition conf.c:925
int SCConfRemove(const char *name)
Remove a configuration parameter from the configuration db.
Definition conf.c:668
int SCConfSetFinal(const char *name, const char *val)
Set a final configuration value.
Definition conf.c:318
int SCConfGetFloat(const char *name, float *val)
Retrieve a configuration value as a float.
Definition conf.c:630
int SCConfGetChildValueInt(const SCConfNode *base, const char *name, intmax_t *val)
Definition conf.c:449
int SCConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
Definition conf.c:497
int SCConfGetChildValueBool(const SCConfNode *base, const char *name, int *val)
Definition conf.c:515
SCConfNode * SCConfSetIfaceNode(const char *ifaces_node_name, const char *iface)
Finds an interface from the list of interfaces.
Definition conf.c:936
int SCConfSet(const char *name, const char *val)
Set a configuration value.
Definition conf.c:239
SCConfNode * SCConfGetRootNode(void)
Get the root configuration node.
Definition conf.c:222
SCConfNode * SCConfNodeLookupChild(const SCConfNode *node, const char *key)
Lookup a child configuration node by name.
Definition conf.c:796
SCConfNode * SCConfNodeLookupKeyValue(const SCConfNode *base, const char *key, const char *value)
Lookup for a key value under a specific node.
Definition conf.c:841
const char * SCConfNodeLookupChildValue(const SCConfNode *node, const char *key)
Lookup the value of a child configuration node by name.
Definition conf.c:824
int SCConfSetFromString(const char *input, int final)
Set a configuration parameter from a string.
Definition conf.c:264
int SCConfValIsFalse(const char *val)
Check if a value is false.
Definition conf.c:576
int SCConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition conf.c:350
int SCConfGetChildValueBoolWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name, int *val)
Definition conf.c:528
const char * SCConfGetValueNode(const SCConfNode *node)
Definition conf.c:214
void SCConfNodeDump(const SCConfNode *node, const char *prefix)
Dump a configuration node and all its children.
Definition conf.c:731
SCConfNode * SCConfNodeGetNodeOrCreate(SCConfNode *parent, const char *name, int final)
Helper function to get a node, creating it if it does not exist.
Definition conf.c:66
void SCConfCreateContextBackup(void)
Creates a backup of the conf_hash hash_table used by the conf API.
Definition conf.c:684
int SCConfGetChildValueIntWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name, intmax_t *val)
Definition conf.c:476
struct SCConfNode_ SCConfNode
int SCConfGetDouble(const char *name, double *val)
Retrieve a configuration value as a double.
Definition conf.c:600
SCConfNode * SCConfNodeNew(void)
Allocate a new configuration node.
Definition conf.c:139
void SCConfNodePrune(SCConfNode *node)
Create the path for an include entry.
Definition conf.c:893
void SCConfRestoreContextBackup(void)
Restores the backup of the hash_table present in backup_conf_hash back to conf_hash.
Definition conf.c:694
void SCConfNodeFree(SCConfNode *)
Free a SCConfNode and all of its children.
Definition conf.c:157
int SCConfGetChildValue(const SCConfNode *base, const char *name, const char **vptr)
Definition conf.c:363
Flow * head
Definition flow-hash.h:1
TAILQ_HEAD(, SCConfNode_) head
int is_seq
Definition conf.h:41
char * name
Definition conf.h:38
char * val
Definition conf.h:39
struct SCConfNode_ * parent
Definition conf.h:46
TAILQ_ENTRY(SCConfNode_) next
const char * name