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