libnl 3.0
|
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 * Traffic control object 00028 * @ingroup tc 00029 */ 00030 struct rtnl_tc; 00031 00032 /** 00033 * Macro to cast qdisc/class/classifier to tc object 00034 * @ingroup tc 00035 * 00036 * @code 00037 * rtnl_tc_set_mpu(TC_CAST(qdisc), 40); 00038 * @endcode 00039 */ 00040 #define TC_CAST(ptr) ((struct rtnl_tc *) (ptr)) 00041 00042 /** 00043 * Traffic control statistical identifier 00044 * @ingroup tc 00045 * 00046 * @code 00047 * uint64_t n = rtnl_tc_get_stat(TC_CAST(class), RTNL_TC_PACKETS); 00048 * @endcode 00049 */ 00050 enum rtnl_tc_stat { 00051 RTNL_TC_PACKETS, /**< Number of packets seen */ 00052 RTNL_TC_BYTES, /**< Total bytes seen */ 00053 RTNL_TC_RATE_BPS, /**< Current bits/s (rate estimator) */ 00054 RTNL_TC_RATE_PPS, /**< Current packet/s (rate estimator) */ 00055 RTNL_TC_QLEN, /**< Current queue length */ 00056 RTNL_TC_BACKLOG, /**< Current backlog length */ 00057 RTNL_TC_DROPS, /**< Total number of packets dropped */ 00058 RTNL_TC_REQUEUES, /**< Total number of requeues */ 00059 RTNL_TC_OVERLIMITS, /**< Total number of overlimits */ 00060 __RTNL_TC_STATS_MAX, 00061 }; 00062 00063 #define RTNL_TC_STATS_MAX (__RTNL_TC_STATS_MAX - 1) 00064 00065 extern void rtnl_tc_set_ifindex(struct rtnl_tc *, int); 00066 extern int rtnl_tc_get_ifindex(struct rtnl_tc *); 00067 extern void rtnl_tc_set_link(struct rtnl_tc *, struct rtnl_link *); 00068 extern void rtnl_tc_set_mtu(struct rtnl_tc *, uint32_t); 00069 extern uint32_t rtnl_tc_get_mtu(struct rtnl_tc *); 00070 extern void rtnl_tc_set_mpu(struct rtnl_tc *, uint32_t); 00071 extern uint32_t rtnl_tc_get_mpu(struct rtnl_tc *); 00072 extern void rtnl_tc_set_overhead(struct rtnl_tc *, uint32_t); 00073 extern uint32_t rtnl_tc_get_overhead(struct rtnl_tc *); 00074 extern void rtnl_tc_set_linktype(struct rtnl_tc *, uint32_t); 00075 extern uint32_t rtnl_tc_get_linktype(struct rtnl_tc *); 00076 extern void rtnl_tc_set_handle(struct rtnl_tc *, uint32_t); 00077 extern uint32_t rtnl_tc_get_handle(struct rtnl_tc *); 00078 extern void rtnl_tc_set_parent(struct rtnl_tc *, uint32_t); 00079 extern uint32_t rtnl_tc_get_parent(struct rtnl_tc *); 00080 extern int rtnl_tc_set_kind(struct rtnl_tc *, const char *); 00081 extern char * rtnl_tc_get_kind(struct rtnl_tc *); 00082 extern uint64_t rtnl_tc_get_stat(struct rtnl_tc *, enum rtnl_tc_stat); 00083 00084 extern int rtnl_tc_calc_txtime(int, int); 00085 extern int rtnl_tc_calc_bufsize(int, int); 00086 extern int rtnl_tc_calc_cell_log(int); 00087 00088 extern int rtnl_tc_read_classid_file(void); 00089 extern char * rtnl_tc_handle2str(uint32_t, char *, size_t); 00090 extern int rtnl_tc_str2handle(const char *, uint32_t *); 00091 extern int rtnl_classid_generate(const char *, uint32_t *, 00092 uint32_t); 00093 00094 #ifdef __cplusplus 00095 } 00096 #endif 00097 00098 #endif