2007-09-15 01:28:01 +02:00
|
|
|
/*
|
|
|
|
* netlink/route/tc.h Traffic Control
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
2011-03-21 15:51:52 +01:00
|
|
|
* Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch>
|
2007-09-15 01:28:01 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NETLINK_TC_H_
|
|
|
|
#define NETLINK_TC_H_
|
|
|
|
|
|
|
|
#include <netlink/netlink.h>
|
|
|
|
#include <netlink/cache.h>
|
|
|
|
#include <netlink/data.h>
|
2010-10-26 12:54:33 +02:00
|
|
|
#include <netlink/route/link.h>
|
2011-03-16 12:59:31 +01:00
|
|
|
#include <linux/pkt_sched.h>
|
|
|
|
#include <linux/pkt_cls.h>
|
2007-09-15 01:28:01 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-01-23 13:17:43 +01:00
|
|
|
enum rtnl_tc_type {
|
|
|
|
RTNL_TC_TYPE_QDISC,
|
|
|
|
RTNL_TC_TYPE_CLASS,
|
|
|
|
RTNL_TC_TYPE_CLS,
|
2013-11-08 10:47:49 -08:00
|
|
|
RTNL_TC_TYPE_ACT,
|
2013-01-23 13:17:43 +01:00
|
|
|
__RTNL_TC_TYPE_MAX,
|
|
|
|
};
|
|
|
|
|
2013-01-24 13:51:24 +01:00
|
|
|
#define RTNL_TC_TYPE_MAX (__RTNL_TC_TYPE_MAX - 1)
|
|
|
|
|
2011-04-01 16:25:57 +02:00
|
|
|
/**
|
|
|
|
* Compute tc handle based on major and minor parts
|
|
|
|
* @ingroup tc
|
|
|
|
*/
|
|
|
|
#define TC_HANDLE(maj, min) (TC_H_MAJ((maj) << 16) | TC_H_MIN(min))
|
|
|
|
|
2011-03-21 15:51:52 +01:00
|
|
|
/**
|
|
|
|
* Traffic control object
|
|
|
|
* @ingroup tc
|
|
|
|
*/
|
2010-10-26 12:54:33 +02:00
|
|
|
struct rtnl_tc;
|
|
|
|
|
2007-09-15 01:28:01 +02:00
|
|
|
/**
|
2011-03-21 15:51:52 +01:00
|
|
|
* Macro to cast qdisc/class/classifier to tc object
|
2007-09-15 01:28:01 +02:00
|
|
|
* @ingroup tc
|
2011-03-21 15:51:52 +01:00
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* rtnl_tc_set_mpu(TC_CAST(qdisc), 40);
|
|
|
|
* @endcode
|
|
|
|
*/
|
|
|
|
#define TC_CAST(ptr) ((struct rtnl_tc *) (ptr))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Traffic control statistical identifier
|
|
|
|
* @ingroup tc
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* uint64_t n = rtnl_tc_get_stat(TC_CAST(class), RTNL_TC_PACKETS);
|
|
|
|
* @endcode
|
2007-09-15 01:28:01 +02:00
|
|
|
*/
|
2011-03-21 15:51:52 +01:00
|
|
|
enum rtnl_tc_stat {
|
2010-10-26 12:54:33 +02:00
|
|
|
RTNL_TC_PACKETS, /**< Number of packets seen */
|
|
|
|
RTNL_TC_BYTES, /**< Total bytes seen */
|
2007-09-15 01:28:01 +02:00
|
|
|
RTNL_TC_RATE_BPS, /**< Current bits/s (rate estimator) */
|
|
|
|
RTNL_TC_RATE_PPS, /**< Current packet/s (rate estimator) */
|
2010-10-26 12:54:33 +02:00
|
|
|
RTNL_TC_QLEN, /**< Current queue length */
|
|
|
|
RTNL_TC_BACKLOG, /**< Current backlog length */
|
|
|
|
RTNL_TC_DROPS, /**< Total number of packets dropped */
|
|
|
|
RTNL_TC_REQUEUES, /**< Total number of requeues */
|
|
|
|
RTNL_TC_OVERLIMITS, /**< Total number of overlimits */
|
2007-09-15 01:28:01 +02:00
|
|
|
__RTNL_TC_STATS_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RTNL_TC_STATS_MAX (__RTNL_TC_STATS_MAX - 1)
|
|
|
|
|
2010-10-26 12:54:33 +02:00
|
|
|
extern void rtnl_tc_set_ifindex(struct rtnl_tc *, int);
|
|
|
|
extern int rtnl_tc_get_ifindex(struct rtnl_tc *);
|
|
|
|
extern void rtnl_tc_set_link(struct rtnl_tc *, struct rtnl_link *);
|
2011-04-21 14:58:05 +02:00
|
|
|
extern struct rtnl_link *rtnl_tc_get_link(struct rtnl_tc *);
|
2010-10-26 12:54:33 +02:00
|
|
|
extern void rtnl_tc_set_mtu(struct rtnl_tc *, uint32_t);
|
|
|
|
extern uint32_t rtnl_tc_get_mtu(struct rtnl_tc *);
|
|
|
|
extern void rtnl_tc_set_mpu(struct rtnl_tc *, uint32_t);
|
|
|
|
extern uint32_t rtnl_tc_get_mpu(struct rtnl_tc *);
|
|
|
|
extern void rtnl_tc_set_overhead(struct rtnl_tc *, uint32_t);
|
|
|
|
extern uint32_t rtnl_tc_get_overhead(struct rtnl_tc *);
|
|
|
|
extern void rtnl_tc_set_linktype(struct rtnl_tc *, uint32_t);
|
|
|
|
extern uint32_t rtnl_tc_get_linktype(struct rtnl_tc *);
|
|
|
|
extern void rtnl_tc_set_handle(struct rtnl_tc *, uint32_t);
|
|
|
|
extern uint32_t rtnl_tc_get_handle(struct rtnl_tc *);
|
|
|
|
extern void rtnl_tc_set_parent(struct rtnl_tc *, uint32_t);
|
|
|
|
extern uint32_t rtnl_tc_get_parent(struct rtnl_tc *);
|
2011-03-21 15:51:52 +01:00
|
|
|
extern int rtnl_tc_set_kind(struct rtnl_tc *, const char *);
|
2010-10-26 12:54:33 +02:00
|
|
|
extern char * rtnl_tc_get_kind(struct rtnl_tc *);
|
2011-03-21 15:51:52 +01:00
|
|
|
extern uint64_t rtnl_tc_get_stat(struct rtnl_tc *, enum rtnl_tc_stat);
|
2015-01-28 17:12:12 -08:00
|
|
|
extern char * rtnl_tc_stat2str(enum rtnl_tc_stat, char *, size_t);
|
|
|
|
extern int rtnl_tc_str2stat(const char *);
|
2007-09-15 01:28:01 +02:00
|
|
|
|
2010-10-26 12:54:33 +02:00
|
|
|
extern int rtnl_tc_calc_txtime(int, int);
|
|
|
|
extern int rtnl_tc_calc_bufsize(int, int);
|
|
|
|
extern int rtnl_tc_calc_cell_log(int);
|
2007-09-15 01:28:01 +02:00
|
|
|
|
2010-10-19 16:31:23 +02:00
|
|
|
extern int rtnl_tc_read_classid_file(void);
|
2007-09-15 01:28:01 +02:00
|
|
|
extern char * rtnl_tc_handle2str(uint32_t, char *, size_t);
|
|
|
|
extern int rtnl_tc_str2handle(const char *, uint32_t *);
|
2010-11-01 08:17:40 +01:00
|
|
|
extern int rtnl_classid_generate(const char *, uint32_t *,
|
|
|
|
uint32_t);
|
2007-09-15 01:28:01 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|