]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-route.h
network: make address/route_configure optionally return created Address/Route object
[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 12
6ff5cc6b
YW
13typedef struct MultipathRouteVia {
14 uint16_t family;
15 union in_addr_union address;
16} _packed_ MultipathRouteVia;
17
18typedef struct MultipathRoute {
19 MultipathRouteVia gateway;
20 int ifindex;
21 uint32_t weight;
22} MultipathRoute;
23
fc2f9534
LP
24struct Route {
25 Network *network;
f4859fc7 26 NetworkConfigSection *section;
fc2f9534 27
1c8e710c
TG
28 Link *link;
29
fc2f9534 30 int family;
09f5dfad 31 int quickack;
633c7258 32 int fast_open_no_cookie;
9b88f20a 33 int ttl_propagate;
09f5dfad 34
fc2f9534
LP
35 unsigned char dst_prefixlen;
36 unsigned char src_prefixlen;
37 unsigned char scope;
94d6e299 38 bool scope_set;
fc2f9534 39 unsigned char protocol; /* RTPROT_* */
983226f3 40 unsigned char type; /* RTN_* */
bb7ae737 41 unsigned char tos;
86655331 42 uint32_t priority; /* note that ip(8) calls this 'metric' */
c953b24c 43 uint32_t table;
94d6e299 44 bool table_set;
d6fceaf1 45 uint32_t mtu;
323d9329
SS
46 uint32_t initcwnd;
47 uint32_t initrwnd;
3b015d40
TG
48 unsigned char pref;
49 unsigned flags;
54901fd2 50 int gateway_onlink;
1985c54f 51 bool gateway_from_dhcp;
fc2f9534 52
2ce40956
TG
53 union in_addr_union gw;
54 union in_addr_union dst;
55 union in_addr_union src;
56 union in_addr_union prefsrc;
6ff5cc6b 57 OrderedSet *multipath_routes;
fc2f9534 58
f833694d
TG
59 usec_t lifetime;
60 sd_event_source *expire;
61
fc2f9534
LP
62 LIST_FIELDS(Route, routes);
63};
64
c077a205 65extern const struct hash_ops route_hash_ops;
01aaa3df 66
ed9e361a 67int route_new(Route **ret);
fc2f9534 68void route_free(Route *route);
80b0e860 69int route_configure(Route *route, Link *link, link_netlink_message_handler_t callback, Route **ret);
302a796f 70int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback);
fc2f9534 71
f1368755
YW
72int route_get(Link *link, Route *in, Route **ret);
73int route_add(Link *link, Route *in, Route **ret);
74int route_add_foreign(Link *link, Route *in, Route **ret);
7ecf0c3e 75bool route_equal(Route *r1, Route *r2);
1c8e710c 76
f833694d 77int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata);
fcbf4cb7 78int route_section_verify(Route *route, Network *network);
f833694d 79
fcbf4cb7 80DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free);
fc2f9534 81
fa7cd711 82int network_add_ipv4ll_route(Network *network);
5d5003ab 83int network_add_default_route_on_device(Network *network);
fa7cd711 84
7a22312d
YW
85const char* route_type_to_string(int t) _const_;
86int route_type_from_string(const char *s) _pure_;
87
b297e0a7
YW
88#define ROUTE_SCOPE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("nowhere") + 1)
89const char *format_route_scope(int scope, char *buf, size_t size);
90
91#define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1)
92const char *format_route_table(int table, char *buf, size_t size);
93
ca420b62 94#define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1)
d3e291fd
YW
95const char *format_route_protocol(int protocol, char *buf, size_t size);
96
a2106925
LP
97CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
98CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
99CONFIG_PARSER_PROTOTYPE(config_parse_destination);
100CONFIG_PARSER_PROTOTYPE(config_parse_route_priority);
101CONFIG_PARSER_PROTOTYPE(config_parse_route_scope);
102CONFIG_PARSER_PROTOTYPE(config_parse_route_table);
d96edb2c 103CONFIG_PARSER_PROTOTYPE(config_parse_route_boolean);
a2106925
LP
104CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference);
105CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol);
106CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
107CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
cea79e66 108CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);
6ff5cc6b 109CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route);