libnl  3.2.13
tc-api.h
1 /*
2  * netlink/route/tc-api.h Traffic Control API
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation version 2.1
7  * of the License.
8  *
9  * Copyright (c) 2011 Thomas Graf <tgraf@suug.ch>
10  */
11 
12 #ifndef NETLINK_TC_API_H_
13 #define NETLINK_TC_API_H_
14 
15 #include <netlink/netlink.h>
16 #include <netlink/msg.h>
17 #include <netlink/route/tc.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 enum rtnl_tc_type {
24  RTNL_TC_TYPE_QDISC,
25  RTNL_TC_TYPE_CLASS,
26  RTNL_TC_TYPE_CLS,
27  __RTNL_TC_TYPE_MAX
28 };
29 
30 #define RTNL_TC_TYPE_MAX (__RTNL_TC_TYPE_MAX - 1)
31 
32 /**
33  * Traffic control object operations
34  * @ingroup tc
35  *
36  * This structure holds function pointers and settings implementing
37  * the features of each traffic control object implementation.
38  */
40 {
41  /**
42  * Name of traffic control module
43  */
44  char *to_kind;
45 
46  /**
47  * Type of traffic control object
48  */
49  enum rtnl_tc_type to_type;
50 
51 
52  /**
53  * Size of private data
54  */
55  size_t to_size;
56 
57  /**
58  * Dump callbacks
59  */
60  void (*to_dump[NL_DUMP_MAX+1])(struct rtnl_tc *, void *,
61  struct nl_dump_params *);
62  /**
63  * Used to fill the contents of TCA_OPTIONS
64  */
65  int (*to_msg_fill)(struct rtnl_tc *, void *, struct nl_msg *);
66 
67  /**
68  * Uesd to to fill tc related messages, unlike with to_msg_fill,
69  * the contents is not encapsulated with a TCA_OPTIONS nested
70  * attribute.
71  */
72  int (*to_msg_fill_raw)(struct rtnl_tc *, void *, struct nl_msg *);
73 
74  /**
75  * TCA_OPTIONS message parser
76  */
77  int (*to_msg_parser)(struct rtnl_tc *, void *);
78 
79  /**
80  * Called before a tc object is destroyed
81  */
82  void (*to_free_data)(struct rtnl_tc *, void *);
83 
84  /**
85  * Called whenever a classifier object needs to be cloned
86  */
87  int (*to_clone)(void *, void *);
88 
89  /**
90  * Internal, don't touch
91  */
93 };
94 
96 {
97  enum rtnl_tc_type tt_type;
98 
99  char *tt_dump_prefix;
100 
101  /**
102  * Dump callbacks
103  */
104  void (*tt_dump[NL_DUMP_MAX+1])(struct rtnl_tc *,
105  struct nl_dump_params *);
106 };
107 
108 extern int rtnl_tc_msg_parse(struct nlmsghdr *,
109  struct rtnl_tc *);
110 extern int rtnl_tc_msg_build(struct rtnl_tc *, int,
111  int, struct nl_msg **);
112 
113 extern void rtnl_tc_free_data(struct nl_object *);
114 extern int rtnl_tc_clone(struct nl_object *,
115  struct nl_object *);
116 extern void rtnl_tc_dump_line(struct nl_object *,
117  struct nl_dump_params *);
118 extern void rtnl_tc_dump_details(struct nl_object *,
119  struct nl_dump_params *);
120 extern void rtnl_tc_dump_stats(struct nl_object *,
121  struct nl_dump_params *);
122 extern int rtnl_tc_compare(struct nl_object *,
123  struct nl_object *,
124  uint32_t, int);
125 
126 extern void * rtnl_tc_data(struct rtnl_tc *);
127 extern void * rtnl_tc_data_check(struct rtnl_tc *,
128  struct rtnl_tc_ops *);
129 
130 extern struct rtnl_tc_ops * rtnl_tc_lookup_ops(enum rtnl_tc_type,
131  const char *);
132 extern struct rtnl_tc_ops * rtnl_tc_get_ops(struct rtnl_tc *);
133 extern int rtnl_tc_register(struct rtnl_tc_ops *);
134 extern void rtnl_tc_unregister(struct rtnl_tc_ops *);
135 
136 extern void rtnl_tc_type_register(struct rtnl_tc_type_ops *);
137 extern void rtnl_tc_type_unregister(struct rtnl_tc_type_ops *);
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif