summaryrefslogtreecommitdiffstats
path: root/src/datatype.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2018-05-08 13:08:37 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2018-05-11 12:16:59 +0200
commite70354f53e9f6be4a4be31dbc46c5e23291d3587 (patch)
tree8d0bb763d9e80c5eb33e899666552e2bd414053b /src/datatype.c
parente77b31f53a61a8995cd6baf91a6e557260f401bd (diff)
libnftables: Implement JSON output support
Although technically there already is support for JSON output via 'nft export json' command, it is hardly useable since it exports all the gory details of nftables VM. Also, libnftables has no control over what is exported since the content comes directly from libnftnl. Instead, implement JSON format support for regular 'nft list' commands. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/datatype.c')
-rw-r--r--src/datatype.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/datatype.c b/src/datatype.c
index d5a5091e..c77d228e 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -25,6 +25,7 @@
#include <gmputil.h>
#include <erec.h>
#include <netlink.h>
+#include <json.h>
#include <netinet/ip_icmp.h>
@@ -357,6 +358,7 @@ const struct datatype integer_type = {
.name = "integer",
.desc = "integer",
.print = integer_type_print,
+ .json = integer_type_json,
.parse = integer_type_parse,
};
@@ -386,6 +388,7 @@ const struct datatype string_type = {
.desc = "string",
.byteorder = BYTEORDER_HOST_ENDIAN,
.print = string_type_print,
+ .json = string_type_json,
.parse = string_type_parse,
};
@@ -603,6 +606,7 @@ const struct datatype inet_protocol_type = {
.size = BITS_PER_BYTE,
.basetype = &integer_type,
.print = inet_protocol_type_print,
+ .json = inet_protocol_type_json,
.parse = inet_protocol_type_parse,
};
@@ -658,6 +662,7 @@ const struct datatype inet_service_type = {
.size = 2 * BITS_PER_BYTE,
.basetype = &integer_type,
.print = inet_service_type_print,
+ .json = inet_service_type_json,
.parse = inet_service_type_parse,
.sym_tbl = &inet_service_tbl,
};
@@ -753,6 +758,7 @@ const struct datatype mark_type = {
.basetype = &integer_type,
.basefmt = "0x%.8Zx",
.print = mark_type_print,
+ .json = mark_type_json,
.parse = mark_type_parse,
.flags = DTYPE_F_PREFIX,
};
@@ -987,6 +993,7 @@ const struct datatype time_type = {
.size = 8 * BITS_PER_BYTE,
.basetype = &integer_type,
.print = time_type_print,
+ .json = time_type_json,
.parse = time_type_parse,
};
@@ -1163,4 +1170,5 @@ const struct datatype boolean_type = {
.size = 1,
.basetype = &integer_type,
.sym_tbl = &boolean_tbl,
+ .json = boolean_type_json,
};