]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-route.h
Merge pull request #11834 from martinpitt/network-test-fixes
[thirdparty/systemd.git] / src / network / networkd-route.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include "conf-parser.h"
5
6 typedef struct Route Route;
7 typedef struct NetworkConfigSection NetworkConfigSection;
8
9 #include "networkd-network.h"
10
11 struct Route {
12 Network *network;
13 NetworkConfigSection *section;
14
15 Link *link;
16
17 int family;
18 int quickack;
19
20 unsigned char dst_prefixlen;
21 unsigned char src_prefixlen;
22 unsigned char scope;
23 unsigned char protocol; /* RTPROT_* */
24 unsigned char type; /* RTN_* */
25 unsigned char tos;
26 uint32_t priority; /* note that ip(8) calls this 'metric' */
27 uint32_t table;
28 uint32_t mtu;
29 uint32_t initcwnd;
30 uint32_t initrwnd;
31 unsigned char pref;
32 unsigned flags;
33 int gateway_onlink;
34
35 union in_addr_union gw;
36 union in_addr_union dst;
37 union in_addr_union src;
38 union in_addr_union prefsrc;
39
40 usec_t lifetime;
41 sd_event_source *expire;
42
43 LIST_FIELDS(Route, routes);
44 };
45
46 int route_new_static(Network *network, const char *filename, unsigned section_line, Route **ret);
47 int route_new(Route **ret);
48 void route_free(Route *route);
49 int route_configure(Route *route, Link *link, link_netlink_message_handler_t callback);
50 int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback);
51
52 int route_get(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
53 int route_add(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
54 int route_add_foreign(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
55 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);
56 bool route_equal(Route *r1, Route *r2);
57
58 int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata);
59
60 DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
61
62 CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
63 CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
64 CONFIG_PARSER_PROTOTYPE(config_parse_destination);
65 CONFIG_PARSER_PROTOTYPE(config_parse_route_priority);
66 CONFIG_PARSER_PROTOTYPE(config_parse_route_scope);
67 CONFIG_PARSER_PROTOTYPE(config_parse_route_table);
68 CONFIG_PARSER_PROTOTYPE(config_parse_gateway_onlink);
69 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference);
70 CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol);
71 CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
72 CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
73 CONFIG_PARSER_PROTOTYPE(config_parse_quickack);
74 CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);