blob: 6b3ed1eb21c3b14546ba5c4548ada202a1dd49a1 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#ifndef _TC_UTIL_H_
2#define _TC_UTIL_H_ 1
3
4#define MAX_MSG 16384
5#include <linux/pkt_sched.h>
6#include <linux/pkt_cls.h>
7#include <linux/gen_stats.h>
8#include "tc_core.h"
9
10/* This is the deprecated multiqueue interface */
11#ifndef TCA_PRIO_MAX
12enum
13{
14 TCA_PRIO_UNSPEC,
15 TCA_PRIO_MQ,
16 __TCA_PRIO_MAX
17};
18
19#define TCA_PRIO_MAX (__TCA_PRIO_MAX - 1)
20#endif
21
22struct qdisc_util
23{
24 struct qdisc_util *next;
25 const char *id;
26 int (*parse_qopt)(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n);
27 int (*print_qopt)(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
28 int (*print_xstats)(struct qdisc_util *qu, FILE *f, struct rtattr *xstats);
29
30 int (*parse_copt)(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n);
31 int (*print_copt)(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
32};
33
34extern __u16 f_proto;
35struct filter_util
36{
37 struct filter_util *next;
38 char id[16];
39 int (*parse_fopt)(struct filter_util *qu, char *fhandle, int argc,
40 char **argv, struct nlmsghdr *n);
41 int (*print_fopt)(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 fhandle);
42};
43
44struct action_util
45{
46 struct action_util *next;
47 char id[16];
48 int (*parse_aopt)(struct action_util *a, int *argc, char ***argv,
49 int code, struct nlmsghdr *n);
50 int (*print_aopt)(struct action_util *au, FILE *f, struct rtattr *opt);
51 int (*print_xstats)(struct action_util *au, FILE *f, struct rtattr *xstats);
52};
53
54extern const char *get_tc_lib(void);
55
56extern struct qdisc_util *get_qdisc_kind(const char *str);
57extern struct filter_util *get_filter_kind(const char *str);
58
59extern int get_qdisc_handle(__u32 *h, const char *str);
60extern int get_rate(unsigned *rate, const char *str);
61extern int get_size(unsigned *size, const char *str);
62extern int get_size_and_cell(unsigned *size, int *cell_log, char *str);
63extern int get_time(unsigned *time, const char *str);
64extern int get_linklayer(unsigned *val, const char *arg);
65
66extern void print_rate(char *buf, int len, __u32 rate);
67extern void print_size(char *buf, int len, __u32 size);
68extern void print_qdisc_handle(char *buf, int len, __u32 h);
69extern void print_time(char *buf, int len, __u32 time);
70extern void print_linklayer(char *buf, int len, unsigned linklayer);
71extern char * sprint_rate(__u32 rate, char *buf);
72extern char * sprint_size(__u32 size, char *buf);
73extern char * sprint_qdisc_handle(__u32 h, char *buf);
74extern char * sprint_tc_classid(__u32 h, char *buf);
75extern char * sprint_time(__u32 time, char *buf);
76extern char * sprint_ticks(__u32 ticks, char *buf);
77extern char * sprint_linklayer(unsigned linklayer, char *buf);
78
79extern void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtattr **xstats);
80extern void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtattr **xstats);
81
82extern int get_tc_classid(__u32 *h, const char *str);
83extern int print_tc_classid(char *buf, int len, __u32 h);
84extern char * sprint_tc_classid(__u32 h, char *buf);
85
86extern int tc_print_police(FILE *f, struct rtattr *tb);
87extern int parse_police(int *, char ***, int, struct nlmsghdr *);
88
89extern char *action_n2a(int action, char *buf, int len);
90extern int action_a2n(char *arg, int *result);
91extern int act_parse_police(struct action_util *a,int *, char ***, int, struct nlmsghdr *);
92extern int print_police(struct action_util *a, FILE *f,
93 struct rtattr *tb);
94extern int police_print_xstats(struct action_util *a,FILE *f,
95 struct rtattr *tb);
96extern int tc_print_action(FILE *f, const struct rtattr *tb);
97extern int tc_print_ipt(FILE *f, const struct rtattr *tb);
98extern int parse_action(int *, char ***, int, struct nlmsghdr *);
99extern void print_tm(FILE *f, const struct tcf_t *tm);
100
101#endif