summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2019-12-04 04:20:55 +0100
committerDavid Lamparter <equinox@diac24.net>2019-12-06 15:13:32 +0100
commitf210b3e3002e2918e912cd5e49c43e874a55e40d (patch)
tree19c3482ead49d05828a3ff0c99601f0ffda9cae6 /lib
parentlib: new defaults logic (diff)
downloadfrr-f210b3e3002e2918e912cd5e49c43e874a55e40d.tar.xz
frr-f210b3e3002e2918e912cd5e49c43e874a55e40d.zip
lib/defaults: add bool variable support
(I hadn't initially added this because I thought it superfluous, but it kinda makes things nicer.) Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/defaults.c4
-rw-r--r--lib/defaults.h8
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/defaults.c b/lib/defaults.c
index 8a1cfebe1..71ccc73cc 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -166,6 +166,8 @@ static void frr_default_apply_one(struct frr_default *dflt, bool check)
if (!saveentry)
saveentry = entry;
+ if (dflt->dflt_bool)
+ *dflt->dflt_bool = dfltentry->val_bool;
if (dflt->dflt_str)
*dflt->dflt_str = dfltentry->val_str;
if (dflt->dflt_long)
@@ -174,6 +176,8 @@ static void frr_default_apply_one(struct frr_default *dflt, bool check)
*dflt->dflt_ulong = dfltentry->val_ulong;
if (dflt->dflt_float)
*dflt->dflt_float = dfltentry->val_float;
+ if (dflt->save_bool)
+ *dflt->save_bool = saveentry->val_bool;
if (dflt->save_str)
*dflt->save_str = saveentry->val_str;
if (dflt->save_long)
diff --git a/lib/defaults.h b/lib/defaults.h
index ad2f1ad2e..b35bdfeaf 100644
--- a/lib/defaults.h
+++ b/lib/defaults.h
@@ -19,6 +19,9 @@
#define _FRR_DEFAULTS_H
#include "config.h"
+
+#include <stdbool.h>
+
#include "compiler.h"
#ifdef HAVE_DATACENTER
@@ -67,6 +70,7 @@ struct frr_default_entry {
const char *match_profile;
/* value to use */
+ bool val_bool;
const char *val_str;
long val_long;
unsigned long val_ulong;
@@ -90,12 +94,14 @@ struct frr_default {
*/
/* variable holding the default value for reading/use */
+ bool *dflt_bool;
const char **dflt_str;
long *dflt_long;
unsigned long *dflt_ulong;
float *dflt_float;
/* variable to use when comparing for config save */
+ bool *save_bool;
const char **save_str;
long *save_long;
unsigned long *save_ulong;
@@ -133,6 +139,8 @@ struct frr_default {
* will be expanded and blow up with a compile error. Use an enum or add an
* extra _ at the beginning (e.g. _SHARP_BLUNTNESS => DFLT__SHARP_BLUNTNESS)
*/
+#define FRR_CFG_DEFAULT_BOOL(varname, ...) \
+ _FRR_CFG_DEFAULT(bool, bool, varname, ## __VA_ARGS__)
#define FRR_CFG_DEFAULT_LONG(varname, ...) \
_FRR_CFG_DEFAULT(long, long, varname, ## __VA_ARGS__)
#define FRR_CFG_DEFAULT_ULONG(varname, ...) \