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 ConfNode_ {
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 
41  struct ConfNode_ *parent;
45 
46 
47 /**
48  * The default log directory.
49  */
50 #ifdef OS_WIN32
51 #define DEFAULT_LOG_DIR "C:\\WINDOWS\\Temp"
52 #define DEFAULT_DATA_DIR "C:\\WINDOWS\\Temp"
53 #else
54 #define DEFAULT_LOG_DIR "/var/log/suricata"
55 #define DEFAULT_DATA_DIR DATA_DIR
56 #endif /* OS_WIN32 */
57 
58 void ConfInit(void);
59 void ConfDeInit(void);
61 int ConfGet(const char *name, const char **vptr);
62 int ConfGetInt(const char *name, intmax_t *val);
63 int ConfGetBool(const char *name, int *val);
64 int ConfGetDouble(const char *name, double *val);
65 int ConfGetFloat(const char *name, float *val);
66 int ConfSet(const char *name, const char *val);
67 int ConfSetFromString(const char *input, int final);
68 int ConfSetFinal(const char *name, const char *val);
69 void ConfDump(void);
70 void ConfNodeDump(const ConfNode *node, const char *prefix);
71 ConfNode *ConfNodeNew(void);
72 void ConfNodeFree(ConfNode *);
73 ConfNode *ConfGetNode(const char *key);
74 void ConfCreateContextBackup(void);
75 void ConfRestoreContextBackup(void);
76 ConfNode *ConfNodeLookupChild(const ConfNode *node, const char *key);
77 const char *ConfNodeLookupChildValue(const ConfNode *node, const char *key);
78 void ConfNodeRemove(ConfNode *);
79 void ConfRegisterTests(void);
80 int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key);
81 int ConfValIsTrue(const char *val);
82 int ConfValIsFalse(const char *val);
83 void ConfNodePrune(ConfNode *node);
84 int ConfRemove(const char *name);
85 bool ConfNodeHasChildren(const ConfNode *node);
86 
87 ConfNode *ConfGetChildWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name);
88 ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value);
89 int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr);
90 int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val);
91 int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val);
92 int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, const char **vptr);
93 int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, intmax_t *val);
94 int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val);
95 char *ConfLoadCompleteIncludePath(const char *);
96 int ConfNodeIsSequence(const ConfNode *node);
97 ConfNode *ConfSetIfaceNode(const char *ifaces_node_name, const char *iface);
99  const char *ifaces_node_name, const char *iface, ConfNode **if_root, ConfNode **if_default);
100 ConfNode *ConfNodeGetNodeOrCreate(ConfNode *parent, const char *name, int final);
101 #endif /* ! SURICATA_CONF_H */
ConfNodeChildValueIsTrue
int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key)
Test if a configuration node has a true value.
Definition: conf.c:859
ConfNode_::val
char * val
Definition: conf.h:34
ConfNodeNew
ConfNode * ConfNodeNew(void)
Allocate a new configuration node.
Definition: conf.c:139
next
struct HtpBodyChunk_ * next
Definition: app-layer-htp.h:0
ConfGetChildValueWithDefault
int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, const char **vptr)
Definition: conf.c:378
ConfSetFinal
int ConfSetFinal(const char *name, const char *val)
Set a final configuration value.
Definition: conf.c:303
ConfGetRootNode
ConfNode * ConfGetRootNode(void)
Get the root configuration node.
Definition: conf.c:207
ConfInit
void ConfInit(void)
Initialize the configuration system.
Definition: conf.c:120
ConfNode
struct ConfNode_ ConfNode
ConfNode_::is_seq
int is_seq
Definition: conf.h:36
ConfGetChildValueIntWithDefault
int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, intmax_t *val)
Definition: conf.c:462
ConfDump
void ConfDump(void)
Dump configuration to stdout.
Definition: conf.c:751
ConfNodeLookupKeyValue
ConfNode * ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value)
Lookup for a key value under a specific node.
Definition: conf.c:831
ConfNode_::TAILQ_HEAD
TAILQ_HEAD(, ConfNode_) head
ConfRemove
int ConfRemove(const char *name)
Remove a configuration parameter from the configuration db.
Definition: conf.c:654
ConfNode_::TAILQ_ENTRY
TAILQ_ENTRY(ConfNode_) next
ConfNode_::parent
struct ConfNode_ * parent
Definition: conf.h:41
ConfGetDouble
int ConfGetDouble(const char *name, double *val)
Retrieve a configuration value as a double.
Definition: conf.c:586
ConfNodeDump
void ConfNodeDump(const ConfNode *node, const char *prefix)
Dump a configuration node and all its children.
Definition: conf.c:721
ConfNodeHasChildren
bool ConfNodeHasChildren(const ConfNode *node)
Check if a node has any children.
Definition: conf.c:767
ConfValIsFalse
int ConfValIsFalse(const char *val)
Check if a value is false.
Definition: conf.c:562
ConfGetFloat
int ConfGetFloat(const char *name, float *val)
Retrieve a configuration value as a float.
Definition: conf.c:616
ConfSetRootAndDefaultNodes
int ConfSetRootAndDefaultNodes(const char *ifaces_node_name, const char *iface, ConfNode **if_root, ConfNode **if_default)
Finds and sets root and default node of the interface.
Definition: conf.c:983
ConfNodeFree
void ConfNodeFree(ConfNode *)
Free a ConfNode and all of its children.
Definition: conf.c:157
ConfSet
int ConfSet(const char *name, const char *val)
Set a configuration value.
Definition: conf.c:224
queue.h
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *key)
Lookup the value of a child configuration node by name.
Definition: conf.c:814
ConfCreateContextBackup
void ConfCreateContextBackup(void)
Creates a backup of the conf_hash hash_table used by the conf API.
Definition: conf.c:670
ConfGetChildValueBoolWithDefault
int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val)
Definition: conf.c:514
ConfNodeIsSequence
int ConfNodeIsSequence(const ConfNode *node)
Check if a node is a sequence or node.
Definition: conf.c:946
ConfRestoreContextBackup
void ConfRestoreContextBackup(void)
Restores the backup of the hash_table present in backup_conf_hash back to conf_hash.
Definition: conf.c:682
ConfNodeGetNodeOrCreate
ConfNode * ConfNodeGetNodeOrCreate(ConfNode *parent, const char *name, int final)
Helper function to get a node, creating it if it does not exist.
Definition: conf.c:66
ConfNode_::name
char * name
Definition: conf.h:33
ConfNodeRemove
void ConfNodeRemove(ConfNode *)
Remove (and SCFree) the provided configuration node.
Definition: conf.c:639
ConfRegisterTests
void ConfRegisterTests(void)
Definition: conf.c:1492
ConfGetChildValue
int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr)
Definition: conf.c:348
ConfGetChildValueBool
int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val)
Definition: conf.c:501
head
Flow * head
Definition: flow-hash.h:1
ConfGetBool
int ConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
Definition: conf.c:483
ConfNode_
Definition: conf.h:32
ConfSetFromString
int ConfSetFromString(const char *input, int final)
Set a configuration parameter from a string.
Definition: conf.c:249
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:537
ConfSetIfaceNode
ConfNode * ConfSetIfaceNode(const char *ifaces_node_name, const char *iface)
Finds an interface from the list of interfaces.
Definition: conf.c:957
ConfGet
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:335
ConfLoadCompleteIncludePath
char * ConfLoadCompleteIncludePath(const char *)
Create the path for an include entry.
Definition: conf.c:873
ConfGetInt
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:399
ConfNodePrune
void ConfNodePrune(ConfNode *node)
Prune a configuration node.
Definition: conf.c:914
ConfDeInit
void ConfDeInit(void)
De-initializes the configuration system.
Definition: conf.c:693
ConfNodeLookupChild
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *key)
Lookup a child configuration node by name.
Definition: conf.c:786
ConfGetNode
ConfNode * ConfGetNode(const char *key)
Get a ConfNode by name.
Definition: conf.c:181
ConfGetChildValueInt
int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val)
Definition: conf.c:434
ConfGetChildWithDefault
ConfNode * ConfGetChildWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name)
Definition: conf.c:364