]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
payload: split ll proto dependency into helper
authorFlorian Westphal <fw@strlen.de>
Thu, 18 May 2017 11:30:54 +0000 (13:30 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 18 May 2017 16:32:08 +0000 (18:32 +0200)
will be re-used in folloup patch for icmp/icmpv6 depenency
handling.

Signed-off-by: Florian Westphal <fw@strlen.de>
src/payload.c

index 55128fee14986a0efe96b26fbb865545430b1e07..31e5a0244837076ee6c40c6c1eff35da65f9b017 100644 (file)
@@ -223,22 +223,29 @@ static int payload_add_dependency(struct eval_ctx *ctx,
        return 0;
 }
 
+static const struct proto_desc *
+payload_get_get_ll_hdr(const struct eval_ctx *ctx)
+{
+       switch (ctx->pctx.family) {
+       case NFPROTO_INET:
+               return &proto_inet;
+       case NFPROTO_BRIDGE:
+               return &proto_eth;
+       case NFPROTO_NETDEV:
+               return &proto_netdev;
+       default:
+               break;
+       }
+
+       return NULL;
+}
+
 static const struct proto_desc *
 payload_gen_special_dependency(struct eval_ctx *ctx, const struct expr *expr)
 {
        switch (expr->payload.base) {
        case PROTO_BASE_LL_HDR:
-               switch (ctx->pctx.family) {
-               case NFPROTO_INET:
-                       return &proto_inet;
-               case NFPROTO_BRIDGE:
-                       return &proto_eth;
-               case NFPROTO_NETDEV:
-                       return &proto_netdev;
-               default:
-                       break;
-               }
-               break;
+               return payload_get_get_ll_hdr(ctx);
        case PROTO_BASE_TRANSPORT_HDR:
                if (expr->payload.desc == &proto_icmp)
                        return &proto_ip;