summaryrefslogtreecommitdiffstats
path: root/src/jansson.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/jansson.c')
-rw-r--r--src/jansson.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/jansson.c b/src/jansson.c
index 4c778d9..cc3ab23 100644
--- a/src/jansson.c
+++ b/src/jansson.c
@@ -90,4 +90,22 @@ json_t *nft_jansson_get_root(char *json, const char *tag, json_error_t *err)
return root;
}
+int nft_jansson_parse_family(json_t *root, void *out)
+{
+ const char *str;
+ int family;
+
+ str = nft_jansson_value_parse_str(root, "family");
+ if (str == NULL)
+ return -1;
+
+ family = nft_str2family(str);
+ if (family < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memcpy(out, &family, sizeof(family));
+ return 0;
+}
#endif