]> git.proxmox.com Git - mirror_iproute2.git/blame - tc/tc_util.h
tc_filter: add support for chain index
[mirror_iproute2.git] / tc / tc_util.h
CommitLineData
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>
aba5acdf
SH
6#include <linux/pkt_sched.h>
7#include <linux/pkt_cls.h>
e5879dc6 8#include <linux/gen_stats.h>
aba5acdf
SH
9#include "tc_core.h"
10
5a67f8f9
SH
11/* This is the deprecated multiqueue interface */
12#ifndef TCA_PRIO_MAX
13enum
14{
15 TCA_PRIO_UNSPEC,
16 TCA_PRIO_MQ,
17 __TCA_PRIO_MAX
18};
19
20#define TCA_PRIO_MAX (__TCA_PRIO_MAX - 1)
21#endif
22
4bd62446 23struct qdisc_util {
2373fde9 24 struct qdisc_util *next;
6dc9f016 25 const char *id;
9ffc80b1
PS
26 int (*parse_qopt)(struct qdisc_util *qu, int argc,
27 char **argv, struct nlmsghdr *n);
28 int (*print_qopt)(struct qdisc_util *qu,
29 FILE *f, struct rtattr *opt);
30 int (*print_xstats)(struct qdisc_util *qu,
31 FILE *f, struct rtattr *xstats);
32
33 int (*parse_copt)(struct qdisc_util *qu, int argc,
34 char **argv, struct nlmsghdr *n);
35 int (*print_copt)(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
aba5acdf
SH
36};
37
eefcbc72 38extern __u16 f_proto;
4bd62446 39struct filter_util {
aba5acdf 40 struct filter_util *next;
9ffc80b1
PS
41 char id[16];
42 int (*parse_fopt)(struct filter_util *qu, char *fhandle,
43 int argc, char **argv, struct nlmsghdr *n);
44 int (*print_fopt)(struct filter_util *qu,
45 FILE *f, struct rtattr *opt, __u32 fhandle);
aba5acdf
SH
46};
47
4bd62446 48struct action_util {
9ffc80b1
PS
49 struct action_util *next;
50 char id[16];
51 int (*parse_aopt)(struct action_util *a, int *argc,
52 char ***argv, int code, struct nlmsghdr *n);
53 int (*print_aopt)(struct action_util *au, FILE *f, struct rtattr *opt);
54 int (*print_xstats)(struct action_util *au,
55 FILE *f, struct rtattr *xstats);
2373fde9 56};
aba5acdf 57
4bd62446 58struct exec_util {
9ffc80b1
PS
59 struct exec_util *next;
60 char id[16];
61 int (*parse_eopt)(struct exec_util *eu, int argc, char **argv);
4bd62446
DB
62};
63
9ffc80b1
PS
64const char *get_tc_lib(void);
65
66struct qdisc_util *get_qdisc_kind(const char *str);
67struct filter_util *get_filter_kind(const char *str);
68
69int get_qdisc_handle(__u32 *h, const char *str);
70int get_rate(unsigned int *rate, const char *str);
71int get_rate64(__u64 *rate, const char *str);
72int get_size(unsigned int *size, const char *str);
73int get_size_and_cell(unsigned int *size, int *cell_log, char *str);
74int get_time(unsigned int *time, const char *str);
75int get_linklayer(unsigned int *val, const char *arg);
76
77void print_rate(char *buf, int len, __u64 rate);
78void print_size(char *buf, int len, __u32 size);
79void print_qdisc_handle(char *buf, int len, __u32 h);
80void print_time(char *buf, int len, __u32 time);
81void print_linklayer(char *buf, int len, unsigned int linklayer);
82
83char *sprint_rate(__u64 rate, char *buf);
84char *sprint_size(__u32 size, char *buf);
85char *sprint_qdisc_handle(__u32 h, char *buf);
86char *sprint_tc_classid(__u32 h, char *buf);
87char *sprint_time(__u32 time, char *buf);
88char *sprint_ticks(__u32 ticks, char *buf);
89char *sprint_linklayer(unsigned int linklayer, char *buf);
90
91void print_tcstats_attr(FILE *fp, struct rtattr *tb[],
92 char *prefix, struct rtattr **xstats);
93void print_tcstats2_attr(FILE *fp, struct rtattr *rta,
94 char *prefix, struct rtattr **xstats);
95
96int get_tc_classid(__u32 *h, const char *str);
97int print_tc_classid(char *buf, int len, __u32 h);
98char *sprint_tc_classid(__u32 h, char *buf);
99
100int tc_print_police(FILE *f, struct rtattr *tb);
101int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
102
70932006 103const char *action_n2a(int action);
53aadc52 104int action_a2n(char *arg, int *result, bool allow_num);
9ffc80b1
PS
105int act_parse_police(struct action_util *a, int *argc_p,
106 char ***argv_p, int tca_id, struct nlmsghdr *n);
107int print_police(struct action_util *a, FILE *f, struct rtattr *tb);
108int police_print_xstats(struct action_util *a, FILE *f, struct rtattr *tb);
109int tc_print_action(FILE *f, const struct rtattr *tb);
110int tc_print_ipt(FILE *f, const struct rtattr *tb);
111int parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
112void print_tm(FILE *f, const struct tcf_t *tm);
113int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt);
114
115int cls_names_init(char *path);
116void cls_names_uninit(void);
4612d04d 117
aba5acdf 118#endif