]> git.ipfire.org Git - thirdparty/nftables.git/commit
json: Support typeof in set and map types
authorPhil Sutter <phil@nwl.cc>
Fri, 27 Sep 2024 22:55:34 +0000 (00:55 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 6 Nov 2024 10:00:21 +0000 (11:00 +0100)
commitbb6312484af93a83a9ec8716f3887a43566a775a
tree9e4a151a53d0ef3011a8e9bf1a0048b85da4f512
parent193faa5475a5df7d9ac0b1a8fe647196de3e5688
json: Support typeof in set and map types

Implement this as a special "type" property value which is an object
with sole property "typeof". The latter's value is the JSON
representation of the expression in set->key, so for concatenated
typeofs it is a concat expression.

All this is a bit clumsy right now but it works and it should be
possible to tear it down a bit for more user-friendliness in a
compatible way by either replacing the concat expression by the array it
contains or even the whole "typeof" object - the parser would just
assume any object (or objects in an array) in the "type" property value
are expressions to extract a type from.

Signed-off-by: Phil Sutter <phil@nwl.cc>
15 files changed:
doc/libnftables-json.adoc
src/json.c
src/parser_json.c
tests/monitor/testcases/map-expr.t
tests/monitor/testcases/set-concat-interval.t
tests/shell/testcases/maps/dumps/0012map_concat_0.json-nft
tests/shell/testcases/maps/dumps/0017_map_variable_0.json-nft
tests/shell/testcases/maps/dumps/named_limits.json-nft
tests/shell/testcases/maps/dumps/typeof_maps_add_delete.json-nft
tests/shell/testcases/maps/dumps/typeof_maps_update_0.json-nft
tests/shell/testcases/maps/dumps/vmap_timeout.json-nft
tests/shell/testcases/packetpath/dumps/set_lookups.json-nft
tests/shell/testcases/sets/dumps/0048set_counters_0.json-nft
tests/shell/testcases/sets/dumps/inner_0.json-nft
tests/shell/testcases/sets/dumps/set_element_timeout_updates.json-nft