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;
44 } ConfNode;
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__ */
void ConfNodeFree(ConfNode *)
Free a ConfNode and all of its children.
Definition: conf.c:152
struct HtpBodyChunk_ * next
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:566
void ConfDeInit(void)
De-initializes the configuration system.
Definition: conf.c:722
ConfNode * ConfGetRootNode(void)
Get the root configuration node.
Definition: conf.c:203
int ConfValIsFalse(const char *val)
Check if a value is false.
Definition: conf.c:591
ConfNode * ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value)
Lookup for a key value under a specific node.
Definition: conf.c:860
ConfNode * ConfGetNode(const char *key)
Get a ConfNode by name.
Definition: conf.c:176
int ConfNodeChildValueIsTrue(const ConfNode *node, const char *key)
Test if a configuration node has a true value.
Definition: conf.c:888
char * val
Definition: conf.h:34
Flow * head
Definition: flow-hash.h:102
void ConfNodeDump(const ConfNode *node, const char *prefix)
Dump a configuration node and all its children.
Definition: conf.c:750
int ConfRemove(const char *name)
Remove a configuration parameter from the configuration db.
Definition: conf.c:683
int ConfGetChildValueBoolWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, int *val)
Definition: conf.c:543
int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, const char **vptr)
Definition: conf.c:416
int ConfNodeIsSequence(const ConfNode *node)
Check if a node is a sequence or node.
Definition: conf.c:975
int ConfGetDouble(const char *name, double *val)
Retrieve a configuration value as a double.
Definition: conf.c:615
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *key)
Lookup the value of a child configuration node by name.
Definition: conf.c:843
void ConfCreateContextBackup(void)
Creates a backup of the conf_hash hash_table used by the conf API.
Definition: conf.c:699
TAILQ_HEAD(, ConfNode_) head
int ConfSetFinal(const char *name, const char *val)
Set a final configuration value.
Definition: conf.c:299
int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr)
Definition: conf.c:388
void ConfNodeRemove(ConfNode *)
Remove (and SCFree) the provided configuration node.
Definition: conf.c:668
int is_seq
Definition: conf.h:36
void ConfRestoreContextBackup(void)
Restores the backup of the hash_table present in backup_conf_hash back to conf_hash.
Definition: conf.c:711
int ConfGetChildValueBool(const ConfNode *base, const char *name, int *val)
Definition: conf.c:530
struct ConfNode_ * parent
Definition: conf.h:41
int ConfGetValue(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:360
int ConfGetChildValueIntWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name, intmax_t *val)
Definition: conf.c:495
int ConfSetFromString(const char *input, int final)
Set a configuration parameter from a string.
Definition: conf.c:245
void ConfDump(void)
Dump configuration to stdout.
Definition: conf.c:780
TAILQ_ENTRY(ConfNode_) next
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:437
ConfNode * ConfGetChildWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name)
Definition: conf.c:402
Definition: conf.h:32
char * ConfLoadCompleteIncludePath(const char *)
Create the path for an include entry.
Definition: conf.c:902
int ConfGetFloat(const char *name, float *val)
Retrieve a configuration value as a float.
Definition: conf.c:645
bool ConfNodeHasChildren(const ConfNode *node)
Check if a node has any children.
Definition: conf.c:796
int ConfSet(const char *name, const char *val)
Set a configuration value.
Definition: conf.c:220
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *key)
Lookup a child configuration node by name.
Definition: conf.c:815
char * name
Definition: conf.h:33
int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val)
Definition: conf.c:469
void ConfRegisterTests(void)
Definition: conf.c:1467
int ConfGet(const char *name, const char **vptr)
Retrieve the value of a configuration node.
Definition: conf.c:331
void ConfNodePrune(ConfNode *node)
Prune a configuration node.
Definition: conf.c:943
int ConfGetBool(const char *name, int *val)
Retrieve a configuration value as an boolen.
Definition: conf.c:517
ConfNode * ConfNodeNew(void)
Allocate a new configuration node.
Definition: conf.c:134
void ConfInit(void)
Initialize the configuration system.
Definition: conf.c:113