Debian Codegraph @

src/shared/firewall-util.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "conf-parser-forward.h"
5 #include "shared-forward.h"
6
7 int fw_nftables_add_masquerade(
8 sd_netlink *nfnl,
9 bool add,
10 int af,
11 const union in_addr_union *source,
12 unsigned source_prefixlen);
13
14 int fw_nftables_add_local_dnat(
15 sd_netlink *nfnl,
16 bool add,
17 int af,
18 int protocol,
19 uint16_t local_port,
20 const union in_addr_union *remote,
21 uint16_t remote_port,
22 const union in_addr_union *previous_remote);
23
24 typedef enum NFTSetSource {
25 NFT_SET_SOURCE_ADDRESS,
26 NFT_SET_SOURCE_PREFIX,
27 NFT_SET_SOURCE_IFINDEX,
28 NFT_SET_SOURCE_CGROUP,
29 NFT_SET_SOURCE_USER,
30 NFT_SET_SOURCE_GROUP,
31 _NFT_SET_SOURCE_MAX,
32 _NFT_SET_SOURCE_INVALID = -EINVAL,
33 } NFTSetSource;
34
35 typedef struct NFTSet {
36 NFTSetSource source;
37 int nfproto;
38 char *table;
39 char *set;
40 } NFTSet;
41
42 typedef struct NFTSetContext {
43 NFTSet *sets;
44 size_t n_sets;
45 } NFTSetContext;
46
47 void nft_set_context_clear(NFTSetContext *s);
48 int nft_set_context_dup(const NFTSetContext *src, NFTSetContext *dst);
49
50 DECLARE_STRING_TABLE_LOOKUP(nfproto, int);
51
52 DECLARE_STRING_TABLE_LOOKUP(nft_set_source, int);
53
54 int nft_set_element_modify_iprange(
55 sd_netlink *nfnl,
56 bool add,
57 int nfproto,
58 int af,
59 const char *table,
60 const char *set,
61 const union in_addr_union *source,
62 unsigned source_prefixlen);
63
64 int nft_set_element_modify_ip(
65 sd_netlink *nfnl,
66 bool add,
67 int nfproto,
68 int af,
69 const char *table,
70 const char *set,
71 const union in_addr_union *source);
72
73 int nft_set_element_modify_any(
74 sd_netlink *nfnl,
75 bool add,
76 int nfproto,
77 const char *table,
78 const char *set,
79 const void *element,
80 size_t element_size);
81
82 int nft_set_add(NFTSetContext *s, NFTSetSource source, int nfproto, const char *table, const char *set);
83
84 typedef enum NFTSetParseFlags {
85 NFT_SET_PARSE_NETWORK,
86 NFT_SET_PARSE_CGROUP,
87 } NFTSetParseFlags;
88
89 CONFIG_PARSER_PROTOTYPE(config_parse_nft_set);