]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-routing-policy-rule.h
networkd: RPDB rule - add support to configure inverted rule.
[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"
36dd5ffd 10#include "missing_fib_rules.h"
bce67bbe
SS
11
12typedef struct RoutingPolicyRule RoutingPolicyRule;
13
14#include "networkd-link.h"
15#include "networkd-network.h"
16
17typedef struct Network Network;
18typedef struct Link Link;
19typedef struct NetworkConfigSection NetworkConfigSection;
36e6e28b 20typedef struct Manager Manager;
bce67bbe
SS
21
22struct RoutingPolicyRule {
6964cf45 23 Manager *manager;
bce67bbe
SS
24 Network *network;
25 Link *link;
26 NetworkConfigSection *section;
27
8b220643
SS
28 bool invert_rule;
29
bce67bbe 30 uint8_t tos;
926062f0 31 uint8_t protocol;
bce67bbe
SS
32
33 uint32_t table;
34 uint32_t fwmark;
35 uint32_t fwmask;
36 uint32_t priority;
37
38 int family;
39 unsigned char to_prefixlen;
40 unsigned char from_prefixlen;
41
762e2659
SS
42 char *iif;
43 char *oif;
44
bce67bbe
SS
45 union in_addr_union to;
46 union in_addr_union from;
47
926062f0
SS
48 struct fib_rule_port_range sport;
49 struct fib_rule_port_range dport;
50
bce67bbe
SS
51 LIST_FIELDS(RoutingPolicyRule, rules);
52};
53
54int routing_policy_rule_new(RoutingPolicyRule **ret);
55void routing_policy_rule_free(RoutingPolicyRule *rule);
56
57DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule*, routing_policy_rule_free);
bce67bbe 58
302a796f
YW
59int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, link_netlink_message_handler_t callback, bool update);
60int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, link_netlink_message_handler_t callback);
bce67bbe
SS
61
62int 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
63 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,
64 const struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
bce67bbe 65int 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
66 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,
67 const struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
bce67bbe 68int 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
69 uint32_t fwmark, uint32_t table, const char *iif, const char *oif, uint8_t protocol, struct fib_rule_port_range *sport,
70 struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
bce67bbe 71int routing_policy_rule_make_local(Manager *m, RoutingPolicyRule *rule);
458d8ae3
ZJS
72int routing_policy_serialize_rules(Set *rules, FILE *f);
73int routing_policy_load_rules(const char *state_file, Set **rules);
bce67bbe
SS
74void routing_policy_rule_purge(Manager *m, Link *link);
75
a2106925
LP
76CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos);
77CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table);
78CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask);
79CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix);
80CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority);
81CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device);
926062f0 82CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_port_range);
97f9df9e 83CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_ip_protocol);
8b220643 84CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_invert);