From 80077787f8f21da1efd8dc27a4c5767ab47a1df6 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 9 Oct 2018 00:03:28 +0200 Subject: src: remove json support We have better json support in libnftables these days. Signed-off-by: Pablo Neira Ayuso --- src/expr/byteorder.c | 59 ---------------------------------------------------- 1 file changed, 59 deletions(-) (limited to 'src/expr/byteorder.c') diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c index 47c04cf..4cddd4a 100644 --- a/src/expr/byteorder.c +++ b/src/expr/byteorder.c @@ -197,63 +197,6 @@ static inline int nftnl_str2ntoh(const char *op) } } -static int -nftnl_expr_byteorder_json_parse(struct nftnl_expr *e, json_t *root, - struct nftnl_parse_err *err) -{ -#ifdef JSON_PARSING - const char *op; - uint32_t sreg, dreg, len, size; - int ntoh; - - if (nftnl_jansson_parse_reg(root, "sreg", NFTNL_TYPE_U32, &sreg, err) == 0) - nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SREG, sreg); - - if (nftnl_jansson_parse_reg(root, "dreg", NFTNL_TYPE_U32, &dreg, err) == 0) - nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_DREG, dreg); - - op = nftnl_jansson_parse_str(root, "op", err); - if (op != NULL) { - ntoh = nftnl_str2ntoh(op); - if (ntoh < 0) - return -1; - - nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_OP, ntoh); - } - - if (nftnl_jansson_parse_val(root, "len", NFTNL_TYPE_U32, &len, err) == 0) - nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_LEN, len); - - if (nftnl_jansson_parse_val(root, "size", NFTNL_TYPE_U32, &size, err) == 0) - nftnl_expr_set_u32(e, NFTNL_EXPR_BYTEORDER_SIZE, size); - - return 0; -#else - errno = EOPNOTSUPP; - return -1; -#endif -} - -static int nftnl_expr_byteorder_export(char *buf, size_t size, - const struct nftnl_expr *e, int type) -{ - struct nftnl_expr_byteorder *byteorder = nftnl_expr_data(e); - NFTNL_BUF_INIT(b, buf, size); - - if (e->flags & (1 << NFTNL_EXPR_BYTEORDER_SREG)) - nftnl_buf_u32(&b, type, byteorder->sreg, SREG); - if (e->flags & (1 << NFTNL_EXPR_BYTEORDER_DREG)) - nftnl_buf_u32(&b, type, byteorder->dreg, DREG); - if (e->flags & (1 << NFTNL_EXPR_BYTEORDER_OP)) - nftnl_buf_str(&b, type, bo2str(byteorder->op), OP); - if (e->flags & (1 << NFTNL_EXPR_BYTEORDER_LEN)) - nftnl_buf_u32(&b, type, byteorder->len, LEN); - if (e->flags & (1 << NFTNL_EXPR_BYTEORDER_SIZE)) - nftnl_buf_u32(&b, type, byteorder->size, SIZE); - - return nftnl_buf_done(&b); -} - static int nftnl_expr_byteorder_snprintf_default(char *buf, size_t size, const struct nftnl_expr *e) { @@ -277,7 +220,6 @@ nftnl_expr_byteorder_snprintf(char *buf, size_t size, uint32_t type, return nftnl_expr_byteorder_snprintf_default(buf, size, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_expr_byteorder_export(buf, size, e, type); default: break; } @@ -315,5 +257,4 @@ struct expr_ops expr_ops_byteorder = { .parse = nftnl_expr_byteorder_parse, .build = nftnl_expr_byteorder_build, .snprintf = nftnl_expr_byteorder_snprintf, - .json_parse = nftnl_expr_byteorder_json_parse, }; -- cgit v1.2.3