]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-routing-policy-rule.h
Merge pull request #11031 from poettering/gcc-attr-cleanup
[thirdparty/systemd.git] / src / network / networkd-routing-policy-rule.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <inttypes.h>
5 #include <linux/fib_rules.h>
6 #include <stdbool.h>
7
8 #include "in-addr-util.h"
9 #include "conf-parser.h"
10
11 typedef struct RoutingPolicyRule RoutingPolicyRule;
12
13 #include "networkd-link.h"
14 #include "networkd-network.h"
15
16 typedef struct Network Network;
17 typedef struct Link Link;
18 typedef struct NetworkConfigSection NetworkConfigSection;
19 typedef struct Manager Manager;
20
21 struct RoutingPolicyRule {
22 Manager *manager;
23 Network *network;
24 Link *link;
25 NetworkConfigSection *section;
26
27 uint8_t tos;
28 uint8_t protocol;
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
39 char *iif;
40 char *oif;
41
42 union in_addr_union to;
43 union in_addr_union from;
44
45 struct fib_rule_port_range sport;
46 struct fib_rule_port_range dport;
47
48 LIST_FIELDS(RoutingPolicyRule, rules);
49 };
50
51 int routing_policy_rule_new(RoutingPolicyRule **ret);
52 void routing_policy_rule_free(RoutingPolicyRule *rule);
53
54 DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule*, routing_policy_rule_free);
55
56 int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, link_netlink_message_handler_t callback, bool update);
57 int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, link_netlink_message_handler_t callback);
58
59 int 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,
60 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,
61 const struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
62 int 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,
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);
65 int 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,
66 uint32_t fwmark, uint32_t table, const char *iif, const char *oif, uint8_t protocol, struct fib_rule_port_range *sport,
67 struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
68 int routing_policy_rule_make_local(Manager *m, RoutingPolicyRule *rule);
69 int routing_policy_serialize_rules(Set *rules, FILE *f);
70 int routing_policy_load_rules(const char *state_file, Set **rules);
71 void routing_policy_rule_purge(Manager *m, Link *link);
72
73 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos);
74 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table);
75 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask);
76 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix);
77 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority);
78 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device);
79 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_port_range);
80 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_ip_protocol);