]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ | |
2 | #pragma once | |
3 | ||
4 | #include <inttypes.h> | |
5 | #include <netinet/in.h> | |
6 | #include <linux/fib_rules.h> | |
7 | #include <stdbool.h> | |
8 | ||
9 | #include "in-addr-util.h" | |
10 | #include "conf-parser.h" | |
11 | ||
12 | typedef struct RoutingPolicyRule RoutingPolicyRule; | |
13 | ||
14 | #include "networkd-link.h" | |
15 | #include "networkd-network.h" | |
16 | #include "networkd-util.h" | |
17 | ||
18 | typedef struct Network Network; | |
19 | typedef struct Link Link; | |
20 | typedef struct NetworkConfigSection NetworkConfigSection; | |
21 | typedef struct Manager Manager; | |
22 | ||
23 | struct RoutingPolicyRule { | |
24 | Manager *manager; | |
25 | Network *network; | |
26 | Link *link; | |
27 | NetworkConfigSection *section; | |
28 | ||
29 | bool invert_rule; | |
30 | ||
31 | uint8_t tos; | |
32 | uint8_t protocol; | |
33 | ||
34 | uint32_t table; | |
35 | uint32_t fwmark; | |
36 | uint32_t fwmask; | |
37 | uint32_t priority; | |
38 | ||
39 | int family; | |
40 | unsigned char to_prefixlen; | |
41 | unsigned char from_prefixlen; | |
42 | ||
43 | char *iif; | |
44 | char *oif; | |
45 | ||
46 | union in_addr_union to; | |
47 | union in_addr_union from; | |
48 | ||
49 | struct fib_rule_port_range sport; | |
50 | struct fib_rule_port_range dport; | |
51 | ||
52 | LIST_FIELDS(RoutingPolicyRule, rules); | |
53 | }; | |
54 | ||
55 | int routing_policy_rule_new(RoutingPolicyRule **ret); | |
56 | void routing_policy_rule_free(RoutingPolicyRule *rule); | |
57 | ||
58 | DEFINE_NETWORK_SECTION_FUNCTIONS(RoutingPolicyRule, routing_policy_rule_free); | |
59 | int routing_policy_rule_section_verify(RoutingPolicyRule *rule); | |
60 | ||
61 | int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, link_netlink_message_handler_t callback); | |
62 | int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, link_netlink_message_handler_t callback); | |
63 | ||
64 | int routing_policy_rule_add_foreign(Manager *m, RoutingPolicyRule *rule, RoutingPolicyRule **ret); | |
65 | int routing_policy_rule_get(Manager *m, RoutingPolicyRule *rule, RoutingPolicyRule **ret); | |
66 | int routing_policy_rule_make_local(Manager *m, RoutingPolicyRule *rule); | |
67 | int routing_policy_serialize_rules(Set *rules, FILE *f); | |
68 | int routing_policy_load_rules(const char *state_file, Set **rules); | |
69 | void routing_policy_rule_purge(Manager *m, Link *link); | |
70 | ||
71 | CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos); | |
72 | CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table); | |
73 | CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask); | |
74 | CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix); | |
75 | CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority); | |
76 | CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device); | |
77 | CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_port_range); | |
78 | CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_ip_protocol); | |
79 | CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_invert); |