libnl
3.2.3
|
00001 /* 00002 * netlink/route/tc.h Traffic Control 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation version 2.1 00007 * of the License. 00008 * 00009 * Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch> 00010 */ 00011 00012 #ifndef NETLINK_TC_H_ 00013 #define NETLINK_TC_H_ 00014 00015 #include <netlink/netlink.h> 00016 #include <netlink/cache.h> 00017 #include <netlink/data.h> 00018 #include <netlink/route/link.h> 00019 #include <linux/pkt_sched.h> 00020 #include <linux/pkt_cls.h> 00021 00022 #ifdef __cplusplus 00023 extern "C" { 00024 #endif 00025 00026 /** 00027 * Compute tc handle based on major and minor parts 00028 * @ingroup tc 00029 */ 00030 #define TC_HANDLE(maj, min) (TC_H_MAJ((maj) << 16) | TC_H_MIN(min)) 00031 00032 /** 00033 * Traffic control object 00034 * @ingroup tc 00035 */ 00036 struct rtnl_tc; 00037 00038 /** 00039 * Macro to cast qdisc/class/classifier to tc object 00040 * @ingroup tc 00041 * 00042 * @code 00043 * rtnl_tc_set_mpu(TC_CAST(qdisc), 40); 00044 * @endcode 00045 */ 00046 #define TC_CAST(ptr) ((struct rtnl_tc *) (ptr)) 00047 00048 /** 00049 * Traffic control statistical identifier 00050 * @ingroup tc 00051 * 00052 * @code 00053 * uint64_t n = rtnl_tc_get_stat(TC_CAST(class), RTNL_TC_PACKETS); 00054 * @endcode 00055 */ 00056 enum rtnl_tc_stat { 00057 RTNL_TC_PACKETS, /**< Number of packets seen */ 00058 RTNL_TC_BYTES, /**< Total bytes seen */ 00059 RTNL_TC_RATE_BPS, /**< Current bits/s (rate estimator) */ 00060 RTNL_TC_RATE_PPS, /**< Current packet/s (rate estimator) */ 00061 RTNL_TC_QLEN, /**< Current queue length */ 00062 RTNL_TC_BACKLOG, /**< Current backlog length */ 00063 RTNL_TC_DROPS, /**< Total number of packets dropped */ 00064 RTNL_TC_REQUEUES, /**< Total number of requeues */ 00065 RTNL_TC_OVERLIMITS, /**< Total number of overlimits */ 00066 __RTNL_TC_STATS_MAX, 00067 }; 00068 00069 #define RTNL_TC_STATS_MAX (__RTNL_TC_STATS_MAX - 1) 00070 00071 extern void rtnl_tc_set_ifindex(struct rtnl_tc *, int); 00072 extern int rtnl_tc_get_ifindex(struct rtnl_tc *); 00073 extern void rtnl_tc_set_link(struct rtnl_tc *, struct rtnl_link *); 00074 extern struct rtnl_link *rtnl_tc_get_link(struct rtnl_tc *); 00075 extern void rtnl_tc_set_mtu(struct rtnl_tc *, uint32_t); 00076 extern uint32_t rtnl_tc_get_mtu(struct rtnl_tc *); 00077 extern void rtnl_tc_set_mpu(struct rtnl_tc *, uint32_t); 00078 extern uint32_t rtnl_tc_get_mpu(struct rtnl_tc *); 00079 extern void rtnl_tc_set_overhead(struct rtnl_tc *, uint32_t); 00080 extern uint32_t rtnl_tc_get_overhead(struct rtnl_tc *); 00081 extern void rtnl_tc_set_linktype(struct rtnl_tc *, uint32_t); 00082 extern uint32_t rtnl_tc_get_linktype(struct rtnl_tc *); 00083 extern void rtnl_tc_set_handle(struct rtnl_tc *, uint32_t); 00084 extern uint32_t rtnl_tc_get_handle(struct rtnl_tc *); 00085 extern void rtnl_tc_set_parent(struct rtnl_tc *, uint32_t); 00086 extern uint32_t rtnl_tc_get_parent(struct rtnl_tc *); 00087 extern int rtnl_tc_set_kind(struct rtnl_tc *, const char *); 00088 extern char * rtnl_tc_get_kind(struct rtnl_tc *); 00089 extern uint64_t rtnl_tc_get_stat(struct rtnl_tc *, enum rtnl_tc_stat); 00090 00091 extern int rtnl_tc_calc_txtime(int, int); 00092 extern int rtnl_tc_calc_bufsize(int, int); 00093 extern int rtnl_tc_calc_cell_log(int); 00094 00095 extern int rtnl_tc_read_classid_file(void); 00096 extern char * rtnl_tc_handle2str(uint32_t, char *, size_t); 00097 extern int rtnl_tc_str2handle(const char *, uint32_t *); 00098 extern int rtnl_classid_generate(const char *, uint32_t *, 00099 uint32_t); 00100 00101 #ifdef __cplusplus 00102 } 00103 #endif 00104 00105 #endif