diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2018-10-09 00:03:28 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2018-10-15 14:04:27 +0200 |
commit | 80077787f8f21da1efd8dc27a4c5767ab47a1df6 (patch) | |
tree | 01d9b399a1aad23d7ea1d1e1daa0ad98bec69e0a /src/obj | |
parent | aaf20ad0dc22d2ebcad1b2c43288e984f0efe2c3 (diff) |
src: remove json support
We have better json support in libnftables these days.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/obj')
-rw-r--r-- | src/obj/counter.c | 38 | ||||
-rw-r--r-- | src/obj/ct_helper.c | 43 | ||||
-rw-r--r-- | src/obj/ct_timeout.c | 16 | ||||
-rw-r--r-- | src/obj/limit.c | 52 | ||||
-rw-r--r-- | src/obj/quota.c | 43 | ||||
-rw-r--r-- | src/obj/tunnel.c | 13 |
6 files changed, 0 insertions, 205 deletions
diff --git a/src/obj/counter.c b/src/obj/counter.c index 332bb2b..23b60c5 100644 --- a/src/obj/counter.c +++ b/src/obj/counter.c @@ -109,42 +109,6 @@ nftnl_obj_counter_parse(struct nftnl_obj *e, struct nlattr *attr) return 0; } -static int -nftnl_obj_counter_json_parse(struct nftnl_obj *e, json_t *root, - struct nftnl_parse_err *err) -{ -#ifdef JSON_PARSING - uint64_t uval64; - - if (nftnl_jansson_parse_val(root, "pkts", NFTNL_TYPE_U64, &uval64, - err) == 0) - nftnl_obj_set_u64(e, NFTNL_OBJ_CTR_PKTS, uval64); - - if (nftnl_jansson_parse_val(root, "bytes", NFTNL_TYPE_U64, &uval64, - err) == 0) - nftnl_obj_set_u64(e, NFTNL_OBJ_CTR_BYTES, uval64); - - return 0; -#else - errno = EOPNOTSUPP; - return -1; -#endif -} - -static int nftnl_obj_counter_export(char *buf, size_t size, - const struct nftnl_obj *e, int type) -{ - struct nftnl_obj_counter *ctr = nftnl_obj_data(e); - NFTNL_BUF_INIT(b, buf, size); - - if (e->flags & (1 << NFTNL_OBJ_CTR_PKTS)) - nftnl_buf_u64(&b, type, ctr->pkts, PKTS); - if (e->flags & (1 << NFTNL_OBJ_CTR_BYTES)) - nftnl_buf_u64(&b, type, ctr->bytes, BYTES); - - return nftnl_buf_done(&b); -} - static int nftnl_obj_counter_snprintf_default(char *buf, size_t len, const struct nftnl_obj *e) { @@ -166,7 +130,6 @@ static int nftnl_obj_counter_snprintf(char *buf, size_t len, uint32_t type, return nftnl_obj_counter_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_obj_counter_export(buf, len, e, type); default: break; } @@ -183,5 +146,4 @@ struct obj_ops obj_ops_counter = { .parse = nftnl_obj_counter_parse, .build = nftnl_obj_counter_build, .snprintf = nftnl_obj_counter_snprintf, - .json_parse = nftnl_obj_counter_json_parse, }; diff --git a/src/obj/ct_helper.c b/src/obj/ct_helper.c index 62569fe..5a689b1 100644 --- a/src/obj/ct_helper.c +++ b/src/obj/ct_helper.c @@ -131,47 +131,6 @@ nftnl_obj_ct_helper_parse(struct nftnl_obj *e, struct nlattr *attr) return 0; } -static int -nftnl_obj_quota_json_parse(struct nftnl_obj *e, json_t *root, - struct nftnl_parse_err *err) -{ -#ifdef JSON_PARSING - uint64_t bytes; - uint32_t flags; - - if (nftnl_jansson_parse_val(root, "bytes", NFTNL_TYPE_U64, &bytes, - err) == 0) - nftnl_obj_set_u64(e, NFTNL_OBJ_QUOTA_BYTES, bytes); - if (nftnl_jansson_parse_val(root, "consumed", NFTNL_TYPE_U64, &bytes, - err) == 0) - nftnl_obj_set_u64(e, NFTNL_OBJ_QUOTA_CONSUMED, bytes); - if (nftnl_jansson_parse_val(root, "flags", NFTNL_TYPE_U32, &flags, - err) == 0) - nftnl_obj_set_u32(e, NFTNL_OBJ_QUOTA_FLAGS, flags); - - return 0; -#else - errno = EOPNOTSUPP; - return -1; -#endif -} - -static int nftnl_obj_ct_helper_export(char *buf, size_t size, - const struct nftnl_obj *e, int type) -{ - struct nftnl_obj_ct_helper *helper = nftnl_obj_data(e); - NFTNL_BUF_INIT(b, buf, size); - - if (e->flags & (1 << NFTNL_OBJ_CT_HELPER_NAME)) - nftnl_buf_str(&b, type, helper->name, NAME); - if (e->flags & (1 << NFTNL_OBJ_CT_HELPER_L3PROTO)) - nftnl_buf_u32(&b, type, helper->l3proto, FAMILY); - if (e->flags & (1 << NFTNL_OBJ_CT_HELPER_L4PROTO)) - nftnl_buf_u32(&b, type, helper->l4proto, "service"); - - return nftnl_buf_done(&b); -} - static int nftnl_obj_ct_helper_snprintf_default(char *buf, size_t len, const struct nftnl_obj *e) { @@ -192,7 +151,6 @@ static int nftnl_obj_ct_helper_snprintf(char *buf, size_t len, uint32_t type, case NFTNL_OUTPUT_DEFAULT: return nftnl_obj_ct_helper_snprintf_default(buf, len, e); case NFTNL_OUTPUT_JSON: - return nftnl_obj_ct_helper_export(buf, len, e, type); default: break; } @@ -209,5 +167,4 @@ struct obj_ops obj_ops_ct_helper = { .parse = nftnl_obj_ct_helper_parse, .build = nftnl_obj_ct_helper_build, .snprintf = nftnl_obj_ct_helper_snprintf, - .json_parse = nftnl_obj_quota_json_parse, }; diff --git a/src/obj/ct_timeout.c b/src/obj/ct_timeout.c index 7c2ea97..12c8f5f 100644 --- a/src/obj/ct_timeout.c +++ b/src/obj/ct_timeout.c @@ -254,21 +254,6 @@ nftnl_obj_ct_timeout_parse(struct nftnl_obj *e, struct nlattr *attr) return 0; } -static int nftnl_obj_ct_timeout_export(char *buf, size_t size, - const struct nftnl_obj *e, int type) -{ - struct nftnl_obj_ct_timeout *timeout = nftnl_obj_data(e); - - NFTNL_BUF_INIT(b, buf, size); - - if (e->flags & (1 << NFTNL_OBJ_CT_TIMEOUT_L3PROTO)) - nftnl_buf_u32(&b, type, timeout->l3proto, FAMILY); - if (e->flags & (1 << NFTNL_OBJ_CT_TIMEOUT_L4PROTO)) - nftnl_buf_u32(&b, type, timeout->l4proto, "service"); - - return nftnl_buf_done(&b); -} - static int nftnl_obj_ct_timeout_snprintf_default(char *buf, size_t len, const struct nftnl_obj *e) { @@ -330,7 +315,6 @@ static int nftnl_obj_ct_timeout_snprintf(char *buf, size_t len, uint32_t type, case NFTNL_OUTPUT_DEFAULT: return nftnl_obj_ct_timeout_snprintf_default(buf, len, e); case NFTNL_OUTPUT_JSON: - return nftnl_obj_ct_timeout_export(buf, len, e, type); default: break; } diff --git a/src/obj/limit.c b/src/obj/limit.c index 7f8bcf7..b0ed4c8 100644 --- a/src/obj/limit.c +++ b/src/obj/limit.c @@ -148,56 +148,6 @@ static int nftnl_obj_limit_parse(struct nftnl_obj *e, struct nlattr *attr) return 0; } -static int nftnl_obj_limit_json_parse(struct nftnl_obj *e, json_t *root, - struct nftnl_parse_err *err) -{ -#ifdef JSON_PARSING - uint64_t uval64; - uint32_t uval32; - - if (nftnl_jansson_parse_val(root, "rate", NFTNL_TYPE_U64, &uval64, - err) == 0) - nftnl_obj_set_u64(e, NFTNL_OBJ_LIMIT_RATE, uval64); - if (nftnl_jansson_parse_val(root, "unit", NFTNL_TYPE_U64, &uval64, - err) == 0) - nftnl_obj_set_u64(e, NFTNL_OBJ_LIMIT_UNIT, uval64); - if (nftnl_jansson_parse_val(root, "burst", NFTNL_TYPE_U32, &uval32, - err) == 0) - nftnl_obj_set_u32(e, NFTNL_OBJ_LIMIT_BURST, uval32); - if (nftnl_jansson_parse_val(root, "type", NFTNL_TYPE_U32, &uval32, - err) == 0) - nftnl_obj_set_u32(e, NFTNL_OBJ_LIMIT_TYPE, uval32); - if (nftnl_jansson_parse_val(root, "flags", NFTNL_TYPE_U32, &uval32, - err) == 0) - nftnl_obj_set_u32(e, NFTNL_OBJ_LIMIT_FLAGS, uval32); - - return 0; -#else - errno = EOPNOTSUPP; - return -1; -#endif -} - -static int nftnl_obj_limit_export(char *buf, size_t size, - const struct nftnl_obj *e, int type) -{ - struct nftnl_obj_limit *limit = nftnl_obj_data(e); - NFTNL_BUF_INIT(b, buf, size); - - if (e->flags & (1 << NFTNL_OBJ_LIMIT_RATE)) - nftnl_buf_u64(&b, type, limit->rate, RATE); - if (e->flags & (1 << NFTNL_OBJ_LIMIT_UNIT)) - nftnl_buf_u64(&b, type, limit->unit, UNIT); - if (e->flags & (1 << NFTNL_OBJ_LIMIT_BURST)) - nftnl_buf_u32(&b, type, limit->burst, BURST); - if (e->flags & (1 << NFTNL_OBJ_LIMIT_TYPE)) - nftnl_buf_u32(&b, type, limit->type, TYPE); - if (e->flags & (1 << NFTNL_OBJ_LIMIT_FLAGS)) - nftnl_buf_u32(&b, type, limit->flags, FLAGS); - - return nftnl_buf_done(&b); -} - static int nftnl_obj_limit_snprintf_default(char *buf, size_t len, const struct nftnl_obj *e) { @@ -220,7 +170,6 @@ static int nftnl_obj_limit_snprintf(char *buf, size_t len, uint32_t type, return nftnl_obj_limit_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_obj_limit_export(buf, len, e, type); default: break; } @@ -237,5 +186,4 @@ struct obj_ops obj_ops_limit = { .parse = nftnl_obj_limit_parse, .build = nftnl_obj_limit_build, .snprintf = nftnl_obj_limit_snprintf, - .json_parse = nftnl_obj_limit_json_parse, }; diff --git a/src/obj/quota.c b/src/obj/quota.c index 6d36784..b1a3f7e 100644 --- a/src/obj/quota.c +++ b/src/obj/quota.c @@ -125,47 +125,6 @@ nftnl_obj_quota_parse(struct nftnl_obj *e, struct nlattr *attr) return 0; } -static int -nftnl_obj_quota_json_parse(struct nftnl_obj *e, json_t *root, - struct nftnl_parse_err *err) -{ -#ifdef JSON_PARSING - uint64_t bytes; - uint32_t flags; - - if (nftnl_jansson_parse_val(root, "bytes", NFTNL_TYPE_U64, &bytes, - err) == 0) - nftnl_obj_set_u64(e, NFTNL_OBJ_QUOTA_BYTES, bytes); - if (nftnl_jansson_parse_val(root, "consumed", NFTNL_TYPE_U64, &bytes, - err) == 0) - nftnl_obj_set_u64(e, NFTNL_OBJ_QUOTA_CONSUMED, bytes); - if (nftnl_jansson_parse_val(root, "flags", NFTNL_TYPE_U32, &flags, - err) == 0) - nftnl_obj_set_u32(e, NFTNL_OBJ_QUOTA_FLAGS, flags); - - return 0; -#else - errno = EOPNOTSUPP; - return -1; -#endif -} - -static int nftnl_obj_quota_export(char *buf, size_t size, - const struct nftnl_obj *e, int type) -{ - struct nftnl_obj_quota *quota = nftnl_obj_data(e); - NFTNL_BUF_INIT(b, buf, size); - - if (e->flags & (1 << NFTNL_OBJ_QUOTA_BYTES)) - nftnl_buf_u64(&b, type, quota->bytes, BYTES); - if (e->flags & (1 << NFTNL_OBJ_QUOTA_CONSUMED)) - nftnl_buf_u64(&b, type, quota->consumed, CONSUMED); - if (e->flags & (1 << NFTNL_OBJ_QUOTA_FLAGS)) - nftnl_buf_u32(&b, type, quota->flags, FLAGS); - - return nftnl_buf_done(&b); -} - static int nftnl_obj_quota_snprintf_default(char *buf, size_t len, const struct nftnl_obj *e) { @@ -187,7 +146,6 @@ static int nftnl_obj_quota_snprintf(char *buf, size_t len, uint32_t type, return nftnl_obj_quota_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_obj_quota_export(buf, len, e, type); default: break; } @@ -204,5 +162,4 @@ struct obj_ops obj_ops_quota = { .parse = nftnl_obj_quota_parse, .build = nftnl_obj_quota_build, .snprintf = nftnl_obj_quota_snprintf, - .json_parse = nftnl_obj_quota_json_parse, }; diff --git a/src/obj/tunnel.c b/src/obj/tunnel.c index 32ca0fd..5b2d9de 100644 --- a/src/obj/tunnel.c +++ b/src/obj/tunnel.c @@ -530,18 +530,6 @@ nftnl_obj_tunnel_parse(struct nftnl_obj *e, struct nlattr *attr) return 0; } -static int nftnl_obj_tunnel_export(char *buf, size_t size, - const struct nftnl_obj *e, int type) -{ - struct nftnl_obj_tunnel *tun = nftnl_obj_data(e); - NFTNL_BUF_INIT(b, buf, size); - - if (e->flags & (1 << NFTNL_OBJ_TUNNEL_ID)) - nftnl_buf_u64(&b, type, tun->id, ID); - - return nftnl_buf_done(&b); -} - static int nftnl_obj_tunnel_snprintf_default(char *buf, size_t len, const struct nftnl_obj *e) { @@ -561,7 +549,6 @@ static int nftnl_obj_tunnel_snprintf(char *buf, size_t len, uint32_t type, return nftnl_obj_tunnel_snprintf_default(buf, len, e); case NFTNL_OUTPUT_XML: case NFTNL_OUTPUT_JSON: - return nftnl_obj_tunnel_export(buf, len, e, type); default: break; } |