]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-nexthop.h
network/link: shorten code a bit
[thirdparty/systemd.git] / src / network / networkd-nexthop.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later
c16c7808
SS
2 * Copyright © 2019 VMware, Inc.
3 */
4
5#pragma once
6
75156ccb 7#include <inttypes.h>
c16c7808 8
75156ccb 9#include "sd-netlink.h"
c16c7808 10
75156ccb 11#include "conf-parser.h"
228c3e21 12#include "hashmap.h"
75156ccb 13#include "in-addr-util.h"
c16c7808
SS
14#include "networkd-util.h"
15
75156ccb
YW
16typedef struct Link Link;
17typedef struct Manager Manager;
18typedef struct Network Network;
19
20typedef struct NextHop {
c16c7808 21 Network *network;
30f10837 22 Manager *manager;
307fe3cd 23 ConfigSection *section;
89fa0133
YW
24 NetworkConfigSource source;
25 NetworkConfigState state;
c16c7808 26
59ac53a6
YW
27 unsigned n_ref;
28
0e9d129c 29 uint8_t protocol;
352eba2e 30 int ifindex;
c16c7808 31 uint32_t id;
30f10837 32 bool blackhole;
8c112218 33 int family;
c16c7808 34 union in_addr_union gw;
17f8d8f9
YW
35 uint8_t flags;
36 int onlink; /* Only used in conf parser and nexthop_section_verify(). */
228c3e21 37 Hashmap *group;
75156ccb 38} NextHop;
c16c7808 39
59ac53a6
YW
40NextHop* nexthop_ref(NextHop *nexthop);
41NextHop* nexthop_unref(NextHop *nexthop);
0992f9fb 42
9a988d16
YW
43int nexthop_remove(NextHop *nexthop, Manager *manager);
44
015b2432 45int network_drop_invalid_nexthops(Network *network);
c16c7808 46
352eba2e
YW
47int link_drop_nexthops(Link *link, bool foreign);
48static inline int link_drop_foreign_nexthops(Link *link) {
49 return link_drop_nexthops(link, /* foreign = */ true);
50}
51static inline int link_drop_managed_nexthops(Link *link) {
52 return link_drop_nexthops(link, /* foreign = */ false);
53}
b4564f4e 54void link_foreignize_nexthops(Link *link);
c133770a 55
76c5a0f2 56int link_request_static_nexthops(Link *link, bool only_ipv4);
76c5a0f2 57
ac217903 58int nexthop_get_by_id(Manager *manager, uint32_t id, NextHop **ret);
ccc55b5e 59int nexthop_is_ready(Manager *manager, uint32_t id, NextHop **ret);
454c87b5 60int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
fb126bb1 61int manager_build_nexthop_ids(Manager *manager);
454c87b5 62
89fa0133
YW
63DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(NextHop, nexthop);
64
c16c7808
SS
65CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_id);
66CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_gateway);
f1923efc 67CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_family);
2ddd52d1 68CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_onlink);
30f10837 69CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_blackhole);
228c3e21 70CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_group);