]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-route.h
network: add NextHop= setting in [Route] section
[thirdparty/systemd.git] / src / network / networkd-route.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
fc2f9534
LP
2#pragma once
3
e2263711
YW
4#include <inttypes.h>
5#include <stdbool.h>
6#include <stdio.h>
a2106925 7
e2263711 8#include "sd-netlink.h"
fc2f9534 9
e2263711
YW
10#include "conf-parser.h"
11#include "in-addr-util.h"
12#include "networkd-link.h"
fcbf4cb7 13#include "networkd-util.h"
fc2f9534 14
e2263711
YW
15typedef struct Manager Manager;
16typedef struct Network Network;
17
e2263711 18typedef struct Route {
fc2f9534 19 Network *network;
f4859fc7 20 NetworkConfigSection *section;
fc2f9534 21
1c8e710c 22 Link *link;
ad208fac 23 Manager *manager;
1c8e710c 24
fc2f9534 25 int family;
6dd53981 26 int gw_family;
f9bb3338 27 uint32_t gw_weight;
09f5dfad 28 int quickack;
633c7258 29 int fast_open_no_cookie;
9b88f20a 30 int ttl_propagate;
09f5dfad 31
fc2f9534
LP
32 unsigned char dst_prefixlen;
33 unsigned char src_prefixlen;
34 unsigned char scope;
fc2f9534 35 unsigned char protocol; /* RTPROT_* */
983226f3 36 unsigned char type; /* RTN_* */
bb7ae737 37 unsigned char tos;
86655331 38 uint32_t priority; /* note that ip(8) calls this 'metric' */
c953b24c 39 uint32_t table;
d6fceaf1 40 uint32_t mtu;
323d9329
SS
41 uint32_t initcwnd;
42 uint32_t initrwnd;
007cac09 43 uint32_t advmss;
3b015d40
TG
44 unsigned char pref;
45 unsigned flags;
54901fd2 46 int gateway_onlink;
324e3422 47 uint32_t nexthop_id;
c27abcf4
YW
48
49 bool scope_set:1;
50 bool table_set:1;
51 bool priority_set:1;
52 bool protocol_set:1;
53 bool pref_set:1;
54 bool gateway_from_dhcp_or_ra:1;
fc2f9534 55
2ce40956
TG
56 union in_addr_union gw;
57 union in_addr_union dst;
58 union in_addr_union src;
59 union in_addr_union prefsrc;
6ff5cc6b 60 OrderedSet *multipath_routes;
fc2f9534 61
f833694d
TG
62 usec_t lifetime;
63 sd_event_source *expire;
e2263711 64} Route;
fc2f9534 65
501b09db
YW
66void route_hash_func(const Route *route, struct siphash *state);
67int route_compare_func(const Route *a, const Route *b);
c077a205 68extern const struct hash_ops route_hash_ops;
01aaa3df 69
ed9e361a 70int route_new(Route **ret);
169948e9 71Route *route_free(Route *route);
74154c2e
YW
72DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free);
73
423c249c
YW
74int route_configure(const Route *route, Link *link, link_netlink_message_handler_t callback, Route **ret);
75int route_remove(const Route *route, Manager *manager, Link *link, link_netlink_message_handler_t callback);
fc2f9534 76
141318f7 77int link_set_routes(Link *link);
f345918d 78int link_set_routes_with_gateway(Link *link);
62f0ea5f 79int link_drop_routes(Link *link);
779804dd 80int link_drop_foreign_routes(Link *link);
141318f7 81
423c249c
YW
82uint32_t link_get_dhcp_route_table(const Link *link);
83uint32_t link_get_ipv6_accept_ra_route_table(const Link *link);
ac49887e 84
4468f01b
YW
85int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
86
fa7cd711 87int network_add_ipv4ll_route(Network *network);
5d5003ab 88int network_add_default_route_on_device(Network *network);
13ffa39f 89void network_drop_invalid_routes(Network *network);
fa7cd711 90
552b90a2
YW
91int manager_get_route_table_from_string(const Manager *m, const char *table, uint32_t *ret);
92int manager_get_route_table_to_string(const Manager *m, uint32_t table, char **ret);
c038ce46 93
a2106925
LP
94CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
95CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
96CONFIG_PARSER_PROTOTYPE(config_parse_destination);
97CONFIG_PARSER_PROTOTYPE(config_parse_route_priority);
98CONFIG_PARSER_PROTOTYPE(config_parse_route_scope);
99CONFIG_PARSER_PROTOTYPE(config_parse_route_table);
d96edb2c 100CONFIG_PARSER_PROTOTYPE(config_parse_route_boolean);
a2106925
LP
101CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference);
102CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol);
103CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
104CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
cea79e66 105CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);
6ff5cc6b 106CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route);
007cac09 107CONFIG_PARSER_PROTOTYPE(config_parse_tcp_advmss);
c038ce46 108CONFIG_PARSER_PROTOTYPE(config_parse_route_table_names);
324e3422 109CONFIG_PARSER_PROTOTYPE(config_parse_route_nexthop);