]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/firewall-util-private.h
Merge pull request #18863 from keszybz/cmdline-escaping
[thirdparty/systemd.git] / src / shared / firewall-util-private.h
CommitLineData
7a6eb60b 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
31220972
FW
2#pragma once
3
4#include <stdbool.h>
5#include <stdint.h>
6
715a70e7 7#include "sd-netlink.h"
31220972 8
da00b840
YW
9#include "in-addr-util.h"
10
11typedef enum FirewallBackend {
761cf19d
FW
12 FW_BACKEND_NONE,
13#if HAVE_LIBIPTC
14 FW_BACKEND_IPTABLES,
15#endif
715a70e7 16 FW_BACKEND_NFTABLES,
da00b840
YW
17 _FW_BACKEND_MAX,
18 _FW_BACKEND_INVALID = -EINVAL,
19} FirewallBackend;
761cf19d
FW
20
21struct FirewallContext {
da00b840 22 FirewallBackend backend;
715a70e7 23 sd_netlink *nfnl;
761cf19d
FW
24};
25
da00b840
YW
26const char *firewall_backend_to_string(FirewallBackend b) _const_;
27
715a70e7
FW
28int fw_nftables_init(FirewallContext *ctx);
29void fw_nftables_exit(FirewallContext *ctx);
30
31int fw_nftables_add_masquerade(
32 FirewallContext *ctx,
33 bool add,
34 int af,
35 const union in_addr_union *source,
36 unsigned source_prefixlen);
37
38int fw_nftables_add_local_dnat(
39 FirewallContext *ctx,
40 bool add,
41 int af,
42 int protocol,
43 uint16_t local_port,
44 const union in_addr_union *remote,
45 uint16_t remote_port,
46 const union in_addr_union *previous_remote);
47
31220972 48#if HAVE_LIBIPTC
afbcd905 49struct xtc_handle;
31220972
FW
50
51int fw_iptables_add_masquerade(
52 bool add,
53 int af,
54 const union in_addr_union *source,
55 unsigned source_prefixlen);
56
57int fw_iptables_add_local_dnat(
58 bool add,
59 int af,
60 int protocol,
61 uint16_t local_port,
62 const union in_addr_union *remote,
63 uint16_t remote_port,
64 const union in_addr_union *previous_remote);
afbcd905
AZ
65
66int fw_iptables_init_nat(struct xtc_handle **ret);
31220972 67#endif