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 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 struct qdisc_util *next; 24 const char *id; 25 int (*parse_qopt)(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n); 26 int (*print_qopt)(struct qdisc_util *qu, FILE *f, struct rtattr *opt); 27 int (*print_xstats)(struct qdisc_util *qu, FILE *f, struct rtattr *xstats); 28 29 int (*parse_copt)(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n); 30 int (*print_copt)(struct qdisc_util *qu, FILE *f, struct rtattr *opt); 31}; 32 33extern __u16 f_proto; 34struct filter_util { 35 struct filter_util *next; 36 char id[16]; 37 int (*parse_fopt)(struct filter_util *qu, char *fhandle, int argc, 38 char **argv, struct nlmsghdr *n); 39 int (*print_fopt)(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 fhandle); 40}; 41 42struct action_util { 43 struct action_util *next; 44 char id[16]; 45 int (*parse_aopt)(struct action_util *a, int *argc, char ***argv, 46 int code, struct nlmsghdr *n); 47 int (*print_aopt)(struct action_util *au, FILE *f, struct rtattr *opt); 48 int (*print_xstats)(struct action_util *au, FILE *f, struct rtattr *xstats); 49}; 50 51struct exec_util { 52 struct exec_util *next; 53 char id[16]; 54 int (*parse_eopt)(struct exec_util *eu, int argc, char **argv); 55}; 56 57extern const char *get_tc_lib(void); 58 59extern struct qdisc_util *get_qdisc_kind(const char *str); 60extern struct filter_util *get_filter_kind(const char *str); 61 62extern int get_qdisc_handle(__u32 *h, const char *str); 63extern int get_rate(unsigned *rate, const char *str); 64extern int get_rate64(__u64 *rate, const char *str); 65extern int get_size(unsigned *size, const char *str); 66extern int get_size_and_cell(unsigned *size, int *cell_log, char *str); 67extern int get_time(unsigned *time, const char *str); 68extern int get_linklayer(unsigned *val, const char *arg); 69 70extern void print_rate(char *buf, int len, __u64 rate); 71extern void print_size(char *buf, int len, __u32 size); 72extern void print_qdisc_handle(char *buf, int len, __u32 h); 73extern void print_time(char *buf, int len, __u32 time); 74extern void print_linklayer(char *buf, int len, unsigned linklayer); 75 76extern char * sprint_rate(__u64 rate, char *buf); 77extern char * sprint_size(__u32 size, char *buf); 78extern char * sprint_qdisc_handle(__u32 h, char *buf); 79extern char * sprint_tc_classid(__u32 h, char *buf); 80extern char * sprint_time(__u32 time, char *buf); 81extern char * sprint_ticks(__u32 ticks, char *buf); 82extern char * sprint_linklayer(unsigned linklayer, char *buf); 83 84extern void print_tcstats_attr(FILE *fp, struct rtattr *tb[], char *prefix, struct rtattr **xstats); 85extern void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtattr **xstats); 86 87extern int get_tc_classid(__u32 *h, const char *str); 88extern int print_tc_classid(char *buf, int len, __u32 h); 89extern char * sprint_tc_classid(__u32 h, char *buf); 90 91extern int tc_print_police(FILE *f, struct rtattr *tb); 92extern int parse_police(int *, char ***, int, struct nlmsghdr *); 93 94extern char *action_n2a(int action, char *buf, int len); 95extern int action_a2n(char *arg, int *result); 96extern int act_parse_police(struct action_util *a,int *, char ***, int, struct nlmsghdr *); 97extern int print_police(struct action_util *a, FILE *f, 98 struct rtattr *tb); 99extern int police_print_xstats(struct action_util *a,FILE *f, 100 struct rtattr *tb); 101extern int tc_print_action(FILE *f, const struct rtattr *tb); 102extern int tc_print_ipt(FILE *f, const struct rtattr *tb); 103extern int parse_action(int *, char ***, int, struct nlmsghdr *); 104extern void print_tm(FILE *f, const struct tcf_t *tm); 105extern int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt); 106 107extern int cls_names_init(char *path); 108extern void cls_names_uninit(void); 109 110#endif 111