libnl: /data/src/libnl/include/netlink/route/nexthop.h Source File

libnl 3.12.0

nexthop.h
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
4 */
5
6#ifndef NETLINK_ROUTE_NEXTHOP_H_
7#define NETLINK_ROUTE_NEXTHOP_H_
8
9#include <netlink/netlink.h>
10#include <netlink/addr.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16struct rtnl_nexthop;
17struct rtnl_nh_encap;
18
19enum {
20 NH_DUMP_FROM_ONELINE = -2,
21 NH_DUMP_FROM_DETAILS = -1,
22 NH_DUMP_FROM_ENV = 0,
23 /* > 0 reserved for nexthop index */
24};
25
26extern struct rtnl_nexthop *rtnl_route_nh_alloc(void);
27extern struct rtnl_nexthop *rtnl_route_nh_clone(struct rtnl_nexthop *);
28extern void rtnl_route_nh_free(struct rtnl_nexthop *);
29
30extern int rtnl_route_nh_compare(struct rtnl_nexthop *, struct rtnl_nexthop *,
31 uint32_t, int);
32
33extern int rtnl_route_nh_identical(struct rtnl_nexthop *,
34 struct rtnl_nexthop *);
35
36extern void rtnl_route_nh_dump(struct rtnl_nexthop *, struct nl_dump_params *);
37
38extern void rtnl_route_nh_set_weight(struct rtnl_nexthop *, uint8_t);
39extern uint8_t rtnl_route_nh_get_weight(struct rtnl_nexthop *);
40extern void rtnl_route_nh_set_ifindex(struct rtnl_nexthop *, int);
41extern int rtnl_route_nh_get_ifindex(struct rtnl_nexthop *);
42extern void rtnl_route_nh_set_gateway(struct rtnl_nexthop *, struct nl_addr *);
43extern struct nl_addr *rtnl_route_nh_get_gateway(struct rtnl_nexthop *);
44extern void rtnl_route_nh_set_flags(struct rtnl_nexthop *, unsigned int);
45extern void rtnl_route_nh_unset_flags(struct rtnl_nexthop *, unsigned int);
46extern unsigned int rtnl_route_nh_get_flags(struct rtnl_nexthop *);
47extern void rtnl_route_nh_set_realms(struct rtnl_nexthop *, uint32_t);
48extern uint32_t rtnl_route_nh_get_realms(struct rtnl_nexthop *);
49
50extern int rtnl_route_nh_set_newdst(struct rtnl_nexthop *, struct nl_addr *);
51extern struct nl_addr *rtnl_route_nh_get_newdst(struct rtnl_nexthop *);
52extern int rtnl_route_nh_set_via(struct rtnl_nexthop *, struct nl_addr *);
53extern struct nl_addr *rtnl_route_nh_get_via(struct rtnl_nexthop *);
54extern int rtnl_route_nh_set_encap(struct rtnl_nexthop *,
55 struct rtnl_nh_encap *);
56extern struct rtnl_nh_encap *rtnl_route_nh_get_encap(struct rtnl_nexthop *);
57extern char *rtnl_route_nh_flags2str(int, char *, size_t);
58extern int rtnl_route_nh_str2flags(const char *);
59
60/*
61 * nexthop encapsulations
62 */
63extern struct rtnl_nh_encap *rtnl_nh_encap_alloc(void);
64extern void rtnl_nh_encap_free(struct rtnl_nh_encap *nh_encap);
65extern struct rtnl_nh_encap *rtnl_nh_encap_clone(struct rtnl_nh_encap *src);
66extern int rtnl_nh_encap_get_type(struct rtnl_nh_encap *nh_encap);
67
68/* MPLS encap */
69extern int rtnl_nh_encap_mpls(struct rtnl_nh_encap *nh_encap,
70 struct nl_addr *dst, uint8_t ttl);
71struct nl_addr *rtnl_nh_get_encap_mpls_dst(struct rtnl_nh_encap *);
72extern int rtnl_nh_get_encap_mpls_ttl(struct rtnl_nh_encap *);
73
74extern int rtnl_route_nh_encap_mpls(struct rtnl_nexthop *nh,
75 struct nl_addr *addr, uint8_t ttl);
76extern struct nl_addr *rtnl_route_nh_get_encap_mpls_dst(struct rtnl_nexthop *);
77extern uint8_t rtnl_route_nh_get_encap_mpls_ttl(struct rtnl_nexthop *);
78
79/* IPv6 encap */
80extern int rtnl_nh_encap_ip6(struct rtnl_nh_encap *nh_encap,
81 struct nl_addr *dst);
82struct nl_addr *rtnl_nh_get_encap_ip6_dst(struct rtnl_nh_encap *);
83extern int rtnl_nh_set_encap_ip6_id(struct rtnl_nh_encap *, uint64_t);
84extern uint64_t rtnl_nh_get_encap_ip6_id(struct rtnl_nh_encap *);
85extern int rtnl_nh_set_encap_ip6_hoplimit(struct rtnl_nh_encap *, uint8_t);
86extern int rtnl_nh_get_encap_ip6_hoplimit(struct rtnl_nh_encap *);
87extern int rtnl_nh_set_encap_ip6_tc(struct rtnl_nh_encap *, uint8_t);
88extern int rtnl_nh_get_encap_ip6_tc(struct rtnl_nh_encap *);
89extern int rtnl_nh_set_encap_ip6_src(struct rtnl_nh_encap *, struct nl_addr *);
90struct nl_addr *rtnl_nh_get_encap_ip6_src(struct rtnl_nh_encap *);
91extern int rtnl_nh_set_encap_ip6_flags(struct rtnl_nh_encap *, uint16_t);
92extern int rtnl_nh_get_encap_ip6_flags(struct rtnl_nh_encap *);
93
94/* ILA encap */
95extern int rtnl_nh_encap_ila(struct rtnl_nh_encap *nh_encap, uint64_t locator);
96extern int rtnl_nh_get_encap_ila_locator(struct rtnl_nh_encap *nh_encap,
97 uint64_t *locator);
98extern int rtnl_nh_set_encap_ila_csum_mode(struct rtnl_nh_encap *nh_encap,
99 uint8_t csum_mode);
100extern int rtnl_nh_clear_encap_ila_csum_mode(struct rtnl_nh_encap *nh_encap);
101extern int rtnl_nh_get_encap_ila_csum_mode(struct rtnl_nh_encap *nh_encap);
102extern int rtnl_nh_set_encap_ila_ident_type(struct rtnl_nh_encap *nh_encap,
103 uint8_t ident_type);
104extern int rtnl_nh_clear_encap_ila_ident_type(struct rtnl_nh_encap *nh_encap);
105extern int rtnl_nh_get_encap_ila_ident_type(struct rtnl_nh_encap *nh_encap);
106extern int rtnl_nh_set_encap_ila_hook_type(struct rtnl_nh_encap *nh_encap,
107 uint8_t hook_type);
108extern int rtnl_nh_clear_encap_ila_hook_type(struct rtnl_nh_encap *nh_encap);
109extern int rtnl_nh_get_encap_ila_hook_type(struct rtnl_nh_encap *nh_encap);
110
111/* IPv4 encap */
112extern int rtnl_nh_encap_ip(struct rtnl_nh_encap *nh_encap,
113 struct nl_addr *dst);
114struct nl_addr *rtnl_nh_get_encap_ip_dst(struct rtnl_nh_encap *);
115extern int rtnl_nh_set_encap_ip_src(struct rtnl_nh_encap *, struct nl_addr *);
116struct nl_addr *rtnl_nh_get_encap_ip_src(struct rtnl_nh_encap *);
117extern int rtnl_nh_set_encap_ip_ttl(struct rtnl_nh_encap *, uint8_t);
118extern int rtnl_nh_get_encap_ip_ttl(struct rtnl_nh_encap *);
119extern int rtnl_nh_set_encap_ip_tos(struct rtnl_nh_encap *, uint8_t);
120extern int rtnl_nh_get_encap_ip_tos(struct rtnl_nh_encap *);
121extern int rtnl_nh_set_encap_ip_id(struct rtnl_nh_encap *, uint64_t);
122extern uint64_t rtnl_nh_get_encap_ip_id(struct rtnl_nh_encap *);
123extern int rtnl_nh_set_encap_ip_flags(struct rtnl_nh_encap *, uint16_t);
124extern int rtnl_nh_get_encap_ip_flags(struct rtnl_nh_encap *);
125#ifdef __cplusplus
126}
127#endif
128
129#endif
rtnl_route_nh_identical
int rtnl_route_nh_identical(struct rtnl_nexthop *, struct rtnl_nexthop *)
Check if the fixed attributes of two nexthops are identical, and may only differ in flags or weight.
Definition nexthop.c:143
rtnl_route_nh_set_encap
int rtnl_route_nh_set_encap(struct rtnl_nexthop *, struct rtnl_nh_encap *)
Set nexthop encapsulation.
Definition nexthop.c:396
nl_dump_params
Dumping parameters.
Definition types.h:32
rtnl_nh_encap
Definition nl-route.h:79