libnl: /data/src/libnl/lib/netfilter/netfilter.c Source File

libnl 3.12.0

netfilter.c
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
4 */
5
6#include "nl-default.h"
7
8#include <linux/netfilter.h>
9
10#include <netlink/netfilter/netfilter.h>
11
12#include "nl-priv-dynamic-core/nl-core.h"
13
14static const struct trans_tbl nfnl_verdicts[] = {
15 __ADD(NF_DROP, NF_DROP),
16 __ADD(NF_ACCEPT, NF_ACCEPT),
17 __ADD(NF_STOLEN, NF_STOLEN),
18 __ADD(NF_QUEUE, NF_QUEUE),
19 __ADD(NF_REPEAT, NF_REPEAT),
20 __ADD(NF_STOP, NF_STOP),
21};
22
23char *nfnl_verdict2str(unsigned int verdict, char *buf, size_t len)
24{
25 return __type2str(verdict, buf, len, nfnl_verdicts,
26 ARRAY_SIZE(nfnl_verdicts));
27}
28
29unsigned int nfnl_str2verdict(const char *name)
30{
31 return __str2type(name, nfnl_verdicts, ARRAY_SIZE(nfnl_verdicts));
32}
33
34static const struct trans_tbl nfnl_inet_hooks[] = {
35 __ADD(NF_INET_PRE_ROUTING, NF_INET_PREROUTING),
36 __ADD(NF_INET_LOCAL_IN, NF_INET_LOCAL_IN),
37 __ADD(NF_INET_FORWARD, NF_INET_FORWARD),
38 __ADD(NF_INET_LOCAL_OUT, NF_INET_LOCAL_OUT),
39 __ADD(NF_INET_POST_ROUTING, NF_INET_POST_ROUTING),
40};
41
42char *nfnl_inet_hook2str(unsigned int hook, char *buf, size_t len)
43{
44 return __type2str(hook, buf, len, nfnl_inet_hooks,
45 ARRAY_SIZE(nfnl_inet_hooks));
46}
47
48unsigned int nfnl_str2inet_hook(const char *name)
49{
50 return __str2type(name, nfnl_inet_hooks, ARRAY_SIZE(nfnl_inet_hooks));
51}