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 #include "queue.h"
28 
29 /**
30  * Structure of a configuration parameter.
31  */
32 typedef struct SCConfNode_ {
33  char *name;
34  char *val;
35 
36  int is_seq;
37 
38  /**< Flag that sets this nodes value as final. */
39  int final;
40 
45 
46 /**
47  * The default log directory.
48  */
49 #ifdef OS_WIN32
50 #define DEFAULT_LOG_DIR "C:\\WINDOWS\\Temp"
51 #define DEFAULT_DATA_DIR "C:\\WINDOWS\\Temp"
52 #else
53 #define DEFAULT_LOG_DIR "/var/log/suricata"
54 #define DEFAULT_DATA_DIR DATA_DIR
55 #endif /* OS_WIN32 */
56 
57 void SCConfInit(void);
58 void SCConfDeInit(void);
60 int SCConfGet(const char *name, const char **vptr);
61 int SCConfGetInt(const char *name, intmax_t *val);
62 int SCConfGetBool(const char *name, int *val);
63 int SCConfGetDouble(const char *name, double *val);
64 int SCConfGetFloat(const char *name, float *val);
65 int SCConfSet(const char *name, const char *val);
66 int SCConfSetFromString(const char *input, int final);
67 int SCConfSetFinal(const char *name, const char *val);
68 void SCConfDump(void);
69 void SCConfNodeDump(const SCConfNode *node, const char *prefix);
72 SCConfNode *SCConfGetNode(const char *key);
73 void SCConfCreateContextBackup(void);
75 SCConfNode *SCConfNodeLookupChild(const SCConfNode *node, const char *key);
76 const char *SCConfNodeLookupChildValue(const SCConfNode *node, const char *key);
78 void SCConfRegisterTests(void);
79 int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key);
80 int SCConfValIsTrue(const char *val);
81 int SCConfValIsFalse(const char *val);
82 void SCConfNodePrune(SCConfNode *node);
83 int SCConfRemove(const char *name);
84 bool SCConfNodeHasChildren(const SCConfNode *node);
85 
87  const SCConfNode *base, const SCConfNode *dflt, const char *name);
88 SCConfNode *SCConfNodeLookupKeyValue(const SCConfNode *base, const char *key, const char *value);
89 int SCConfGetChildValue(const SCConfNode *base, const char *name, const char **vptr);
90 int SCConfGetChildValueInt(const SCConfNode *base, const char *name, intmax_t *val);
91 int SCConfGetChildValueBool(const SCConfNode *base, const char *name, int *val);
93  const SCConfNode *base, const SCConfNode *dflt, const char *name, const char **vptr);
95  const SCConfNode *base, const SCConfNode *dflt, const char *name, intmax_t *val);
97  const SCConfNode *base, const SCConfNode *dflt, const char *name, int *val);
98 int SCConfNodeIsSequence(const SCConfNode *node);
99 SCConfNode *SCConfSetIfaceNode(const char *ifaces_node_name, const char *iface);
100 int SCConfSetRootAndDefaultNodes(const char *ifaces_node_name, const char *iface,
101  SCConfNode **if_root, SCConfNode **if_default);
102 SCConfNode *SCConfNodeGetNodeOrCreate(SCConfNode *parent, const char *name, int final);
103 
106 const char *SCConfGetValueNode(const SCConfNode *node);
107 
108 #endif /* ! SURICATA_CONF_H */
SCConfNodeIsSequence
int SCConfNodeIsSequence(const SCConfNode *node)
Check if a node is a sequence or node.
Definition: conf.c:925
SCConfSetFromString
int SCConfSetFromString(const char *input, int final)
Set a configuration parameter from a string.
Definition: conf.c:264
SCConfGetDouble
int SCConfGetDouble(const char *name, double *val)
Retrieve a configuration value as a double.
Definition: conf.c:600
SCConfNodeDump
void SCConfNodeDump(const SCConfNode *node, const char *prefix)
Dump a configuration node and all its children.
Definition: conf.c:731
next
struct HtpBodyChunk_ * next
Definition: app-layer-htp.h:0
SCConfSet
int SCConfSet(const char *name, const char *val)
Set a configuration value.
Definition: conf.c:239
SCConfGetChildValueBool
int SCConfGetChildValueBool(const SCConfNode *base, const char *name, int *val)
Definition: conf.c:515
SCConfValIsFalse
int SCConfValIsFalse(const char *val)
Check if a value is false.
Definition: conf.c:576
SCConfGetValueNode
const char * SCConfGetValueNode(const SCConfNode *node)
Definition: conf.c:214
SCConfNodeRemove
void SCConfNodeRemove(SCConfNode *)
Remove (and SCFree) the provided configuration node.
Definition: conf.c:653
SCConfNode_::parent
struct SCConfNode_ * parent
Definition: conf.h:41
SCConfGet
int SCConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:350
SCConfGetNode
SCConfNode * SCConfGetNode(const char *key)
Get a SCConfNode by name.
Definition: conf.c:181
SCConfNodeGetNodeOrCreate
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
SCConfRegisterTests
void SCConfRegisterTests(void)
Definition: conf.c:1471
SCConfNodeFree
void SCConfNodeFree(SCConfNode *)
Free a SCConfNode and all of its children.
Definition: conf.c:157
SCConfNode_::is_seq
int is_seq
Definition: conf.h:36
SCConfGetChildValueWithDefault
int SCConfGetChildValueWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name, const char **vptr)
Definition: conf.c:393
SCConfInit
void SCConfInit(void)
Initialize the configuration system.
Definition: conf.c:120
SCConfNodeLookupChild
SCConfNode * SCConfNodeLookupChild(const SCConfNode *node, const char *key)
Lookup a child configuration node by name.
Definition: conf.c:796
SCConfGetChildValueInt
int SCConfGetChildValueInt(const SCConfNode *base, const char *name, intmax_t *val)
Definition: conf.c:449
SCConfDeInit
void SCConfDeInit(void)
De-initializes the configuration system.
Definition: conf.c:703
SCConfGetNextNode
SCConfNode * SCConfGetNextNode(const SCConfNode *node)
Definition: conf.c:209
SCConfGetChildValueIntWithDefault
int SCConfGetChildValueIntWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name, intmax_t *val)
Definition: conf.c:476
SCConfNode_::TAILQ_ENTRY
TAILQ_ENTRY(SCConfNode_) next
SCConfGetFirstNode
SCConfNode * SCConfGetFirstNode(const SCConfNode *parent)
Definition: conf.c:204
SCConfGetChildWithDefault
SCConfNode * SCConfGetChildWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name)
Definition: conf.c:379
name
const char * name
Definition: tm-threads.c:2135
SCConfSetIfaceNode
SCConfNode * SCConfSetIfaceNode(const char *ifaces_node_name, const char *iface)
Finds an interface from the list of interfaces.
Definition: conf.c:936
queue.h
SCConfNode_::TAILQ_HEAD
TAILQ_HEAD(, SCConfNode_) head
SCConfCreateContextBackup
void SCConfCreateContextBackup(void)
Creates a backup of the conf_hash hash_table used by the conf API.
Definition: conf.c:684
SCConfNodeChildValueIsTrue
int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key)
Test if a configuration node has a true value.
Definition: conf.c:868
SCConfNodeNew
SCConfNode * SCConfNodeNew(void)
Allocate a new configuration node.
Definition: conf.c:139
SCConfGetBool
int SCConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
Definition: conf.c:497
SCConfRemove
int SCConfRemove(const char *name)
Remove a configuration parameter from the configuration db.
Definition: conf.c:668
head
Flow * head
Definition: flow-hash.h:1
SCConfGetChildValue
int SCConfGetChildValue(const SCConfNode *base, const char *name, const char **vptr)
Definition: conf.c:363
SCConfNodeHasChildren
bool SCConfNodeHasChildren(const SCConfNode *node)
Check if a node has any children.
Definition: conf.c:777
SCConfGetFloat
int SCConfGetFloat(const char *name, float *val)
Retrieve a configuration value as a float.
Definition: conf.c:630
SCConfRestoreContextBackup
void SCConfRestoreContextBackup(void)
Restores the backup of the hash_table present in backup_conf_hash back to conf_hash.
Definition: conf.c:694
SCConfDump
void SCConfDump(void)
Dump configuration to stdout.
Definition: conf.c:761
SCConfNode_::name
char * name
Definition: conf.h:33
SCConfNodeLookupChildValue
const char * SCConfNodeLookupChildValue(const SCConfNode *node, const char *key)
Lookup the value of a child configuration node by name.
Definition: conf.c:824
SCConfSetRootAndDefaultNodes
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
SCConfNode
struct SCConfNode_ SCConfNode
SCConfValIsTrue
int SCConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:551
SCConfNode_
Definition: conf.h:32
SCConfNodePrune
void SCConfNodePrune(SCConfNode *node)
Create the path for an include entry.
Definition: conf.c:893
SCConfSetFinal
int SCConfSetFinal(const char *name, const char *val)
Set a final configuration value.
Definition: conf.c:318
SCConfNode_::val
char * val
Definition: conf.h:34
SCConfGetInt
int SCConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:414
SCConfGetChildValueBoolWithDefault
int SCConfGetChildValueBoolWithDefault(const SCConfNode *base, const SCConfNode *dflt, const char *name, int *val)
Definition: conf.c:528
SCConfNodeLookupKeyValue
SCConfNode * SCConfNodeLookupKeyValue(const SCConfNode *base, const char *key, const char *value)
Lookup for a key value under a specific node.
Definition: conf.c:841
SCConfGetRootNode
SCConfNode * SCConfGetRootNode(void)
Get the root configuration node.
Definition: conf.c:222