Debian Codegraph @

include/netlink/route/nh.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3 * Copyright (c) 2022 Stanislav Zaikin <[email protected]>
4 */
5
6 #ifndef NETLINK_ROUTE_NEXTHOP2_H_
7 #define NETLINK_ROUTE_NEXTHOP2_H_
8
9 #include <netlink/netlink.h>
10 #include <netlink/addr.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 struct rtnl_nh;
17
18 typedef struct nl_nh_group_info {
19 uint32_t nh_id; /*!< nexthop id */
20 uint8_t weight; /*!< weight in nexthop group */
21 } nl_nh_group_info_t;
22
23 typedef struct nl_nh_group {
24 int ce_refcnt;
25 unsigned size;
26 nl_nh_group_info_t *entries;
27 } nl_nh_group_t;
28
29 extern int rtnl_nh_alloc_cache(struct nl_sock *sk, int family,
30 struct nl_cache **result);
31 extern struct rtnl_nh *rtnl_nh_alloc(void);
32 extern int rtnl_nh_add(struct nl_sock *sk, struct rtnl_nh *nh, int flags);
33 extern void rtnl_nh_put(struct rtnl_nh *);
34
35 extern struct rtnl_nh *rtnl_nh_get(struct nl_cache *cache, int nhid);
36
37 extern int rtnl_nh_set_gateway(struct rtnl_nh *, struct nl_addr *);
38 extern struct nl_addr *rtnl_nh_get_gateway(struct rtnl_nh *);
39
40 extern int rtnl_nh_set_fdb(struct rtnl_nh *, int value);
41 extern int rtnl_nh_get_fdb(struct rtnl_nh *);
42
43 extern int rtnl_nh_get_group_entry(struct rtnl_nh *, int n);
44 extern int rtnl_nh_get_group_size(struct rtnl_nh *);
45
46 extern int rtnl_nh_set_group(struct rtnl_nh *,
47 const nl_nh_group_info_t *entries, unsigned size);
48
49 extern int rtnl_nh_set_id(struct rtnl_nh *, uint32_t id);
50 extern int rtnl_nh_get_id(struct rtnl_nh *);
51 extern int rtnl_nh_set_oif(struct rtnl_nh *, uint32_t ifindex);
52 extern int rtnl_nh_get_oif(struct rtnl_nh *);
53
54 extern int rtnl_nh_set_family(struct rtnl_nh *, uint8_t family);
55 extern int rtnl_nh_get_family(struct rtnl_nh *);
56
57 extern int rtnl_nh_set_group_type(struct rtnl_nh *, uint16_t group_type);
58 extern int rtnl_nh_get_group_type(struct rtnl_nh *);
59
60 /* Resilient nexthop group specific setters/getters */
61 extern int rtnl_nh_set_res_group_bucket_size(struct rtnl_nh *,
62 uint16_t buckets);
63 extern int rtnl_nh_get_res_group_bucket_size(struct rtnl_nh *);
64
65 extern int rtnl_nh_set_res_group_idle_timer(struct rtnl_nh *,
66 uint32_t idle_timer);
67 extern int rtnl_nh_get_res_group_idle_timer(struct rtnl_nh *,
68 uint32_t *out_value);
69
70 extern int rtnl_nh_set_res_group_unbalanced_timer(struct rtnl_nh *,
71 uint32_t unbalanced_timer);
72 extern int rtnl_nh_get_res_group_unbalanced_timer(struct rtnl_nh *,
73 uint32_t *out_value);
74
75 /* lwtunnel encapsulation */
76 struct rtnl_nh_encap;
77 extern int rtnl_nh_set_encap(struct rtnl_nh *, struct rtnl_nh_encap *);
78 extern struct rtnl_nh_encap *rtnl_nh_get_encap(struct rtnl_nh *);
79
80 #ifdef __cplusplus
81 }
82 #endif
83
84 #endif