xref: /aosp_15_r20/external/libnl/include/netlink/route/nexthop.h (revision 4dc78e53d49367fa8e61b07018507c90983a077d)
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright (c) 2003-2008 Thomas Graf <[email protected]>
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
13 extern "C" {
14 #endif
15 
16 struct rtnl_nexthop;
17 
18 enum {
19 	NH_DUMP_FROM_ONELINE = -2,
20 	NH_DUMP_FROM_DETAILS = -1,
21 	NH_DUMP_FROM_ENV = 0,
22 	/* > 0 reserved for nexthop index */
23 };
24 
25 extern struct rtnl_nexthop * rtnl_route_nh_alloc(void);
26 extern struct rtnl_nexthop * rtnl_route_nh_clone(struct rtnl_nexthop *);
27 extern void		rtnl_route_nh_free(struct rtnl_nexthop *);
28 
29 extern int		rtnl_route_nh_compare(struct rtnl_nexthop *,
30 					      struct rtnl_nexthop *,
31 					      uint32_t, int);
32 
33 extern int		rtnl_route_nh_identical(struct rtnl_nexthop *,
34 						struct rtnl_nexthop *);
35 
36 extern void		rtnl_route_nh_dump(struct rtnl_nexthop *,
37 					   struct nl_dump_params *);
38 
39 extern void		rtnl_route_nh_set_weight(struct rtnl_nexthop *, uint8_t);
40 extern uint8_t		rtnl_route_nh_get_weight(struct rtnl_nexthop *);
41 extern void		rtnl_route_nh_set_ifindex(struct rtnl_nexthop *, int);
42 extern int		rtnl_route_nh_get_ifindex(struct rtnl_nexthop *);
43 extern void		rtnl_route_nh_set_gateway(struct rtnl_nexthop *,
44 						  struct nl_addr *);
45 extern struct nl_addr *	rtnl_route_nh_get_gateway(struct rtnl_nexthop *);
46 extern void		rtnl_route_nh_set_flags(struct rtnl_nexthop *,
47 						unsigned int);
48 extern void		rtnl_route_nh_unset_flags(struct rtnl_nexthop *,
49 						  unsigned int);
50 extern unsigned int	rtnl_route_nh_get_flags(struct rtnl_nexthop *);
51 extern void		rtnl_route_nh_set_realms(struct rtnl_nexthop *,
52 						 uint32_t);
53 extern uint32_t		rtnl_route_nh_get_realms(struct rtnl_nexthop *);
54 
55 extern int		rtnl_route_nh_set_newdst(struct rtnl_nexthop *,
56 						 struct nl_addr *);
57 extern struct nl_addr *	rtnl_route_nh_get_newdst(struct rtnl_nexthop *);
58 extern int		rtnl_route_nh_set_via(struct rtnl_nexthop *,
59 						 struct nl_addr *);
60 extern struct nl_addr *	rtnl_route_nh_get_via(struct rtnl_nexthop *);
61 extern char *		rtnl_route_nh_flags2str(int, char *, size_t);
62 extern int		rtnl_route_nh_str2flags(const char *);
63 
64 /*
65  * nexthop encapsulations
66  */
67 extern int		rtnl_route_nh_encap_mpls(struct rtnl_nexthop *nh,
68 						 struct nl_addr *addr,
69 						 uint8_t ttl);
70 extern struct nl_addr *	rtnl_route_nh_get_encap_mpls_dst(struct rtnl_nexthop *);
71 extern uint8_t		rtnl_route_nh_get_encap_mpls_ttl(struct rtnl_nexthop *);
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif
77