The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
configcontext.h
Go to the documentation of this file.
1 
26 #ifndef _CONFIGCONTEXT_H
27 #define _CONFIGCONTEXT_H
28 #include <projectcommon.h>
29 #include <assimobj.h>
30 #include <netaddr.h>
31 #include <signframe.h>
32 #include <address_family_numbers.h>
33 
36 
41 
43 
45  CFG_EEXIST, // Name does not exist
46  CFG_NULL, // JSON null object
47  CFG_BOOL, // JSON boolean object
48  CFG_INT64, // Signed 64-bit Integer
49  CFG_STRING, // String
50  CFG_FLOAT, // Floating point
51  CFG_ARRAY, // JSON Array
52  CFG_CFGCTX, // ConfigContext (recursive) object
53  CFG_NETADDR, // NetAddr object
54  CFG_FRAME, // Frame object
55 };
56 typedef struct _ConfigValue ConfigValue;
57 struct _ConfigValue {
60  union {
61  gint64 intvalue; // Or boolean
62  double floatvalue;
63  GSList* arrayvalue; // Each element pointing to a ConfigValue object
64  char* strvalue; // A string
65  ConfigContext* cfgctxvalue; // Another ConfigContext object
66  NetAddr* addrvalue; // A NetAddr value
67  Frame* framevalue; // A Frame value
68  }u;
69 };
70 
73  GHashTable* _values;
74  gint64 (*getint)(const ConfigContext*, const char *name);
75  void (*setint)(ConfigContext*, const char *name, gint value);
76  gboolean (*appendint)(ConfigContext*, const char *name, gint value);
77  gboolean (*getbool)(const ConfigContext*, const char *name);
78  void (*setbool)(ConfigContext*, const char *name, gboolean);
79  gboolean (*appendbool)(ConfigContext*, const char *name, gboolean);
80  double (*getdouble)(const ConfigContext*, const char *name);
81  void (*setdouble)(ConfigContext*, const char *name, double value);
82  gboolean (*appenddouble)(ConfigContext*, const char *name, double value);
84  GSList* (*getarray)(const ConfigContext*, const char *name);
85  void (*setarray)(ConfigContext*, const char *name, GSList*);
86  const char* (*getstring)(const ConfigContext*, const char *name);
87  void (*setstring)(ConfigContext*, const char *name, const char *value);
88  gboolean (*appendstring)(ConfigContext*, const char *name, const char *value);
90  Frame* (*getframe)(const ConfigContext*, const char*);
91  void (*setframe)(ConfigContext*, const char*,Frame*);
92  NetAddr* (*getaddr)(const ConfigContext*, const char* name);
93  void (*setaddr)(ConfigContext*,const char *,NetAddr*);
94  gboolean (*appendaddr)(ConfigContext*,const char *,NetAddr*);
95  ConfigContext* (*getconfig)(const ConfigContext*, const char* name);
96  void (*setconfig)(ConfigContext*,const char*,ConfigContext*);
97  gboolean (*appendconfig)(ConfigContext*,const char*,ConfigContext*);
98  enum ConfigValType
99  (*gettype)(const ConfigContext*, const char *);
100  ConfigValue* (*getvalue)(const ConfigContext*, const char *);
101  void (*delkey)(const ConfigContext*, const char *);
102  guint (*keycount)(const ConfigContext*);
103  GSList* (*keys)(const ConfigContext*);
104 };
105 WINEXPORT ConfigContext* configcontext_new(gsize objsize); // ConfigContext constructor
106 WINEXPORT ConfigContext* configcontext_new_JSON_string(const char * jsontext);// Constructor
107 
108 #define CONFIG_DEFAULT_DEADTIME 30
109 #define CONFIG_DEFAULT_HBTIME 3
110 #define CONFIG_DEFAULT_WARNTIME 10
111 #define CONFIG_DEFAULT_CMAPORT 1984
112 #define CONFIG_DEFAULT_ADDR {127,0,0,1}
113 #define CONFIG_DEFAULT_ADDRTYPE ADDR_FAMILY_IPV4
114 #define CONFIG_DEFAULT_SIGNFRAME_TYPE G_CHECKSUM_SHA256
115 
116 #define CONFIGNAME_INTERVAL "repeat"
117 #define CONFIGNAME_WARNTIME "warn"
118 #define CONFIGNAME_TIMEOUT "timeout"
119 #define CONFIGNAME_INITDELAY "init_delay"
120 #define CONFIGNAME_CMAPORT "cmaport"
121 #define CONFIGNAME_CMAINIT "cmainit"
122 #define CONFIGNAME_CMAADDR "cmaaddr"
124 #define CONFIGNAME_CMADISCOVER "cmadisc"
125 #define CONFIGNAME_CMAFAIL "cmafail"
126 #define CONFIGNAME_TYPE "type"
127 #define CONFIGNAME_INSTANCE "instance"
128 #define CONFIGNAME_DEVNAME "device"
129 #define CONFIGNAME_SWPROTOS "swprotocols"
130 #define CONFIGNAME_OUTSIG "outsig"
131 #define CONFIGNAME_CRYPT "crypt"
132 #define CONFIGNAME_COMPRESS "compress"
133 #define CONFIGNAME_CPRS_THRESH "compression_threshold"
134 #define CONFIGNAME_COMPRESSTYPE "compression_method"
135 
136 #define CONFIGINTDEFAULTS { \
138  {CONFIGNAME_DEADTIME, CONFIG_DEFAULT_DEADTIME}, \
139  {CONFIGNAME_WARNTIME, CONFIG_DEFAULT_WARNTIME}, \
140  {CONFIGNAME_HBTIME, CONFIG_DEFAULT_HBTIME}, \
141  {CONFIGNAME_CMAPORT, CONFIG_DEFAULT_CMAPORT}, \
142  }
143 #endif /* _CONFIGCONTEXT_H */
gboolean(* appendint)(ConfigContext *, const char *name, gint value)
Set integer value.
Definition: configcontext.h:76
WINEXPORT ConfigContext * configcontext_new_JSON_string(const char *jsontext)
Construct a ConfigContext object from the given JSON string.
IETF/IANA Address family assignments.
enum ConfigValType valtype
Definition: configcontext.h:59
double(* getdouble)(const ConfigContext *, const char *name)
Get double value.
Definition: configcontext.h:80
Describes interfaces to Signature Frame (Signframe) C-Class - providing digital signatures.
char * strvalue
Definition: configcontext.h:64
gboolean(* appendbool)(ConfigContext *, const char *name, gboolean)
Set bool value.
Definition: configcontext.h:79
This is the base Frame class object (in-memory TLV (type, length, value)) for every general component...
Definition: frame.h:43
AssimObj baseclass
Definition: configcontext.h:58
void(* setbool)(ConfigContext *, const char *name, gboolean)
Set bool value.
Definition: configcontext.h:78
void(* setconfig)(ConfigContext *, const char *, ConfigContext *)
Set ConfigContext value.
Definition: configcontext.h:96
#define WINEXPORT
Definition: projectcommon.h:45
enum ConfigValType(* gettype)(const ConfigContext *, const char *)
Return type.
Definition: configcontext.h:99
gint64(* getint)(const ConfigContext *, const char *name)
Get integer value.
Definition: configcontext.h:74
This file defines our base object class: AssimObj.
ConfigContext * cfgctxvalue
Definition: configcontext.h:65
void(* setaddr)(ConfigContext *, const char *, NetAddr *)
Set NetAddr value.
Definition: configcontext.h:93
void(* setframe)(ConfigContext *, const char *, Frame *)
Set Frame value.
Definition: configcontext.h:91
union _ConfigValue::@2 u
AssimObj baseclass
Definition: configcontext.h:72
gboolean(* appendstring)(ConfigContext *, const char *name, const char *value)
Set String value.
Definition: configcontext.h:88
void(* setarray)(ConfigContext *, const char *name, GSList *)
Set array value.
Definition: configcontext.h:85
Frame * framevalue
Definition: configcontext.h:67
gboolean(* getbool)(const ConfigContext *, const char *name)
Get boolean value.
Definition: configcontext.h:77
Project common header file.
void(* setdouble)(ConfigContext *, const char *name, double value)
Definition: configcontext.h:81
GSList * arrayvalue
Definition: configcontext.h:63
gboolean(* appendaddr)(ConfigContext *, const char *, NetAddr *)
Set NetAddr value.
Definition: configcontext.h:94
gboolean(* appenddouble)(ConfigContext *, const char *name, double value)
Set double value.
Definition: configcontext.h:82
void(* setint)(ConfigContext *, const char *name, gint value)
Set integer value.
Definition: configcontext.h:75
void(* setstring)(ConfigContext *, const char *name, const char *value)
Definition: configcontext.h:87
GHashTable * _values
table of Values
Definition: configcontext.h:73
ConfigValType
Definition: configcontext.h:44
NetAddr * addrvalue
Definition: configcontext.h:66
The NetAddr class class represents a general network address - whether IP, MAC, or any other type of ...
Definition: netaddr.h:43
Defines interfaces for the NetAddr (network address) object.
guint(* keycount)(const ConfigContext *)
Return number of keys in object.
gboolean(* appendconfig)(ConfigContext *, const char *, ConfigContext *)
Set ConfigContext value.
Definition: configcontext.h:97
WINEXPORT ConfigContext * configcontext_new(gsize objsize)
Construct a new ConfigContext object - with no values defaulted.
void(* delkey)(const ConfigContext *, const char *)
Delete the object with the given key.
double floatvalue
Definition: configcontext.h:62
gint64 intvalue
Definition: configcontext.h:61