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