]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-routing-policy-rule.h
networkd: add support to configure ip rule port range and protocol.
[thirdparty/systemd.git] / src / network / networkd-routing-policy-rule.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
bce67bbe
SS
2#pragma once
3
bce67bbe 4#include <inttypes.h>
926062f0 5#include <linux/fib_rules.h>
bce67bbe
SS
6#include <stdbool.h>
7
8#include "in-addr-util.h"
a2106925 9#include "conf-parser.h"
bce67bbe
SS
10
11typedef struct RoutingPolicyRule RoutingPolicyRule;
12
13#include "networkd-link.h"
14#include "networkd-network.h"
15
16typedef struct Network Network;
17typedef struct Link Link;
18typedef struct NetworkConfigSection NetworkConfigSection;
36e6e28b 19typedef struct Manager Manager;
bce67bbe
SS
20
21struct RoutingPolicyRule {
6964cf45 22 Manager *manager;
bce67bbe
SS
23 Network *network;
24 Link *link;
25 NetworkConfigSection *section;
26
27 uint8_t tos;
926062f0 28 uint8_t protocol;
bce67bbe
SS
29
30 uint32_t table;
31 uint32_t fwmark;
32 uint32_t fwmask;
33 uint32_t priority;
34
35 int family;
36 unsigned char to_prefixlen;
37 unsigned char from_prefixlen;
38
762e2659
SS
39 char *iif;
40 char *oif;
41
bce67bbe
SS
42 union in_addr_union to;
43 union in_addr_union from;
44
926062f0
SS
45 struct fib_rule_port_range sport;
46 struct fib_rule_port_range dport;
47
bce67bbe
SS
48 LIST_FIELDS(RoutingPolicyRule, rules);
49};
50
51int routing_policy_rule_new(RoutingPolicyRule **ret);
52void routing_policy_rule_free(RoutingPolicyRule *rule);
53
54DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule*, routing_policy_rule_free);
bce67bbe
SS
55
56int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, sd_netlink_message_handler_t callback, bool update);
57int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, sd_netlink_message_handler_t callback);
58int link_routing_policy_rule_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata);
59int link_routing_policy_rule_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata);
60
61int routing_policy_rule_add(Manager *m, int family, const union in_addr_union *from, uint8_t from_prefixlen, const union in_addr_union *to, uint8_t to_prefixlen,
926062f0
SS
62 uint8_t tos, uint32_t fwmark, uint32_t table, const char *iif, const char *oif, uint8_t protocol, const struct fib_rule_port_range *sport,
63 const struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
bce67bbe 64int routing_policy_rule_add_foreign(Manager *m, int family, const union in_addr_union *from, uint8_t from_prefixlen, const union in_addr_union *to, uint8_t to_prefixlen,
926062f0
SS
65 uint8_t tos, uint32_t fwmark, uint32_t table, const char *iif, const char *oif, uint8_t protocol, const struct fib_rule_port_range *sport,
66 const struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
bce67bbe 67int routing_policy_rule_get(Manager *m, int family, const union in_addr_union *from, uint8_t from_prefixlen, const union in_addr_union *to, uint8_t to_prefixlen, uint8_t tos,
926062f0
SS
68 uint32_t fwmark, uint32_t table, const char *iif, const char *oif, uint8_t protocol, struct fib_rule_port_range *sport,
69 struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
bce67bbe 70int routing_policy_rule_make_local(Manager *m, RoutingPolicyRule *rule);
458d8ae3
ZJS
71int routing_policy_serialize_rules(Set *rules, FILE *f);
72int routing_policy_load_rules(const char *state_file, Set **rules);
bce67bbe
SS
73void routing_policy_rule_purge(Manager *m, Link *link);
74
a2106925
LP
75CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos);
76CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table);
77CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask);
78CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix);
79CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority);
80CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device);
926062f0
SS
81CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_port_range);
82CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_protocol);