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