lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #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 |
| 12 | enum |
| 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 | |
| 22 | struct 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 | |
| 34 | extern __u16 f_proto; |
| 35 | struct 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 | |
| 44 | struct 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 | |
| 54 | extern const char *get_tc_lib(void); |
| 55 | |
| 56 | extern struct qdisc_util *get_qdisc_kind(const char *str); |
| 57 | extern struct filter_util *get_filter_kind(const char *str); |
| 58 | |
| 59 | extern int get_qdisc_handle(__u32 *h, const char *str); |
| 60 | extern int get_rate(unsigned *rate, const char *str); |
| 61 | extern int get_size(unsigned *size, const char *str); |
| 62 | extern int get_size_and_cell(unsigned *size, int *cell_log, char *str); |
| 63 | extern int get_time(unsigned *time, const char *str); |
| 64 | extern int get_linklayer(unsigned *val, const char *arg); |
| 65 | |
| 66 | extern void print_rate(char *buf, int len, __u32 rate); |
| 67 | extern void print_size(char *buf, int len, __u32 size); |
| 68 | extern void print_qdisc_handle(char *buf, int len, __u32 h); |
| 69 | extern void print_time(char *buf, int len, __u32 time); |
| 70 | extern void print_linklayer(char *buf, int len, unsigned linklayer); |
| 71 | extern char * sprint_rate(__u32 rate, char *buf); |
| 72 | extern char * sprint_size(__u32 size, char *buf); |
| 73 | extern char * sprint_qdisc_handle(__u32 h, char *buf); |
| 74 | extern char * sprint_tc_classid(__u32 h, char *buf); |
| 75 | extern char * sprint_time(__u32 time, char *buf); |
| 76 | extern char * sprint_ticks(__u32 ticks, char *buf); |
| 77 | extern char * sprint_linklayer(unsigned linklayer, char *buf); |
| 78 | |
| 79 | extern void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtattr **xstats); |
| 80 | extern void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtattr **xstats); |
| 81 | |
| 82 | extern int get_tc_classid(__u32 *h, const char *str); |
| 83 | extern int print_tc_classid(char *buf, int len, __u32 h); |
| 84 | extern char * sprint_tc_classid(__u32 h, char *buf); |
| 85 | |
| 86 | extern int tc_print_police(FILE *f, struct rtattr *tb); |
| 87 | extern int parse_police(int *, char ***, int, struct nlmsghdr *); |
| 88 | |
| 89 | extern char *action_n2a(int action, char *buf, int len); |
| 90 | extern int action_a2n(char *arg, int *result); |
| 91 | extern int act_parse_police(struct action_util *a,int *, char ***, int, struct nlmsghdr *); |
| 92 | extern int print_police(struct action_util *a, FILE *f, |
| 93 | struct rtattr *tb); |
| 94 | extern int police_print_xstats(struct action_util *a,FILE *f, |
| 95 | struct rtattr *tb); |
| 96 | extern int tc_print_action(FILE *f, const struct rtattr *tb); |
| 97 | extern int tc_print_ipt(FILE *f, const struct rtattr *tb); |
| 98 | extern int parse_action(int *, char ***, int, struct nlmsghdr *); |
| 99 | extern void print_tm(FILE *f, const struct tcf_t *tm); |
| 100 | |
| 101 | #endif |