suricata
conf.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2010 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 __CONF_H__
25 #define __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 ConfGetValue(const char *name, const char **vptr);
63 int ConfGetInt(const char *name, intmax_t *val);
64 int ConfGetBool(const char *name, int *val);
65 int ConfGetDouble(const char *name, double *val);
66 int ConfGetFloat(const char *name, float *val);
67 int ConfSet(const char *name, const char *val);
68 int ConfSetFromString(const char *input, int final);
69 int ConfSetFinal(const char *name, const char *val);
70 void ConfDump(void);
71 void ConfNodeDump(const ConfNode *node, const char *prefix);
72 ConfNode *ConfNodeNew(void);
73 void ConfNodeFree(ConfNode *);
74 ConfNode *ConfGetNode(const char *key);
75 void ConfCreateContextBackup(void);
76 void ConfRestoreContextBackup(void);
77 ConfNode *ConfNodeLookupChild(const ConfNode *node, const char *key);
78 const char *ConfNodeLookupChildValue(const ConfNode *node, const char *key);
79 void ConfNodeRemove(ConfNode *);
80 void ConfRegisterTests(void);
81 int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key);
82 int ConfValIsTrue(const char *val);
83 int ConfValIsFalse(const char *val);
84 void ConfNodePrune(ConfNode *node);
85 int ConfRemove(const char *name);
86 bool ConfNodeHasChildren(const ConfNode *node);
87 
88 ConfNode *ConfGetChildWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name);
89 ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value);
90 int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr);
91 int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val);
92 int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val);
93 int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, const char **vptr);
94 int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, intmax_t *val);
95 int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val);
96 char *ConfLoadCompleteIncludePath(const char *);
97 int ConfNodeIsSequence(const ConfNode *node);
98 
99 #endif /* ! __CONF_H__ */
ConfNodeChildValueIsTrue
int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key)
Test if a configuration node has a true value.
Definition: conf.c:887
ConfNode_::val
char * val
Definition: conf.h:34
ConfNodeNew
ConfNode * ConfNodeNew(void)
Allocate a new configuration node.
Definition: conf.c:133
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:415
ConfSetFinal
int ConfSetFinal(const char *name, const char *val)
Set a final configuration value.
Definition: conf.c:298
ConfGetRootNode
ConfNode * ConfGetRootNode(void)
Get the root configuration node.
Definition: conf.c:202
ConfInit
void ConfInit(void)
Initialize the configuration system.
Definition: conf.c:113
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:494
ConfDump
void ConfDump(void)
Dump configuration to stdout.
Definition: conf.c:779
ConfNodeLookupKeyValue
ConfNode * ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value)
Lookup for a key value under a specific node.
Definition: conf.c:859
ConfNode_::TAILQ_HEAD
TAILQ_HEAD(, ConfNode_) head
ConfRemove
int ConfRemove(const char *name)
Remove a configuration parameter from the configuration db.
Definition: conf.c:682
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:614
ConfNodeDump
void ConfNodeDump(const ConfNode *node, const char *prefix)
Dump a configuration node and all its children.
Definition: conf.c:749
ConfNodeHasChildren
bool ConfNodeHasChildren(const ConfNode *node)
Check if a node has any children.
Definition: conf.c:795
ConfValIsFalse
int ConfValIsFalse(const char *val)
Check if a value is false.
Definition: conf.c:590
ConfGetFloat
int ConfGetFloat(const char *name, float *val)
Retrieve a configuration value as a float.
Definition: conf.c:644
ConfNodeFree
void ConfNodeFree(ConfNode *)
Free a ConfNode and all of its children.
Definition: conf.c:151
ConfSet
int ConfSet(const char *name, const char *val)
Set a configuration value.
Definition: conf.c:219
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:842
ConfCreateContextBackup
void ConfCreateContextBackup(void)
Creates a backup of the conf_hash hash_table used by the conf API.
Definition: conf.c:698
ConfGetChildValueBoolWithDefault
int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val)
Definition: conf.c:542
ConfNodeIsSequence
int ConfNodeIsSequence(const ConfNode *node)
Check if a node is a sequence or node.
Definition: conf.c:974
ConfRestoreContextBackup
void ConfRestoreContextBackup(void)
Restores the backup of the hash_table present in backup_conf_hash back to conf_hash.
Definition: conf.c:710
ConfNode_::name
char * name
Definition: conf.h:33
ConfNodeRemove
void ConfNodeRemove(ConfNode *)
Remove (and SCFree) the provided configuration node.
Definition: conf.c:667
ConfRegisterTests
void ConfRegisterTests(void)
Definition: conf.c:1466
ConfGetChildValue
int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr)
Definition: conf.c:387
ConfGetChildValueBool
int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val)
Definition: conf.c:529
head
Flow * head
Definition: flow-hash.h:1
ConfGetBool
int ConfGetBool(const char *name, int *val)
Retrieve a configuration value as an boolen.
Definition: conf.c:516
ConfNode_
Definition: conf.h:32
ConfSetFromString
int ConfSetFromString(const char *input, int final)
Set a configuration parameter from a string.
Definition: conf.c:244
ConfGetValue
int ConfGetValue(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:359
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:565
ConfGet
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:330
ConfLoadCompleteIncludePath
char * ConfLoadCompleteIncludePath(const char *)
Create the path for an include entry.
Definition: conf.c:901
ConfGetInt
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:436
ConfNodePrune
void ConfNodePrune(ConfNode *node)
Prune a configuration node.
Definition: conf.c:942
ConfDeInit
void ConfDeInit(void)
De-initializes the configuration system.
Definition: conf.c:721
ConfNodeLookupChild
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *key)
Lookup a child configuration node by name.
Definition: conf.c:814
ConfGetNode
ConfNode * ConfGetNode(const char *key)
Get a ConfNode by name.
Definition: conf.c:175
ConfGetChildValueInt
int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val)
Definition: conf.c:468
ConfGetChildWithDefault
ConfNode * ConfGetChildWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name)
Definition: conf.c:401