From: Phil Sutter Date: Tue, 28 Aug 2018 20:26:56 +0000 (+0200) Subject: json: Fix compile error X-Git-Tag: v0.9.1~304 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0c0f90bcca71b35f3d50bad0c612ca1ce46d1351;p=thirdparty%2Fnftables.git json: Fix compile error Commit 9e45a28ca467f ("src: honor /etc/services") broke compiling with JSON support enabled: inet_service_type_print() is not suited for converting inet_service datatype into JSON at all. In order to avoid having to replicate the port value resolving into human-readable name in inet_service_type_json(), just return a numeric value. At least for JSON output, this probably makes most sense either way since the output is expected to be parsed by scripts which have an easier time with numers than names anyway. Fixes: 9e45a28ca467f ("src: honor /etc/services") Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/json.c b/src/json.c index b70a53f2..00d24764 100644 --- a/src/json.c +++ b/src/json.c @@ -861,10 +861,7 @@ json_t *inet_protocol_type_json(const struct expr *expr, json_t *inet_service_type_json(const struct expr *expr, struct output_ctx *octx) { - if (octx->numeric >= NFT_NUMERIC_PORT) - return integer_type_json(expr, octx); - - return inet_service_type_print(expr, octx); + return json_integer(ntohs(mpz_get_be16(expr->value))); } json_t *mark_type_json(const struct expr *expr, struct output_ctx *octx)