]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: add input flags for nft_ctx
authorThomas Haller <thaller@redhat.com>
Fri, 18 Aug 2023 09:40:36 +0000 (11:40 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Aug 2023 07:01:45 +0000 (09:01 +0200)
Similar to the existing output flags, add input flags. No flags are yet
implemented, that will follow.

One difference to nft_ctx_output_set_flags(), is that the setter for
input flags returns the previously set flags.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Reviewed-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
doc/libnftables.adoc
include/nftables.h
include/nftables/libnftables.h
src/libnftables.c
src/libnftables.map

index 7ea0d56e9b1d164d82d2d369d3d32f08fc67def9..a0d3521e5e7acc4921b02844a7822e059d2ca21f 100644 (file)
@@ -18,6 +18,9 @@ void nft_ctx_free(struct nft_ctx* '\*ctx'*);
 bool nft_ctx_get_dry_run(struct nft_ctx* '\*ctx'*);
 void nft_ctx_set_dry_run(struct nft_ctx* '\*ctx'*, bool* 'dry'*);
 
+unsigned int nft_ctx_input_get_flags(struct nft_ctx* '\*ctx'*);
+unsigned int nft_ctx_input_set_flags(struct nft_ctx* '\*ctx'*, unsigned int* 'flags'*);
+
 unsigned int nft_ctx_output_get_flags(struct nft_ctx* '\*ctx'*);
 void nft_ctx_output_set_flags(struct nft_ctx* '\*ctx'*, unsigned int* 'flags'*);
 
@@ -78,6 +81,16 @@ The *nft_ctx_get_dry_run*() function returns the dry-run setting's value contain
 
 The *nft_ctx_set_dry_run*() function sets the dry-run setting in 'ctx' to the value of 'dry'.
 
+=== nft_ctx_input_get_flags() and nft_ctx_input_set_flags()
+The flags setting controls the input format.
+
+Currently no flags are implemented.
+
+The *nft_ctx_input_get_flags*() function returns the input flags setting's value in 'ctx'.
+
+The *nft_ctx_input_set_flags*() function sets the input flags setting in 'ctx' to the value of 'val'
+and returns the previous flags.
+
 === nft_ctx_output_get_flags() and nft_ctx_output_set_flags()
 The flags setting controls the output format.
 
index d49eb579dc0489303f0a8540bac633cb19782dac..7d35a95a89de603c459443eba7fbd2a36d50e21d 100644 (file)
@@ -23,6 +23,10 @@ struct symbol_tables {
        const struct symbol_table       *realm;
 };
 
+struct input_ctx {
+       unsigned int flags;
+};
+
 struct output_ctx {
        unsigned int flags;
        union {
@@ -119,6 +123,7 @@ struct nft_ctx {
        unsigned int            num_vars;
        unsigned int            parser_max_errors;
        unsigned int            debug_mask;
+       struct input_ctx        input;
        struct output_ctx       output;
        bool                    check;
        struct nft_cache        cache;
index 85e08c9bc98b2a22bbce860cd6183db2199a2ab5..9a05d3c4b90dbb6cd305ff104323578ecea363fe 100644 (file)
@@ -48,6 +48,9 @@ enum nft_optimize_flags {
 uint32_t nft_ctx_get_optimize(struct nft_ctx *ctx);
 void nft_ctx_set_optimize(struct nft_ctx *ctx, uint32_t flags);
 
+unsigned int nft_ctx_input_get_flags(struct nft_ctx *ctx);
+unsigned int nft_ctx_input_set_flags(struct nft_ctx *ctx, unsigned int flags);
+
 enum {
        NFT_CTX_OUTPUT_REVERSEDNS       = (1 << 0),
        NFT_CTX_OUTPUT_SERVICE          = (1 << 1),
index e214abb69cf257fb939e8b7b5611e4adcd9967c4..17438b5330cbd41beeffcbd101b04383feb9ea46 100644 (file)
@@ -401,6 +401,22 @@ void nft_ctx_set_optimize(struct nft_ctx *ctx, uint32_t flags)
        ctx->optimize_flags = flags;
 }
 
+EXPORT_SYMBOL(nft_ctx_input_get_flags);
+unsigned int nft_ctx_input_get_flags(struct nft_ctx *ctx)
+{
+       return ctx->input.flags;
+}
+
+EXPORT_SYMBOL(nft_ctx_input_set_flags);
+unsigned int nft_ctx_input_set_flags(struct nft_ctx *ctx, unsigned int flags)
+{
+       unsigned int old_flags;
+
+       old_flags = ctx->input.flags;
+       ctx->input.flags = flags;
+       return old_flags;
+}
+
 EXPORT_SYMBOL(nft_ctx_output_get_flags);
 unsigned int nft_ctx_output_get_flags(struct nft_ctx *ctx)
 {
index a46a3ad53ff6e07312f4bf11b613ae0aa0c3b635..9369f44f3536745f529fb5ea1ecb4dd0098400a5 100644 (file)
@@ -33,3 +33,8 @@ LIBNFTABLES_3 {
   nft_ctx_set_optimize;
   nft_ctx_get_optimize;
 } LIBNFTABLES_2;
+
+LIBNFTABLES_4 {
+  nft_ctx_input_get_flags;
+  nft_ctx_input_set_flags;
+} LIBNFTABLES_3;