]>
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 LP |
12 | |
13 | struct Route { | |
14 | Network *network; | |
f4859fc7 | 15 | NetworkConfigSection *section; |
fc2f9534 | 16 | |
1c8e710c TG |
17 | Link *link; |
18 | ||
fc2f9534 | 19 | int family; |
09f5dfad | 20 | int quickack; |
633c7258 | 21 | int fast_open_no_cookie; |
9b88f20a | 22 | int ttl_propagate; |
09f5dfad | 23 | |
fc2f9534 LP |
24 | unsigned char dst_prefixlen; |
25 | unsigned char src_prefixlen; | |
26 | unsigned char scope; | |
94d6e299 | 27 | bool scope_set; |
fc2f9534 | 28 | unsigned char protocol; /* RTPROT_* */ |
983226f3 | 29 | unsigned char type; /* RTN_* */ |
bb7ae737 | 30 | unsigned char tos; |
86655331 | 31 | uint32_t priority; /* note that ip(8) calls this 'metric' */ |
c953b24c | 32 | uint32_t table; |
94d6e299 | 33 | bool table_set; |
d6fceaf1 | 34 | uint32_t mtu; |
323d9329 SS |
35 | uint32_t initcwnd; |
36 | uint32_t initrwnd; | |
3b015d40 TG |
37 | unsigned char pref; |
38 | unsigned flags; | |
54901fd2 | 39 | int gateway_onlink; |
fc2f9534 | 40 | |
2ce40956 TG |
41 | union in_addr_union gw; |
42 | union in_addr_union dst; | |
43 | union in_addr_union src; | |
44 | union in_addr_union prefsrc; | |
fc2f9534 | 45 | |
f833694d TG |
46 | usec_t lifetime; |
47 | sd_event_source *expire; | |
48 | ||
fc2f9534 LP |
49 | LIST_FIELDS(Route, routes); |
50 | }; | |
51 | ||
01aaa3df YW |
52 | extern const struct hash_ops route_full_hash_ops; |
53 | ||
ed9e361a | 54 | int route_new(Route **ret); |
fc2f9534 | 55 | void route_free(Route *route); |
302a796f YW |
56 | int route_configure(Route *route, Link *link, link_netlink_message_handler_t callback); |
57 | int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback); | |
fc2f9534 | 58 | |
0b1cd3e2 WKI |
59 | int route_get(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, const union in_addr_union *gw, unsigned char tos, uint32_t priority, uint32_t table, Route **ret); |
60 | int route_add(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, const union in_addr_union *gw, unsigned char tos, uint32_t priority, uint32_t table, Route **ret); | |
61 | int route_add_foreign(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, const union in_addr_union *gw, unsigned char tos, uint32_t priority, uint32_t table, Route **ret); | |
bbd15900 | 62 | void route_update(Route *route, const union in_addr_union *src, unsigned char src_prefixlen, const union in_addr_union *gw, const union in_addr_union *prefsrc, unsigned char scope, unsigned char protocol, unsigned char type); |
7ecf0c3e | 63 | bool route_equal(Route *r1, Route *r2); |
1c8e710c | 64 | |
f833694d | 65 | int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata); |
fcbf4cb7 | 66 | int route_section_verify(Route *route, Network *network); |
f833694d | 67 | |
fcbf4cb7 | 68 | DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free); |
fc2f9534 | 69 | |
fa7cd711 | 70 | int network_add_ipv4ll_route(Network *network); |
5d5003ab | 71 | int network_add_default_route_on_device(Network *network); |
fa7cd711 | 72 | |
7a22312d YW |
73 | const char* route_type_to_string(int t) _const_; |
74 | int route_type_from_string(const char *s) _pure_; | |
75 | ||
b297e0a7 YW |
76 | #define ROUTE_SCOPE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("nowhere") + 1) |
77 | const char *format_route_scope(int scope, char *buf, size_t size); | |
78 | ||
79 | #define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1) | |
80 | const char *format_route_table(int table, char *buf, size_t size); | |
81 | ||
ca420b62 | 82 | #define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1) |
d3e291fd YW |
83 | const char *format_route_protocol(int protocol, char *buf, size_t size); |
84 | ||
a2106925 LP |
85 | CONFIG_PARSER_PROTOTYPE(config_parse_gateway); |
86 | CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src); | |
87 | CONFIG_PARSER_PROTOTYPE(config_parse_destination); | |
88 | CONFIG_PARSER_PROTOTYPE(config_parse_route_priority); | |
89 | CONFIG_PARSER_PROTOTYPE(config_parse_route_scope); | |
90 | CONFIG_PARSER_PROTOTYPE(config_parse_route_table); | |
91 | CONFIG_PARSER_PROTOTYPE(config_parse_gateway_onlink); | |
92 | CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference); | |
93 | CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol); | |
94 | CONFIG_PARSER_PROTOTYPE(config_parse_route_type); | |
95 | CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window); | |
96 | CONFIG_PARSER_PROTOTYPE(config_parse_quickack); | |
633c7258 | 97 | CONFIG_PARSER_PROTOTYPE(config_parse_fast_open_no_cookie); |
9b88f20a | 98 | CONFIG_PARSER_PROTOTYPE(config_parse_route_ttl_propagate); |
cea79e66 | 99 | CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu); |