1 /* SPDX-License-Identifier: LGPL-2.1-or-later 2 * Copyright © 2019 VMware, Inc. 3 */ 4 5 #pragma once 6 7 #include <inttypes.h> 8 9 #include "sd-netlink.h" 10 11 #include "conf-parser.h" 12 #include "hashmap.h" 13 #include "in-addr-util.h" 14 #include "networkd-util.h" 15 16 typedef struct Link Link; 17 typedef struct Manager Manager; 18 typedef struct Network Network; 19 20 typedef struct NextHop { 21 Network *network; 22 Manager *manager; 23 Link *link; 24 ConfigSection *section; 25 NetworkConfigSource source; 26 NetworkConfigState state; 27 28 uint8_t protocol; 29 30 uint32_t id; 31 bool blackhole; 32 int family; 33 union in_addr_union gw; 34 uint8_t flags; 35 int onlink; /* Only used in conf parser and nexthop_section_verify(). */ 36 Hashmap *group; 37 } NextHop; 38 39 NextHop *nexthop_free(NextHop *nexthop); 40 41 void network_drop_invalid_nexthops(Network *network); 42 43 int link_drop_managed_nexthops(Link *link); 44 int link_drop_foreign_nexthops(Link *link); 45 void link_foreignize_nexthops(Link *link); 46 47 int link_request_static_nexthops(Link *link, bool only_ipv4); 48 49 int manager_get_nexthop_by_id(Manager *manager, uint32_t id, NextHop **ret); 50 int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m); 51 52 DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(NextHop, nexthop); 53 54 CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_id); 55 CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_gateway); 56 CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_family); 57 CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_onlink); 58 CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_blackhole); 59 CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_group); 60