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
28 extern "C"
29 {
30 #endif
31 
32 #include "queue.h"
33 
34 /**
35  * Structure of a configuration parameter.
36  */
37 typedef 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 
62 void SCConfInit(void);
63 void SCConfDeInit(void);
65 int SCConfGet(const char *name, const char **vptr);
66 int SCConfGetInt(const char *name, intmax_t *val);
67 int SCConfGetBool(const char *name, int *val);
68 int SCConfGetDouble(const char *name, double *val);
69 int SCConfGetFloat(const char *name, float *val);
70 int SCConfSet(const char *name, const char *val);
71 int SCConfSetFromString(const char *input, int final);
72 int SCConfSetFinal(const char *name, const char *val);
73 void SCConfDump(void);
74 void SCConfNodeDump(const SCConfNode *node, const char *prefix);
77 SCConfNode *SCConfGetNode(const char *key);
78 void SCConfCreateContextBackup(void);
80 SCConfNode *SCConfNodeLookupChild(const SCConfNode *node, const char *key);
81 const char *SCConfNodeLookupChildValue(const SCConfNode *node, const char *key);
83 void SCConfRegisterTests(void);
84 int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key);
85 int SCConfValIsTrue(const char *val);
86 int SCConfValIsFalse(const char *val);
87 void SCConfNodePrune(SCConfNode *node);
88 int SCConfRemove(const char *name);
89 bool SCConfNodeHasChildren(const SCConfNode *node);
90 
92  const SCConfNode *base, const SCConfNode *dflt, const char *name);
93 SCConfNode *SCConfNodeLookupKeyValue(const SCConfNode *base, const char *key, const char *value);
94 int SCConfGetChildValue(const SCConfNode *base, const char *name, const char **vptr);
95 int SCConfGetChildValueInt(const SCConfNode *base, const char *name, intmax_t *val);
96 int 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);
103 int SCConfNodeIsSequence(const SCConfNode *node);
104 SCConfNode *SCConfSetIfaceNode(const char *ifaces_node_name, const char *iface);
105 int SCConfSetRootAndDefaultNodes(const char *ifaces_node_name, const char *iface,
106  SCConfNode **if_root, SCConfNode **if_default);
107 SCConfNode *SCConfNodeGetNodeOrCreate(SCConfNode *parent, const char *name, int final);
108 
111 const char *SCConfGetValueNode(const SCConfNode *node);
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #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:46
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:41
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:2123
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:38
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:37
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:39
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