]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
fc2f9534 LP |
2 | #pragma once |
3 | ||
a2106925 | 4 | #include "conf-parser.h" |
b297e0a7 | 5 | #include "macro.h" |
a2106925 | 6 | |
fc2f9534 | 7 | typedef struct Route Route; |
f4859fc7 | 8 | typedef struct NetworkConfigSection NetworkConfigSection; |
fc2f9534 | 9 | |
fc2f9534 | 10 | #include "networkd-network.h" |
fcbf4cb7 | 11 | #include "networkd-util.h" |
fc2f9534 | 12 | |
6ff5cc6b YW |
13 | typedef struct MultipathRouteVia { |
14 | uint16_t family; | |
15 | union in_addr_union address; | |
16 | } _packed_ MultipathRouteVia; | |
17 | ||
18 | typedef struct MultipathRoute { | |
19 | MultipathRouteVia gateway; | |
20 | int ifindex; | |
21 | uint32_t weight; | |
22 | } MultipathRoute; | |
23 | ||
fc2f9534 LP |
24 | struct Route { |
25 | Network *network; | |
f4859fc7 | 26 | NetworkConfigSection *section; |
fc2f9534 | 27 | |
1c8e710c TG |
28 | Link *link; |
29 | ||
fc2f9534 | 30 | int family; |
09f5dfad | 31 | int quickack; |
633c7258 | 32 | int fast_open_no_cookie; |
9b88f20a | 33 | int ttl_propagate; |
09f5dfad | 34 | |
fc2f9534 LP |
35 | unsigned char dst_prefixlen; |
36 | unsigned char src_prefixlen; | |
37 | unsigned char scope; | |
94d6e299 | 38 | bool scope_set; |
fc2f9534 | 39 | unsigned char protocol; /* RTPROT_* */ |
983226f3 | 40 | unsigned char type; /* RTN_* */ |
bb7ae737 | 41 | unsigned char tos; |
86655331 | 42 | uint32_t priority; /* note that ip(8) calls this 'metric' */ |
c953b24c | 43 | uint32_t table; |
94d6e299 | 44 | bool table_set; |
d6fceaf1 | 45 | uint32_t mtu; |
323d9329 SS |
46 | uint32_t initcwnd; |
47 | uint32_t initrwnd; | |
3b015d40 TG |
48 | unsigned char pref; |
49 | unsigned flags; | |
54901fd2 | 50 | int gateway_onlink; |
1985c54f | 51 | bool gateway_from_dhcp; |
fc2f9534 | 52 | |
2ce40956 TG |
53 | union in_addr_union gw; |
54 | union in_addr_union dst; | |
55 | union in_addr_union src; | |
56 | union in_addr_union prefsrc; | |
6ff5cc6b | 57 | OrderedSet *multipath_routes; |
fc2f9534 | 58 | |
f833694d TG |
59 | usec_t lifetime; |
60 | sd_event_source *expire; | |
61 | ||
fc2f9534 LP |
62 | LIST_FIELDS(Route, routes); |
63 | }; | |
64 | ||
c077a205 | 65 | extern const struct hash_ops route_hash_ops; |
01aaa3df | 66 | |
ed9e361a | 67 | int route_new(Route **ret); |
fc2f9534 | 68 | void route_free(Route *route); |
80b0e860 | 69 | int route_configure(Route *route, Link *link, link_netlink_message_handler_t callback, Route **ret); |
302a796f | 70 | int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback); |
fc2f9534 | 71 | |
f1368755 YW |
72 | int route_get(Link *link, Route *in, Route **ret); |
73 | int route_add(Link *link, Route *in, Route **ret); | |
74 | int route_add_foreign(Link *link, Route *in, Route **ret); | |
7ecf0c3e | 75 | bool route_equal(Route *r1, Route *r2); |
1c8e710c | 76 | |
f833694d | 77 | int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata); |
fcbf4cb7 | 78 | int route_section_verify(Route *route, Network *network); |
f833694d | 79 | |
fcbf4cb7 | 80 | DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free); |
fc2f9534 | 81 | |
fa7cd711 | 82 | int network_add_ipv4ll_route(Network *network); |
5d5003ab | 83 | int network_add_default_route_on_device(Network *network); |
fa7cd711 | 84 | |
7a22312d YW |
85 | const char* route_type_to_string(int t) _const_; |
86 | int route_type_from_string(const char *s) _pure_; | |
87 | ||
b297e0a7 YW |
88 | #define ROUTE_SCOPE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("nowhere") + 1) |
89 | const char *format_route_scope(int scope, char *buf, size_t size); | |
90 | ||
91 | #define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1) | |
92 | const char *format_route_table(int table, char *buf, size_t size); | |
93 | ||
ca420b62 | 94 | #define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1) |
d3e291fd YW |
95 | const char *format_route_protocol(int protocol, char *buf, size_t size); |
96 | ||
a2106925 LP |
97 | CONFIG_PARSER_PROTOTYPE(config_parse_gateway); |
98 | CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src); | |
99 | CONFIG_PARSER_PROTOTYPE(config_parse_destination); | |
100 | CONFIG_PARSER_PROTOTYPE(config_parse_route_priority); | |
101 | CONFIG_PARSER_PROTOTYPE(config_parse_route_scope); | |
102 | CONFIG_PARSER_PROTOTYPE(config_parse_route_table); | |
d96edb2c | 103 | CONFIG_PARSER_PROTOTYPE(config_parse_route_boolean); |
a2106925 LP |
104 | CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference); |
105 | CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol); | |
106 | CONFIG_PARSER_PROTOTYPE(config_parse_route_type); | |
107 | CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window); | |
cea79e66 | 108 | CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu); |
6ff5cc6b | 109 | CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route); |