]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
fc2f9534 LP |
2 | #pragma once |
3 | ||
e2263711 YW |
4 | #include <inttypes.h> |
5 | #include <stdbool.h> | |
6 | #include <stdio.h> | |
a2106925 | 7 | |
e2263711 | 8 | #include "sd-netlink.h" |
fc2f9534 | 9 | |
e2263711 YW |
10 | #include "conf-parser.h" |
11 | #include "in-addr-util.h" | |
12 | #include "networkd-link.h" | |
fcbf4cb7 | 13 | #include "networkd-util.h" |
fc2f9534 | 14 | |
e2263711 YW |
15 | typedef struct Manager Manager; |
16 | typedef struct Network Network; | |
17 | ||
e2263711 | 18 | typedef struct Route { |
fc2f9534 | 19 | Network *network; |
f4859fc7 | 20 | NetworkConfigSection *section; |
fc2f9534 | 21 | |
1c8e710c | 22 | Link *link; |
ad208fac | 23 | Manager *manager; |
1c8e710c | 24 | |
fc2f9534 | 25 | int family; |
6dd53981 | 26 | int gw_family; |
f9bb3338 | 27 | uint32_t gw_weight; |
09f5dfad | 28 | int quickack; |
633c7258 | 29 | int fast_open_no_cookie; |
9b88f20a | 30 | int ttl_propagate; |
09f5dfad | 31 | |
fc2f9534 LP |
32 | unsigned char dst_prefixlen; |
33 | unsigned char src_prefixlen; | |
34 | unsigned char scope; | |
fc2f9534 | 35 | unsigned char protocol; /* RTPROT_* */ |
983226f3 | 36 | unsigned char type; /* RTN_* */ |
bb7ae737 | 37 | unsigned char tos; |
86655331 | 38 | uint32_t priority; /* note that ip(8) calls this 'metric' */ |
c953b24c | 39 | uint32_t table; |
d6fceaf1 | 40 | uint32_t mtu; |
323d9329 SS |
41 | uint32_t initcwnd; |
42 | uint32_t initrwnd; | |
3b015d40 TG |
43 | unsigned char pref; |
44 | unsigned flags; | |
54901fd2 | 45 | int gateway_onlink; |
c27abcf4 YW |
46 | |
47 | bool scope_set:1; | |
48 | bool table_set:1; | |
49 | bool priority_set:1; | |
50 | bool protocol_set:1; | |
51 | bool pref_set:1; | |
52 | bool gateway_from_dhcp_or_ra:1; | |
fc2f9534 | 53 | |
2ce40956 TG |
54 | union in_addr_union gw; |
55 | union in_addr_union dst; | |
56 | union in_addr_union src; | |
57 | union in_addr_union prefsrc; | |
6ff5cc6b | 58 | OrderedSet *multipath_routes; |
fc2f9534 | 59 | |
f833694d TG |
60 | usec_t lifetime; |
61 | sd_event_source *expire; | |
e2263711 | 62 | } Route; |
fc2f9534 | 63 | |
501b09db YW |
64 | void route_hash_func(const Route *route, struct siphash *state); |
65 | int route_compare_func(const Route *a, const Route *b); | |
c077a205 | 66 | extern const struct hash_ops route_hash_ops; |
01aaa3df | 67 | |
ed9e361a | 68 | int route_new(Route **ret); |
169948e9 | 69 | Route *route_free(Route *route); |
74154c2e YW |
70 | DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free); |
71 | ||
423c249c YW |
72 | int route_configure(const Route *route, Link *link, link_netlink_message_handler_t callback, Route **ret); |
73 | int route_remove(const Route *route, Manager *manager, Link *link, link_netlink_message_handler_t callback); | |
fc2f9534 | 74 | |
141318f7 | 75 | int link_set_routes(Link *link); |
62f0ea5f | 76 | int link_drop_routes(Link *link); |
779804dd | 77 | int link_drop_foreign_routes(Link *link); |
423c249c | 78 | int link_serialize_routes(const Link *link, FILE *f); |
731ff05b | 79 | int link_deserialize_routes(Link *link, const char *routes); |
141318f7 | 80 | |
423c249c YW |
81 | uint32_t link_get_dhcp_route_table(const Link *link); |
82 | uint32_t link_get_ipv6_accept_ra_route_table(const Link *link); | |
ac49887e | 83 | |
4468f01b YW |
84 | int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m); |
85 | ||
fa7cd711 | 86 | int network_add_ipv4ll_route(Network *network); |
5d5003ab | 87 | int network_add_default_route_on_device(Network *network); |
13ffa39f | 88 | void network_drop_invalid_routes(Network *network); |
fa7cd711 | 89 | |
a2106925 LP |
90 | CONFIG_PARSER_PROTOTYPE(config_parse_gateway); |
91 | CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src); | |
92 | CONFIG_PARSER_PROTOTYPE(config_parse_destination); | |
93 | CONFIG_PARSER_PROTOTYPE(config_parse_route_priority); | |
94 | CONFIG_PARSER_PROTOTYPE(config_parse_route_scope); | |
95 | CONFIG_PARSER_PROTOTYPE(config_parse_route_table); | |
d96edb2c | 96 | CONFIG_PARSER_PROTOTYPE(config_parse_route_boolean); |
a2106925 LP |
97 | CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference); |
98 | CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol); | |
99 | CONFIG_PARSER_PROTOTYPE(config_parse_route_type); | |
100 | CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window); | |
cea79e66 | 101 | CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu); |
6ff5cc6b | 102 | CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route); |