Line data Source code
1 : /* SPDX-License-Identifier: GPL-2.0-only */
2 : /*
3 : * Copyright (c) 2023 Meta Platforms, Inc. and affiliates.
4 : */
5 :
6 : #include "bpfilter/xlate/front.h"
7 :
8 : #include "core/front.h"
9 : #include "core/helper.h"
10 :
11 : extern const struct bf_front_ops ipt_front;
12 : extern const struct bf_front_ops nft_front;
13 : extern const struct bf_front_ops cli_front;
14 :
15 1 : const struct bf_front_ops *bf_front_ops_get(enum bf_front front)
16 : {
17 1 : bf_assert(0 <= front && front < _BF_FRONT_MAX);
18 :
19 : static const struct bf_front_ops *fronts[] = {
20 : [BF_FRONT_IPT] = &ipt_front,
21 : [BF_FRONT_NFT] = &nft_front,
22 : [BF_FRONT_CLI] = &cli_front,
23 : };
24 :
25 : // We need to have an entry for each value in `bf_front` enumeration.
26 : static_assert(ARRAY_SIZE(fronts) == _BF_FRONT_MAX,
27 : "missing entries in fronts array");
28 :
29 1 : return fronts[front];
30 : }
|