xref: /aosp_15_r20/external/libnl/lib/route/tc-api.h (revision 4dc78e53d49367fa8e61b07018507c90983a077d)
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright (c) 2011-2013 Thomas Graf <[email protected]>
4  */
5 
6 #ifndef NETLINK_TC_API_H_
7 #define NETLINK_TC_API_H_
8 
9 #include <netlink/netlink.h>
10 #include <netlink/msg.h>
11 #include <netlink/route/tc.h>
12 
13 #include "nl-route.h"
14 #include "nl-priv-dynamic-route/nl-priv-dynamic-route.h"
15 #include "nl-priv-dynamic-core/nl-core.h"
16 #include "nl-priv-dynamic-core/cache-api.h"
17 
18 /*****************************************************************************/
19 
20 #define TCA_ATTR_HANDLE		0x0001
21 #define TCA_ATTR_PARENT		0x0002
22 #define TCA_ATTR_IFINDEX	0x0004
23 #define TCA_ATTR_KIND		0x0008
24 #define TCA_ATTR_FAMILY		0x0010
25 #define TCA_ATTR_INFO		0x0020
26 #define TCA_ATTR_OPTS		0x0040
27 #define TCA_ATTR_STATS		0x0080
28 #define TCA_ATTR_XSTATS		0x0100
29 #define TCA_ATTR_LINK		0x0200
30 #define TCA_ATTR_MTU		0x0400
31 #define TCA_ATTR_MPU		0x0800
32 #define TCA_ATTR_OVERHEAD	0x1000
33 #define TCA_ATTR_LINKTYPE	0x2000
34 #define TCA_ATTR_CHAIN          0x4000
35 #define TCA_ATTR_MAX            TCA_ATTR_CHAIN
36 
37 extern int tca_parse(struct nlattr **, int, struct rtnl_tc *,
38                      const struct nla_policy *);
39 
40 #define RTNL_TC_RTABLE_SIZE	256
41 
tca_xstats(struct rtnl_tc * tca)42 static inline void *tca_xstats(struct rtnl_tc *tca)
43 {
44 	return tca->tc_xstats->d_data;
45 }
46 
47 extern struct nl_af_group tc_groups[];
48 
49 /*****************************************************************************/
50 
51 struct rtnl_tc_type_ops
52 {
53 	enum rtnl_tc_type tt_type;
54 
55 	char *tt_dump_prefix;
56 
57 	/**
58 	 * Dump callbacks
59 	 */
60 	void (*tt_dump[NL_DUMP_MAX+1])(struct rtnl_tc *,
61 				        struct nl_dump_params *);
62 };
63 
64 void *rtnl_tc_data_peek(struct rtnl_tc *tc);
65 
66 /*****************************************************************************/
67 
68 /* WARNING: the following symbols are wrongly exported in libnl-route-3
69  * library. They are private API, but leaked. */
70 extern int			rtnl_tc_msg_parse(struct nlmsghdr *,
71 						  struct rtnl_tc *);
72 extern int			rtnl_tc_msg_build(struct rtnl_tc *, int,
73 						  int, struct nl_msg **);
74 
75 extern void			rtnl_tc_free_data(struct nl_object *);
76 extern int			rtnl_tc_clone(struct nl_object *,
77 					      struct nl_object *);
78 extern void			rtnl_tc_dump_line(struct nl_object *,
79 						  struct nl_dump_params *);
80 extern void			rtnl_tc_dump_details(struct nl_object *,
81 						     struct nl_dump_params *);
82 extern void			rtnl_tc_dump_stats(struct nl_object *,
83 						   struct nl_dump_params *);
84 extern uint64_t			rtnl_tc_compare(struct nl_object *,
85 						struct nl_object *,
86 						uint64_t, int);
87 
88 extern void *			rtnl_tc_data(struct rtnl_tc *);
89 extern void *			rtnl_tc_data_check(struct rtnl_tc *,
90 						   struct rtnl_tc_ops *, int *);
91 
92 extern int 			rtnl_tc_register(struct rtnl_tc_ops *);
93 extern void 			rtnl_tc_unregister(struct rtnl_tc_ops *);
94 
95 extern void			rtnl_tc_type_register(struct rtnl_tc_type_ops *);
96 extern void			rtnl_tc_type_unregister(struct rtnl_tc_type_ops *);
97 
98 
99 extern int rtnl_tc_build_rate_table(struct rtnl_tc *tc, struct rtnl_ratespec *,
100 				    uint32_t *);
101 
102 /*****************************************************************************/
103 
104 #endif
105