Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | From 8d8cfe5ad6ca460a5262fb15fdbef3601058c784 Mon Sep 17 00:00:00 2001 |
| 2 | From: Florian Westphal <fw@strlen.de> |
| 3 | Date: Thu, 18 May 2017 13:30:54 +0200 |
| 4 | Subject: [PATCH 1/4] payload: split ll proto dependency into helper |
| 5 | |
| 6 | will be re-used in folloup patch for icmp/icmpv6 depenency |
| 7 | handling. |
| 8 | |
| 9 | Signed-off-by: Florian Westphal <fw@strlen.de> |
| 10 | --- |
| 11 | Upstream-Status: Backport |
| 12 | Signed-off-by: André Draszik <adraszik@tycoint.com> |
| 13 | src/payload.c | 29 ++++++++++++++++++----------- |
| 14 | 1 file changed, 18 insertions(+), 11 deletions(-) |
| 15 | |
| 16 | diff --git a/src/payload.c b/src/payload.c |
| 17 | index 55128fe..31e5a02 100644 |
| 18 | --- a/src/payload.c |
| 19 | +++ b/src/payload.c |
| 20 | @@ -224,21 +224,28 @@ static int payload_add_dependency(struct eval_ctx *ctx, |
| 21 | } |
| 22 | |
| 23 | static const struct proto_desc * |
| 24 | +payload_get_get_ll_hdr(const struct eval_ctx *ctx) |
| 25 | +{ |
| 26 | + switch (ctx->pctx.family) { |
| 27 | + case NFPROTO_INET: |
| 28 | + return &proto_inet; |
| 29 | + case NFPROTO_BRIDGE: |
| 30 | + return &proto_eth; |
| 31 | + case NFPROTO_NETDEV: |
| 32 | + return &proto_netdev; |
| 33 | + default: |
| 34 | + break; |
| 35 | + } |
| 36 | + |
| 37 | + return NULL; |
| 38 | +} |
| 39 | + |
| 40 | +static const struct proto_desc * |
| 41 | payload_gen_special_dependency(struct eval_ctx *ctx, const struct expr *expr) |
| 42 | { |
| 43 | switch (expr->payload.base) { |
| 44 | case PROTO_BASE_LL_HDR: |
| 45 | - switch (ctx->pctx.family) { |
| 46 | - case NFPROTO_INET: |
| 47 | - return &proto_inet; |
| 48 | - case NFPROTO_BRIDGE: |
| 49 | - return &proto_eth; |
| 50 | - case NFPROTO_NETDEV: |
| 51 | - return &proto_netdev; |
| 52 | - default: |
| 53 | - break; |
| 54 | - } |
| 55 | - break; |
| 56 | + return payload_get_get_ll_hdr(ctx); |
| 57 | case PROTO_BASE_TRANSPORT_HDR: |
| 58 | if (expr->payload.desc == &proto_icmp) |
| 59 | return &proto_ip; |
| 60 | -- |
| 61 | 2.11.0 |
| 62 | |