1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 #include "conf-parser.h"
7 typedef struct Route Route
;
8 typedef struct NetworkConfigSection NetworkConfigSection
;
10 #include "networkd-network.h"
11 #include "networkd-util.h"
13 typedef struct MultipathRouteVia
{
15 union in_addr_union address
;
16 } _packed_ MultipathRouteVia
;
18 typedef struct MultipathRoute
{
19 MultipathRouteVia gateway
;
26 NetworkConfigSection
*section
;
32 int fast_open_no_cookie
;
35 unsigned char dst_prefixlen
;
36 unsigned char src_prefixlen
;
39 unsigned char protocol
; /* RTPROT_* */
40 unsigned char type
; /* RTN_* */
42 uint32_t priority
; /* note that ip(8) calls this 'metric' */
51 bool gateway_from_dhcp
;
53 union in_addr_union gw
;
54 union in_addr_union dst
;
55 union in_addr_union src
;
56 union in_addr_union prefsrc
;
57 OrderedSet
*multipath_routes
;
60 sd_event_source
*expire
;
62 LIST_FIELDS(Route
, routes
);
65 extern const struct hash_ops route_hash_ops
;
67 int route_new(Route
**ret
);
68 void route_free(Route
*route
);
69 int route_configure(Route
*route
, Link
*link
, link_netlink_message_handler_t callback
, Route
**ret
);
70 int route_remove(Route
*route
, Link
*link
, link_netlink_message_handler_t callback
);
72 int route_get(Link
*link
, Route
*in
, Route
**ret
);
73 int route_add(Link
*link
, Route
*in
, Route
**ret
);
74 int route_add_foreign(Link
*link
, Route
*in
, Route
**ret
);
75 bool route_equal(Route
*r1
, Route
*r2
);
77 int route_expire_handler(sd_event_source
*s
, uint64_t usec
, void *userdata
);
78 int route_section_verify(Route
*route
, Network
*network
);
80 DEFINE_NETWORK_SECTION_FUNCTIONS(Route
, route_free
);
82 int network_add_ipv4ll_route(Network
*network
);
83 int network_add_default_route_on_device(Network
*network
);
85 const char* route_type_to_string(int t
) _const_
;
86 int route_type_from_string(const char *s
) _pure_
;
88 #define ROUTE_SCOPE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("nowhere") + 1)
89 const char *format_route_scope(int scope
, char *buf
, size_t size
);
91 #define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1)
92 const char *format_route_table(int table
, char *buf
, size_t size
);
94 #define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1)
95 const char *format_route_protocol(int protocol
, char *buf
, size_t size
);
97 CONFIG_PARSER_PROTOTYPE(config_parse_gateway
);
98 CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src
);
99 CONFIG_PARSER_PROTOTYPE(config_parse_destination
);
100 CONFIG_PARSER_PROTOTYPE(config_parse_route_priority
);
101 CONFIG_PARSER_PROTOTYPE(config_parse_route_scope
);
102 CONFIG_PARSER_PROTOTYPE(config_parse_route_table
);
103 CONFIG_PARSER_PROTOTYPE(config_parse_route_boolean
);
104 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference
);
105 CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol
);
106 CONFIG_PARSER_PROTOTYPE(config_parse_route_type
);
107 CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window
);
108 CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu
);
109 CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route
);