]>
Commit | Line | Data |
---|---|---|
aba5acdf SH |
1 | #ifndef _TC_UTIL_H_ |
2 | #define _TC_UTIL_H_ 1 | |
3 | ||
2373fde9 | 4 | #define MAX_MSG 16384 |
d421bb4e | 5 | #include <limits.h> |
b317557f SH |
6 | #include <linux/if.h> |
7 | ||
aba5acdf SH |
8 | #include <linux/pkt_sched.h> |
9 | #include <linux/pkt_cls.h> | |
e5879dc6 | 10 | #include <linux/gen_stats.h> |
b317557f | 11 | |
aba5acdf SH |
12 | #include "tc_core.h" |
13 | ||
5a67f8f9 SH |
14 | /* This is the deprecated multiqueue interface */ |
15 | #ifndef TCA_PRIO_MAX | |
16 | enum | |
17 | { | |
18 | TCA_PRIO_UNSPEC, | |
19 | TCA_PRIO_MQ, | |
20 | __TCA_PRIO_MAX | |
21 | }; | |
22 | ||
23 | #define TCA_PRIO_MAX (__TCA_PRIO_MAX - 1) | |
24 | #endif | |
25 | ||
b317557f SH |
26 | #define FILTER_NAMESZ 16 |
27 | ||
4bd62446 | 28 | struct qdisc_util { |
2373fde9 | 29 | struct qdisc_util *next; |
6dc9f016 | 30 | const char *id; |
9ffc80b1 | 31 | int (*parse_qopt)(struct qdisc_util *qu, int argc, |
927e3cfb | 32 | char **argv, struct nlmsghdr *n, const char *dev); |
9ffc80b1 PS |
33 | int (*print_qopt)(struct qdisc_util *qu, |
34 | FILE *f, struct rtattr *opt); | |
35 | int (*print_xstats)(struct qdisc_util *qu, | |
36 | FILE *f, struct rtattr *xstats); | |
37 | ||
38 | int (*parse_copt)(struct qdisc_util *qu, int argc, | |
927e3cfb | 39 | char **argv, struct nlmsghdr *n, const char *dev); |
9ffc80b1 | 40 | int (*print_copt)(struct qdisc_util *qu, FILE *f, struct rtattr *opt); |
aba5acdf SH |
41 | }; |
42 | ||
eefcbc72 | 43 | extern __u16 f_proto; |
4bd62446 | 44 | struct filter_util { |
aba5acdf | 45 | struct filter_util *next; |
b317557f | 46 | char id[FILTER_NAMESZ]; |
9ffc80b1 PS |
47 | int (*parse_fopt)(struct filter_util *qu, char *fhandle, |
48 | int argc, char **argv, struct nlmsghdr *n); | |
49 | int (*print_fopt)(struct filter_util *qu, | |
50 | FILE *f, struct rtattr *opt, __u32 fhandle); | |
aba5acdf SH |
51 | }; |
52 | ||
4bd62446 | 53 | struct action_util { |
9ffc80b1 | 54 | struct action_util *next; |
b317557f | 55 | char id[FILTER_NAMESZ]; |
9ffc80b1 PS |
56 | int (*parse_aopt)(struct action_util *a, int *argc, |
57 | char ***argv, int code, struct nlmsghdr *n); | |
58 | int (*print_aopt)(struct action_util *au, FILE *f, struct rtattr *opt); | |
59 | int (*print_xstats)(struct action_util *au, | |
60 | FILE *f, struct rtattr *xstats); | |
2373fde9 | 61 | }; |
aba5acdf | 62 | |
4bd62446 | 63 | struct exec_util { |
9ffc80b1 | 64 | struct exec_util *next; |
b317557f | 65 | char id[FILTER_NAMESZ]; |
9ffc80b1 | 66 | int (*parse_eopt)(struct exec_util *eu, int argc, char **argv); |
4bd62446 DB |
67 | }; |
68 | ||
9ffc80b1 PS |
69 | const char *get_tc_lib(void); |
70 | ||
71 | struct qdisc_util *get_qdisc_kind(const char *str); | |
72 | struct filter_util *get_filter_kind(const char *str); | |
73 | ||
927e3cfb | 74 | int parse_percent_rate(char *rate, const char *str, const char *dev); |
9ffc80b1 PS |
75 | int get_qdisc_handle(__u32 *h, const char *str); |
76 | int get_rate(unsigned int *rate, const char *str); | |
927e3cfb | 77 | int get_percent_rate(unsigned int *rate, const char *str, const char *dev); |
9ffc80b1 | 78 | int get_rate64(__u64 *rate, const char *str); |
927e3cfb | 79 | int get_percent_rate64(__u64 *rate, const char *str, const char *dev); |
9ffc80b1 PS |
80 | int get_size(unsigned int *size, const char *str); |
81 | int get_size_and_cell(unsigned int *size, int *cell_log, char *str); | |
82 | int get_time(unsigned int *time, const char *str); | |
83 | int get_linklayer(unsigned int *val, const char *arg); | |
84 | ||
85 | void print_rate(char *buf, int len, __u64 rate); | |
86 | void print_size(char *buf, int len, __u32 size); | |
87 | void print_qdisc_handle(char *buf, int len, __u32 h); | |
88 | void print_time(char *buf, int len, __u32 time); | |
89 | void print_linklayer(char *buf, int len, unsigned int linklayer); | |
90 | ||
91 | char *sprint_rate(__u64 rate, char *buf); | |
92 | char *sprint_size(__u32 size, char *buf); | |
93 | char *sprint_qdisc_handle(__u32 h, char *buf); | |
94 | char *sprint_tc_classid(__u32 h, char *buf); | |
95 | char *sprint_time(__u32 time, char *buf); | |
96 | char *sprint_ticks(__u32 ticks, char *buf); | |
97 | char *sprint_linklayer(unsigned int linklayer, char *buf); | |
98 | ||
99 | void print_tcstats_attr(FILE *fp, struct rtattr *tb[], | |
100 | char *prefix, struct rtattr **xstats); | |
101 | void print_tcstats2_attr(FILE *fp, struct rtattr *rta, | |
102 | char *prefix, struct rtattr **xstats); | |
103 | ||
104 | int get_tc_classid(__u32 *h, const char *str); | |
105 | int print_tc_classid(char *buf, int len, __u32 h); | |
106 | char *sprint_tc_classid(__u32 h, char *buf); | |
107 | ||
108 | int tc_print_police(FILE *f, struct rtattr *tb); | |
109 | int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n); | |
110 | ||
e67aba55 JP |
111 | int parse_action_control(int *argc_p, char ***argv_p, |
112 | int *result_p, bool allow_num); | |
113 | void parse_action_control_dflt(int *argc_p, char ***argv_p, | |
114 | int *result_p, bool allow_num, | |
115 | int default_result); | |
116 | int parse_action_control_slash(int *argc_p, char ***argv_p, | |
117 | int *result1_p, int *result2_p, bool allow_num); | |
118 | void print_action_control(FILE *f, const char *prefix, | |
119 | int action, const char *suffix); | |
9ffc80b1 PS |
120 | int act_parse_police(struct action_util *a, int *argc_p, |
121 | char ***argv_p, int tca_id, struct nlmsghdr *n); | |
122 | int print_police(struct action_util *a, FILE *f, struct rtattr *tb); | |
123 | int police_print_xstats(struct action_util *a, FILE *f, struct rtattr *tb); | |
9e713525 | 124 | int tc_print_action(FILE *f, const struct rtattr *tb, unsigned short tot_acts); |
9ffc80b1 PS |
125 | int tc_print_ipt(FILE *f, const struct rtattr *tb); |
126 | int parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n); | |
127 | void print_tm(FILE *f, const struct tcf_t *tm); | |
128 | int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt); | |
129 | ||
130 | int cls_names_init(char *path); | |
131 | void cls_names_uninit(void); | |
4612d04d | 132 | |
aba5acdf | 133 | #endif |