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