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"
15 NetworkConfigSection
*section
;
21 int fast_open_no_cookie
;
24 unsigned char dst_prefixlen
;
25 unsigned char src_prefixlen
;
28 unsigned char protocol
; /* RTPROT_* */
29 unsigned char type
; /* RTN_* */
31 uint32_t priority
; /* note that ip(8) calls this 'metric' */
41 union in_addr_union gw
;
42 union in_addr_union dst
;
43 union in_addr_union src
;
44 union in_addr_union prefsrc
;
47 sd_event_source
*expire
;
49 LIST_FIELDS(Route
, routes
);
52 extern const struct hash_ops route_full_hash_ops
;
54 int route_new(Route
**ret
);
55 void route_free(Route
*route
);
56 int route_configure(Route
*route
, Link
*link
, link_netlink_message_handler_t callback
);
57 int route_remove(Route
*route
, Link
*link
, link_netlink_message_handler_t callback
);
59 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
);
60 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
);
61 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
);
62 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
);
63 bool route_equal(Route
*r1
, Route
*r2
);
65 int route_expire_handler(sd_event_source
*s
, uint64_t usec
, void *userdata
);
66 int route_section_verify(Route
*route
, Network
*network
);
68 DEFINE_NETWORK_SECTION_FUNCTIONS(Route
, route_free
);
70 int network_add_ipv4ll_route(Network
*network
);
71 int network_add_default_route_on_device(Network
*network
);
73 const char* route_type_to_string(int t
) _const_
;
74 int route_type_from_string(const char *s
) _pure_
;
76 #define ROUTE_SCOPE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("nowhere") + 1)
77 const char *format_route_scope(int scope
, char *buf
, size_t size
);
79 #define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1)
80 const char *format_route_table(int table
, char *buf
, size_t size
);
82 #define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1)
83 const char *format_route_protocol(int protocol
, char *buf
, size_t size
);
85 CONFIG_PARSER_PROTOTYPE(config_parse_gateway
);
86 CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src
);
87 CONFIG_PARSER_PROTOTYPE(config_parse_destination
);
88 CONFIG_PARSER_PROTOTYPE(config_parse_route_priority
);
89 CONFIG_PARSER_PROTOTYPE(config_parse_route_scope
);
90 CONFIG_PARSER_PROTOTYPE(config_parse_route_table
);
91 CONFIG_PARSER_PROTOTYPE(config_parse_gateway_onlink
);
92 CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference
);
93 CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol
);
94 CONFIG_PARSER_PROTOTYPE(config_parse_route_type
);
95 CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window
);
96 CONFIG_PARSER_PROTOTYPE(config_parse_quickack
);
97 CONFIG_PARSER_PROTOTYPE(config_parse_fast_open_no_cookie
);
98 CONFIG_PARSER_PROTOTYPE(config_parse_route_ttl_propagate
);
99 CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu
);