]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-route.h
Merge pull request #13939 from yuwata/network-fix-memleak-and-13938
[thirdparty/systemd.git] / src / network / networkd-route.h
CommitLineData
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 7typedef struct Route Route;
f4859fc7 8typedef struct NetworkConfigSection NetworkConfigSection;
fc2f9534 9
fc2f9534 10#include "networkd-network.h"
fcbf4cb7 11#include "networkd-util.h"
fc2f9534
LP
12
13struct 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
c077a205 52extern const struct hash_ops route_hash_ops;
01aaa3df 53
ed9e361a 54int route_new(Route **ret);
fc2f9534 55void route_free(Route *route);
302a796f
YW
56int route_configure(Route *route, Link *link, link_netlink_message_handler_t callback);
57int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback);
fc2f9534 58
f1368755
YW
59int route_get(Link *link, Route *in, Route **ret);
60int route_add(Link *link, Route *in, Route **ret);
61int route_add_foreign(Link *link, Route *in, Route **ret);
7ecf0c3e 62bool route_equal(Route *r1, Route *r2);
1c8e710c 63
f833694d 64int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata);
fcbf4cb7 65int route_section_verify(Route *route, Network *network);
f833694d 66
fcbf4cb7 67DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free);
fc2f9534 68
fa7cd711 69int network_add_ipv4ll_route(Network *network);
5d5003ab 70int network_add_default_route_on_device(Network *network);
fa7cd711 71
7a22312d
YW
72const char* route_type_to_string(int t) _const_;
73int route_type_from_string(const char *s) _pure_;
74
b297e0a7
YW
75#define ROUTE_SCOPE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("nowhere") + 1)
76const char *format_route_scope(int scope, char *buf, size_t size);
77
78#define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1)
79const char *format_route_table(int table, char *buf, size_t size);
80
ca420b62 81#define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1)
d3e291fd
YW
82const char *format_route_protocol(int protocol, char *buf, size_t size);
83
a2106925
LP
84CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
85CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
86CONFIG_PARSER_PROTOTYPE(config_parse_destination);
87CONFIG_PARSER_PROTOTYPE(config_parse_route_priority);
88CONFIG_PARSER_PROTOTYPE(config_parse_route_scope);
89CONFIG_PARSER_PROTOTYPE(config_parse_route_table);
90CONFIG_PARSER_PROTOTYPE(config_parse_gateway_onlink);
91CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference);
92CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol);
93CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
94CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
95CONFIG_PARSER_PROTOTYPE(config_parse_quickack);
633c7258 96CONFIG_PARSER_PROTOTYPE(config_parse_fast_open_no_cookie);
9b88f20a 97CONFIG_PARSER_PROTOTYPE(config_parse_route_ttl_propagate);
cea79e66 98CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);