]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft-shared: Introduce __get_cmp_data()
authorPhil Sutter <phil@nwl.cc>
Tue, 27 Sep 2022 21:15:37 +0000 (23:15 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 28 Sep 2022 12:21:13 +0000 (14:21 +0200)
This is an inner function to get_cmp_data() returning the op value as-is
for caller examination.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/nft-shared.c
iptables/nft-shared.h

index 555f74f035305e04e4f12ffdc579da0fc1db0878..f8de2b715dd610a82457fa00ded4c85651b6c033 100644 (file)
@@ -471,17 +471,20 @@ static void nft_parse_match(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
                ctx->h->ops->parse_match(match, ctx->cs);
 }
 
-void get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, bool *inv)
+void __get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, uint8_t *op)
 {
        uint32_t len;
-       uint8_t op;
 
        memcpy(data, nftnl_expr_get(e, NFTNL_EXPR_CMP_DATA, &len), dlen);
-       op = nftnl_expr_get_u32(e, NFTNL_EXPR_CMP_OP);
-       if (op == NFT_CMP_NEQ)
-               *inv = true;
-       else
-               *inv = false;
+       *op = nftnl_expr_get_u32(e, NFTNL_EXPR_CMP_OP);
+}
+
+void get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, bool *inv)
+{
+       uint8_t op;
+
+       __get_cmp_data(e, data, dlen, &op);
+       *inv = (op == NFT_CMP_NEQ);
 }
 
 static void nft_meta_set_to_target(struct nft_xt_ctx *ctx,
index 421706389e55885b944c6ba0b28e047161cc0e86..8fcedcdd78fbe9465d6745e2078e936d465b5cfe 100644 (file)
@@ -217,6 +217,7 @@ bool is_same_interfaces(const char *a_iniface, const char *a_outiface,
 int parse_meta(struct nft_xt_ctx *ctx, struct nftnl_expr *e, uint8_t key,
               char *iniface, unsigned char *iniface_mask, char *outiface,
               unsigned char *outiface_mask, uint8_t *invflags);
+void __get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, uint8_t *op);
 void get_cmp_data(struct nftnl_expr *e, void *data, size_t dlen, bool *inv);
 void nft_rule_to_iptables_command_state(struct nft_handle *h,
                                        const struct nftnl_rule *r,