1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
7 #include "sd-netlink.h"
9 #include "conf-parser.h"
10 #include "in-addr-util.h"
12 #include "siphash24.h"
14 typedef struct Link Link
;
15 typedef struct Manager Manager
;
16 typedef struct Route Route
;
18 typedef struct RouteNextHop
{
19 int family
; /* used in RTA_VIA (IPv4 only) */
20 union in_addr_union gw
; /* RTA_GATEWAY or RTA_VIA (IPv4 only) */
21 uint32_t weight
; /* rtnh_hops */
22 int ifindex
; /* RTA_OIF(u32) or rtnh_ifindex */
23 char *ifname
; /* only used by Route object owned by Network object */
24 /* unsupported attributes: RTA_FLOW (IPv4 only), RTA_ENCAP_TYPE, RTA_ENCAP. */
27 #define ROUTE_NEXTHOP_NULL ((const RouteNextHop) {})
29 void route_detach_from_nexthop(Route
*route
);
30 void route_attach_to_nexthop(Route
*route
);
32 RouteNextHop
* route_nexthop_free(RouteNextHop
*nh
);
33 DEFINE_TRIVIAL_CLEANUP_FUNC(RouteNextHop
*, route_nexthop_free
);
35 void route_nexthops_done(Route
*route
);
37 void route_nexthops_hash_func(const Route
*route
, struct siphash
*state
);
38 int route_nexthops_compare_func(const Route
*a
, const Route
*b
);
40 int route_nexthops_copy(const Route
*src
, const RouteNextHop
*nh
, Route
*dest
);
41 bool route_nexthops_needs_adjust(const Route
*route
);
42 int route_adjust_nexthops(Route
*route
, Link
*link
);
44 int route_nexthop_get_link(Manager
*manager
, const RouteNextHop
*nh
, Link
**ret
);
45 int route_nexthops_is_ready_to_configure(const Route
*route
, Manager
*manager
);
47 int route_nexthops_to_string(const Route
*route
, char **ret
);
49 int route_nexthops_set_netlink_message(const Route
*route
, sd_netlink_message
*message
);
50 int route_nexthops_read_netlink_message(Route
*route
, sd_netlink_message
*message
);
52 int route_section_verify_nexthops(Route
*route
);
54 CONFIG_PARSER_PROTOTYPE(config_parse_gateway
);
55 CONFIG_PARSER_PROTOTYPE(config_parse_route_gateway_onlink
);
56 CONFIG_PARSER_PROTOTYPE(config_parse_route_nexthop
);
57 CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route
);