diff options
author | Thomas Graf <tgraf@suug.ch> | 2011-03-21 14:51:52 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2011-03-21 14:51:52 (GMT) |
commit | 8eb5b5532eae985a5f0911dccf2db8cb4e0a5de4 (patch) | |
tree | 0fec48d114edbb535bd234f2684acccf81447d13 /include | |
parent | 5dc897d5de9f54078221b241e0122713207f5e0c (diff) | |
download | libnl-8eb5b5532eae985a5f0911dccf2db8cb4e0a5de4.zip libnl-8eb5b5532eae985a5f0911dccf2db8cb4e0a5de4.tar.gz libnl-8eb5b5532eae985a5f0911dccf2db8cb4e0a5de4.tar.bz2 |
Unified TC API
Finally got rid of all the qdisc/class/cls code duplication in
the tc module API. The API takes care of allocation/freeing the
tc object specific data.
I hope I got it right this time.
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 4 | ||||
-rw-r--r-- | include/netlink-tc.h | 17 | ||||
-rw-r--r-- | include/netlink-types.h | 18 | ||||
-rw-r--r-- | include/netlink/cli/class.h | 3 | ||||
-rw-r--r-- | include/netlink/cli/cls.h | 15 | ||||
-rw-r--r-- | include/netlink/cli/qdisc.h | 20 | ||||
-rw-r--r-- | include/netlink/cli/tc.h | 18 | ||||
-rw-r--r-- | include/netlink/route/class-modules.h | 73 | ||||
-rw-r--r-- | include/netlink/route/class.h | 2 | ||||
-rw-r--r-- | include/netlink/route/classifier-modules.h | 78 | ||||
-rw-r--r-- | include/netlink/route/classifier.h | 7 | ||||
-rw-r--r-- | include/netlink/route/qdisc-modules.h | 75 | ||||
-rw-r--r-- | include/netlink/route/sch/netem.h | 26 | ||||
-rw-r--r-- | include/netlink/route/sch/prio.h | 4 | ||||
-rw-r--r-- | include/netlink/route/sch/sfq.h | 8 | ||||
-rw-r--r-- | include/netlink/route/sch/tbf.h | 6 | ||||
-rw-r--r-- | include/netlink/route/tc-api.h | 141 | ||||
-rw-r--r-- | include/netlink/route/tc.h | 26 |
18 files changed, 213 insertions, 328 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 8815a6e..8824dfe 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -43,20 +43,18 @@ nobase_include_HEADERS = \ netlink/route/sch/sfq.h \ netlink/route/sch/tbf.h \ netlink/route/addr.h \ - netlink/route/class-modules.h \ netlink/route/class.h \ - netlink/route/classifier-modules.h \ netlink/route/classifier.h \ netlink/route/link.h \ netlink/route/neighbour.h \ netlink/route/neightbl.h \ netlink/route/nexthop.h \ - netlink/route/qdisc-modules.h \ netlink/route/qdisc.h \ netlink/route/route.h \ netlink/route/rtnl.h \ netlink/route/rule.h \ netlink/route/tc.h \ + netlink/route/tc-api.h \ netlink/socket.h \ netlink/types.h \ netlink/utils.h \ diff --git a/include/netlink-tc.h b/include/netlink-tc.h index 9e4bce9..3e44642 100644 --- a/include/netlink-tc.h +++ b/include/netlink-tc.h @@ -36,18 +36,6 @@ extern "C" { extern int tca_parse(struct nlattr **, int, struct rtnl_tc *, struct nla_policy *); -extern int tca_msg_parser(struct nlmsghdr *, struct rtnl_tc *); -extern void tca_free_data(struct rtnl_tc *); -extern int tca_clone(struct rtnl_tc *, struct rtnl_tc *); -extern void tca_dump_line(struct rtnl_tc *, const char *, - struct nl_dump_params *); -extern void tca_dump_details(struct rtnl_tc *, struct nl_dump_params *); -extern void tca_dump_stats(struct rtnl_tc *, struct nl_dump_params *); -extern int tca_compare(struct nl_object *, struct nl_object *, uint32_t, int); - -extern void tca_set_kind(struct rtnl_tc *, const char *); - -extern int tca_build_msg(struct rtnl_tc *, int, int, struct nl_msg **); #define RTNL_TC_RTABLE_SIZE 256 @@ -55,11 +43,6 @@ extern int rtnl_tc_build_rate_table(struct rtnl_tc *tc, struct rtnl_ratespec *, uint32_t *); -static inline void *tca_priv(struct rtnl_tc *tca) -{ - return tca->tc_subdata; -} - static inline void *tca_xstats(struct rtnl_tc *tca) { return tca->tc_xstats->d_data; diff --git a/include/netlink-types.h b/include/netlink-types.h index de17f9a..1cb7c0e 100644 --- a/include/netlink-types.h +++ b/include/netlink-types.h @@ -17,6 +17,7 @@ #include <netlink/route/qdisc.h> #include <netlink/route/rtnl.h> #include <netlink/route/route.h> +#include <netlink/route/tc-api.h> #define NL_SOCK_BUFSIZE_SET (1<<0) #define NL_SOCK_PASSCRED (1<<1) @@ -441,7 +442,7 @@ struct rtnl_tstats #define TCKINDSIZ 32 -#define NL_TCA_GENERIC(pre) \ +#define NL_TC_GENERIC(pre) \ NLHDR_COMMON \ uint32_t pre ##_family; \ uint32_t pre ##_ifindex; \ @@ -457,31 +458,30 @@ struct rtnl_tstats uint64_t pre ##_stats[RTNL_TC_STATS_MAX+1]; \ struct nl_data * pre ##_xstats; \ struct nl_data * pre ##_subdata; \ - struct rtnl_link * pre ##_link + struct rtnl_link * pre ##_link; \ + struct rtnl_tc_ops * pre ##_ops; \ + enum rtnl_tc_type pre ##_type struct rtnl_tc { - NL_TCA_GENERIC(tc); + NL_TC_GENERIC(tc); }; struct rtnl_qdisc { - NL_TCA_GENERIC(q); - struct rtnl_qdisc_ops *q_ops; + NL_TC_GENERIC(q); }; struct rtnl_class { - NL_TCA_GENERIC(c); - struct rtnl_class_ops *c_ops; + NL_TC_GENERIC(c); }; struct rtnl_cls { - NL_TCA_GENERIC(c); + NL_TC_GENERIC(c); uint16_t c_prio; uint16_t c_protocol; - struct rtnl_cls_ops *c_ops; }; struct rtnl_u32 diff --git a/include/netlink/cli/class.h b/include/netlink/cli/class.h index 0141c21..5001e42 100644 --- a/include/netlink/cli/class.h +++ b/include/netlink/cli/class.h @@ -13,12 +13,9 @@ #define __NETLINK_CLI_CLASS_H_ #include <netlink/route/class.h> -#include <netlink/route/class-modules.h> #include <netlink/cli/tc.h> extern struct rtnl_class *nl_cli_class_alloc(void); extern struct nl_cache *nl_cli_class_alloc_cache(struct nl_sock *, int); -extern void nl_cli_class_parse_kind(struct rtnl_class *, char *); - #endif diff --git a/include/netlink/cli/cls.h b/include/netlink/cli/cls.h index cdcb17e..a2707b8 100644 --- a/include/netlink/cli/cls.h +++ b/include/netlink/cli/cls.h @@ -13,27 +13,12 @@ #define __NETLINK_CLI_CLS_H_ #include <netlink/route/classifier.h> -#include <netlink/route/classifier-modules.h> #include <netlink/cli/tc.h> -struct nl_cli_cls_module -{ - const char * cm_name; - struct rtnl_cls_ops * cm_ops; - int (*cm_parse_argv)(struct rtnl_cls *, int, char **); - struct nl_list_head cm_list; -}; - extern struct rtnl_cls * nl_cli_cls_alloc(void); extern struct nl_cache * nl_cli_cls_alloc_cache(struct nl_sock *, int, uint32_t); -extern void nl_cli_cls_parse_kind(struct rtnl_cls *, char *); extern void nl_cli_cls_parse_proto(struct rtnl_cls *, char *); extern struct rtnl_ematch_tree *nl_cli_cls_parse_ematch(struct rtnl_cls *, char *); -extern struct nl_cli_cls_module *nl_cli_cls_lookup(struct rtnl_cls_ops *); -extern void nl_cli_cls_register(struct nl_cli_cls_module *); -extern void nl_cli_cls_unregister(struct nl_cli_cls_module *); - - #endif diff --git a/include/netlink/cli/qdisc.h b/include/netlink/cli/qdisc.h index 00c7083..b102da4 100644 --- a/include/netlink/cli/qdisc.h +++ b/include/netlink/cli/qdisc.h @@ -6,36 +6,18 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2008-2010 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2008-2011 Thomas Graf <tgraf@suug.ch> */ #ifndef __NETLINK_CLI_QDISC_H_ #define __NETLINK_CLI_QDISC_H_ #include <netlink/route/qdisc.h> -#include <netlink/route/qdisc-modules.h> #define nl_cli_qdisc_alloc_cache(sk) \ nl_cli_alloc_cache((sk), "queueing disciplines", \ rtnl_qdisc_alloc_cache) -struct nl_cli_qdisc_module -{ - const char * qm_name; - struct rtnl_qdisc_ops * qm_ops; - struct rtnl_class_ops * qm_class_ops; - void (*qm_parse_qdisc_argv)(struct rtnl_qdisc *, int, char **); - void (*qm_parse_class_argv)(struct rtnl_class *, int, char **); - struct nl_list_head qm_list; -}; - -extern struct nl_cli_qdisc_module *nl_cli_qdisc_lookup(struct rtnl_qdisc_ops *); -extern struct nl_cli_qdisc_module *nl_cli_qdisc_lookup_by_class(struct rtnl_class_ops *); -extern void nl_cli_qdisc_register(struct nl_cli_qdisc_module *); -extern void nl_cli_qdisc_unregister(struct nl_cli_qdisc_module *); - extern struct rtnl_qdisc *nl_cli_qdisc_alloc(void); -extern void nl_cli_qdisc_parse_kind(struct rtnl_qdisc *, char *); - #endif diff --git a/include/netlink/cli/tc.h b/include/netlink/cli/tc.h index 82f9a1d..85d2e30 100644 --- a/include/netlink/cli/tc.h +++ b/include/netlink/cli/tc.h @@ -6,13 +6,13 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch> */ #ifndef __NETLINK_CLI_TC_H_ #define __NETLINK_CLI_TC_H_ -#include <netlink/route/tc.h> +#include <netlink/route/tc-api.h> extern void nl_cli_tc_parse_dev(struct rtnl_tc *, struct nl_cache *, char *); extern void nl_cli_tc_parse_parent(struct rtnl_tc *, char *); @@ -21,5 +21,19 @@ extern void nl_cli_tc_parse_mtu(struct rtnl_tc *, char *); extern void nl_cli_tc_parse_mpu(struct rtnl_tc *, char *); extern void nl_cli_tc_parse_overhead(struct rtnl_tc *, char *); extern void nl_cli_tc_parse_linktype(struct rtnl_tc *, char *); +extern void nl_cli_tc_parse_kind(struct rtnl_tc *, char *); + +struct nl_cli_tc_module +{ + const char * tm_name; + enum rtnl_tc_type tm_type; + struct rtnl_tc_ops * tm_ops; + void (*tm_parse_argv)(struct rtnl_tc *, int, char **); + struct nl_list_head tm_list; +}; + +extern struct nl_cli_tc_module *nl_cli_tc_lookup(struct rtnl_tc_ops *); +extern void nl_cli_tc_register(struct nl_cli_tc_module *); +extern void nl_cli_tc_unregister(struct nl_cli_tc_module *); #endif diff --git a/include/netlink/route/class-modules.h b/include/netlink/route/class-modules.h deleted file mode 100644 index 74a25c9..0000000 --- a/include/netlink/route/class-modules.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * netlink/route/class-modules.h Class Module API - * - * 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. - * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> - */ - -#ifndef NETLINK_CLASS_MODULES_H_ -#define NETLINK_CLASS_MODULES_H_ - -#include <netlink/netlink.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Class operations - * @ingroup class_api - */ -struct rtnl_class_ops -{ - /** - * Kind/Name of class - */ - char co_kind[32]; - - /** - * Dump callbacks - */ - void (*co_dump[NL_DUMP_MAX+1])(struct rtnl_class *, - struct nl_dump_params *); - - /** - * Must return the contents supposed to be in TCA_OPTIONS - */ - struct nl_msg *(*co_get_opts)(struct rtnl_class *); - - /** - * TCA_OPTIONS message parser - */ - int (*co_msg_parser)(struct rtnl_class *); - - /** - * Called before a class object gets destroyed - */ - void (*co_free_data)(struct rtnl_class *); - - /** - * Called whenever a class object needs to be cloned - */ - int (*co_clone)(struct rtnl_class *, struct rtnl_class *); - - /** - * INTERNAL (Do not use) - */ - struct rtnl_class_ops *co_next; -}; - -extern int rtnl_class_register(struct rtnl_class_ops *); -extern int rtnl_class_unregister(struct rtnl_class_ops *); -extern struct rtnl_class_ops * rtnl_class_lookup_ops(struct rtnl_class *); -extern struct rtnl_class_ops * __rtnl_class_lookup_ops(const char *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/netlink/route/class.h b/include/netlink/route/class.h index 13a25d6..ad3bacf 100644 --- a/include/netlink/route/class.h +++ b/include/netlink/route/class.h @@ -22,8 +22,6 @@ extern "C" { struct rtnl_class; -extern struct nl_object_ops class_obj_ops; - extern struct rtnl_class * rtnl_class_alloc(void); extern void rtnl_class_put(struct rtnl_class *); extern int rtnl_class_alloc_cache(struct nl_sock *, int, diff --git a/include/netlink/route/classifier-modules.h b/include/netlink/route/classifier-modules.h deleted file mode 100644 index 35cb06e..0000000 --- a/include/netlink/route/classifier-modules.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * netlink/route/classifier-modules.h Classifier Module API - * - * 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. - * - * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch> - */ - -#ifndef NETLINK_CLASS_MODULES_H_ -#define NETLINK_CLASS_MODULES_H_ - -#include <netlink/netlink.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Classifier operations - * @ingroup cls_api - */ -struct rtnl_cls_ops -{ - /** - * Name of classifier module - */ - char co_kind[32]; - - - /** - * Size of private classifier data - */ - size_t co_size; - - /** - * Dump callbacks - */ - void (*co_dump[NL_DUMP_MAX+1])(struct rtnl_cls *, - struct nl_dump_params *); - /** - * Must return the contents supposed to be in TCA_OPTIONS - */ - int (*co_get_opts)(struct rtnl_cls *, struct nl_msg *); - - /** - * TCA_OPTIONS message parser - */ - int (*co_msg_parser)(struct rtnl_cls *); - - /** - * Called before a class object gets destroyed - */ - void (*co_free_data)(struct rtnl_cls *); - - /** - * Called whenever a classifier object needs to be cloned - */ - int (*co_clone)(struct rtnl_cls *, struct rtnl_cls *); - - /** - * INTERNAL (Do not use) - */ - struct rtnl_cls_ops *co_next; -}; - -extern int rtnl_cls_register(struct rtnl_cls_ops *); -extern int rtnl_cls_unregister(struct rtnl_cls_ops *); -extern struct rtnl_cls_ops * rtnl_cls_lookup_ops(struct rtnl_cls *); -extern struct rtnl_cls_ops * __rtnl_cls_lookup_ops(const char *kind); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/netlink/route/classifier.h b/include/netlink/route/classifier.h index 17c834b..23af837 100644 --- a/include/netlink/route/classifier.h +++ b/include/netlink/route/classifier.h @@ -21,8 +21,6 @@ extern "C" { #endif -extern struct nl_object_ops cls_obj_ops; - extern struct rtnl_cls *rtnl_cls_alloc(void); extern void rtnl_cls_put(struct rtnl_cls *); @@ -39,17 +37,12 @@ extern int rtnl_cls_build_delete_request(struct rtnl_cls *, int, struct nl_msg **); extern int rtnl_cls_delete(struct nl_sock *, struct rtnl_cls *, int); -extern int rtnl_cls_set_kind(struct rtnl_cls *, const char *); -extern struct rtnl_cls_ops *rtnl_cls_get_ops(struct rtnl_cls *); - extern void rtnl_cls_set_prio(struct rtnl_cls *, uint16_t); extern uint16_t rtnl_cls_get_prio(struct rtnl_cls *); extern void rtnl_cls_set_protocol(struct rtnl_cls *, uint16_t); extern uint16_t rtnl_cls_get_protocol(struct rtnl_cls *); -extern void *rtnl_cls_data(struct rtnl_cls *); - #ifdef __cplusplus } #endif diff --git a/include/netlink/route/qdisc-modules.h b/include/netlink/route/qdisc-modules.h deleted file mode 100644 index 769625e..0000000 --- a/include/netlink/route/qdisc-modules.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * netlink/route/qdisc-modules.h Qdisc Module API - * - * 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. - * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> - */ - -#ifndef NETLINK_QDISC_MODULES_H_ -#define NETLINK_QDISC_MODULES_H_ - -#include <netlink/netlink.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Qdisc Operations - * @ingroup qdisc - */ -struct rtnl_qdisc_ops -{ - /** - * Kind/Name of Qdisc - */ - char qo_kind[32]; - - /** - * Dump callbacks - */ - void (*qo_dump[NL_DUMP_MAX+1])(struct rtnl_qdisc *, - struct nl_dump_params *); - - /** - * Must return the contents supposed to be in TCA_OPTIONS - */ - struct nl_msg *(*qo_get_opts)(struct rtnl_qdisc *); - - int (*qo_build_msg)(struct rtnl_qdisc *, struct nl_msg *); - - /** - * TCA_OPTIONS message parser - */ - int (*qo_msg_parser)(struct rtnl_qdisc *); - - /** - * Called before a Qdisc object gets destroyed - */ - void (*qo_free_data)(struct rtnl_qdisc *); - - /** - * Called whenever a qdisc object needs to be cloned - */ - int (*qo_clone)(struct rtnl_qdisc *, struct rtnl_qdisc *); - - /** - * INTERNAL (Do not use) - */ - struct rtnl_qdisc_ops *qo_next; -}; - -extern int rtnl_qdisc_register(struct rtnl_qdisc_ops *); -extern int rtnl_qdisc_unregister(struct rtnl_qdisc_ops *); -extern struct rtnl_qdisc_ops * rtnl_qdisc_lookup_ops(struct rtnl_qdisc *); -extern struct rtnl_qdisc_ops * __rtnl_qdisc_lookup_ops(const char *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/netlink/route/sch/netem.h b/include/netlink/route/sch/netem.h index c293777..ce56ee7 100644 --- a/include/netlink/route/sch/netem.h +++ b/include/netlink/route/sch/netem.h @@ -18,48 +18,48 @@ extern "C" { #endif -extern int rtnl_netem_set_limit(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_limit(struct rtnl_qdisc *, int); extern int rtnl_netem_get_limit(struct rtnl_qdisc *); /* Packet Re-ordering */ -extern int rtnl_netem_set_gap(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_gap(struct rtnl_qdisc *, int); extern int rtnl_netem_get_gap(struct rtnl_qdisc *); -extern int rtnl_netem_set_reorder_probability(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_reorder_probability(struct rtnl_qdisc *, int); extern int rtnl_netem_get_reorder_probability(struct rtnl_qdisc *); -extern int rtnl_netem_set_reorder_correlation(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_reorder_correlation(struct rtnl_qdisc *, int); extern int rtnl_netem_get_reorder_correlation(struct rtnl_qdisc *); /* Corruption */ -extern int rtnl_netem_set_corruption_probability(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_corruption_probability(struct rtnl_qdisc *, int); extern int rtnl_netem_get_corruption_probability(struct rtnl_qdisc *); -extern int rtnl_netem_set_corruption_correlation(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_corruption_correlation(struct rtnl_qdisc *, int); extern int rtnl_netem_get_corruption_correlation(struct rtnl_qdisc *); /* Packet Loss */ -extern int rtnl_netem_set_loss(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_loss(struct rtnl_qdisc *, int); extern int rtnl_netem_get_loss(struct rtnl_qdisc *); -extern int rtnl_netem_set_loss_correlation(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_loss_correlation(struct rtnl_qdisc *, int); extern int rtnl_netem_get_loss_correlation(struct rtnl_qdisc *); /* Packet Duplication */ -extern int rtnl_netem_set_duplicate(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_duplicate(struct rtnl_qdisc *, int); extern int rtnl_netem_get_duplicate(struct rtnl_qdisc *); -extern int rtnl_netem_set_duplicate_correlation(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_duplicate_correlation(struct rtnl_qdisc *, int); extern int rtnl_netem_get_duplicate_correlation(struct rtnl_qdisc *); /* Packet Delay */ -extern int rtnl_netem_set_delay(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_delay(struct rtnl_qdisc *, int); extern int rtnl_netem_get_delay(struct rtnl_qdisc *); -extern int rtnl_netem_set_jitter(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_jitter(struct rtnl_qdisc *, int); extern int rtnl_netem_get_jitter(struct rtnl_qdisc *); -extern int rtnl_netem_set_delay_correlation(struct rtnl_qdisc *, int); +extern void rtnl_netem_set_delay_correlation(struct rtnl_qdisc *, int); extern int rtnl_netem_get_delay_correlation(struct rtnl_qdisc *); /* Delay Distribution */ diff --git a/include/netlink/route/sch/prio.h b/include/netlink/route/sch/prio.h index ff35b07..f6fdc86 100644 --- a/include/netlink/route/sch/prio.h +++ b/include/netlink/route/sch/prio.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_PRIO_H_ @@ -38,7 +38,7 @@ extern "C" { /** @} */ -extern int rtnl_qdisc_prio_set_bands(struct rtnl_qdisc *, int); +extern void rtnl_qdisc_prio_set_bands(struct rtnl_qdisc *, int); extern int rtnl_qdisc_prio_get_bands(struct rtnl_qdisc *); extern int rtnl_qdisc_prio_set_priomap(struct rtnl_qdisc *, uint8_t[], int); extern uint8_t *rtnl_qdisc_prio_get_priomap(struct rtnl_qdisc *); diff --git a/include/netlink/route/sch/sfq.h b/include/netlink/route/sch/sfq.h index 19b3817..7cc0b3e 100644 --- a/include/netlink/route/sch/sfq.h +++ b/include/netlink/route/sch/sfq.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_SFQ_H_ @@ -18,13 +18,13 @@ extern "C" { #endif -extern int rtnl_sfq_set_quantum(struct rtnl_qdisc *, int); +extern void rtnl_sfq_set_quantum(struct rtnl_qdisc *, int); extern int rtnl_sfq_get_quantum(struct rtnl_qdisc *); -extern int rtnl_sfq_set_limit(struct rtnl_qdisc *, int); +extern void rtnl_sfq_set_limit(struct rtnl_qdisc *, int); extern int rtnl_sfq_get_limit(struct rtnl_qdisc *); -extern int rtnl_sfq_set_perturb(struct rtnl_qdisc *, int); +extern void rtnl_sfq_set_perturb(struct rtnl_qdisc *, int); extern int rtnl_sfq_get_perturb(struct rtnl_qdisc *); extern int rtnl_sfq_get_divisor(struct rtnl_qdisc *); diff --git a/include/netlink/route/sch/tbf.h b/include/netlink/route/sch/tbf.h index bb0e3b1..8a2144a 100644 --- a/include/netlink/route/sch/tbf.h +++ b/include/netlink/route/sch/tbf.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2010 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_TBF_H_ @@ -19,11 +19,11 @@ extern "C" { #endif -extern int rtnl_qdisc_tbf_set_limit(struct rtnl_qdisc *, int); +extern void rtnl_qdisc_tbf_set_limit(struct rtnl_qdisc *, int); extern int rtnl_qdisc_tbf_set_limit_by_latency(struct rtnl_qdisc *, int); extern int rtnl_qdisc_tbf_get_limit(struct rtnl_qdisc *); -extern int rtnl_qdisc_tbf_set_rate(struct rtnl_qdisc *, int, int, int); +extern void rtnl_qdisc_tbf_set_rate(struct rtnl_qdisc *, int, int, int); extern int rtnl_qdisc_tbf_get_rate(struct rtnl_qdisc *); extern int rtnl_qdisc_tbf_get_rate_bucket(struct rtnl_qdisc *); extern int rtnl_qdisc_tbf_get_rate_cell(struct rtnl_qdisc *); diff --git a/include/netlink/route/tc-api.h b/include/netlink/route/tc-api.h new file mode 100644 index 0000000..8ed940a --- /dev/null +++ b/include/netlink/route/tc-api.h @@ -0,0 +1,141 @@ +/* + * netlink/route/tc-api.h Traffic Control API + * + * 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. + * + * Copyright (c) 2011 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef NETLINK_TC_API_H_ +#define NETLINK_TC_API_H_ + +#include <netlink/netlink.h> +#include <netlink/msg.h> +#include <netlink/route/tc.h> + +#ifdef __cplusplus +extern "C" { +#endif + +enum rtnl_tc_type { + RTNL_TC_TYPE_QDISC, + RTNL_TC_TYPE_CLASS, + RTNL_TC_TYPE_CLS, + __RTNL_TC_TYPE_MAX, +}; + +#define RTNL_TC_TYPE_MAX (__RTNL_TC_TYPE_MAX - 1) + +/** + * Traffic control object operations + * @ingroup tc + * + * This structure holds function pointers and settings implementing + * the features of each traffic control object implementation. + */ +struct rtnl_tc_ops +{ + /** + * Name of traffic control module + */ + char *to_kind; + + /** + * Type of traffic control object + */ + enum rtnl_tc_type to_type; + + + /** + * Size of private data + */ + size_t to_size; + + /** + * Dump callbacks + */ + void (*to_dump[NL_DUMP_MAX+1])(struct rtnl_tc *, void *, + struct nl_dump_params *); + /** + * Used to fill the contents of TCA_OPTIONS + */ + int (*to_msg_fill)(struct rtnl_tc *, void *, struct nl_msg *); + + /** + * Uesd to to fill tc related messages, unlike with to_msg_fill, + * the contents is not encapsulated with a TCA_OPTIONS nested + * attribute. + */ + int (*to_msg_fill_raw)(struct rtnl_tc *, void *, struct nl_msg *); + + /** + * TCA_OPTIONS message parser + */ + int (*to_msg_parser)(struct rtnl_tc *, void *); + + /** + * Called before a tc object is destroyed + */ + void (*to_free_data)(struct rtnl_tc *, void *); + + /** + * Called whenever a classifier object needs to be cloned + */ + int (*to_clone)(void *, void *); + + /** + * Internal, don't touch + */ + struct nl_list_head to_list; +}; + +struct rtnl_tc_type_ops +{ + enum rtnl_tc_type tt_type; + + char *tt_dump_prefix; + + /** + * Dump callbacks + */ + void (*tt_dump[NL_DUMP_MAX+1])(struct rtnl_tc *, + struct nl_dump_params *); +}; + +extern int rtnl_tc_msg_parse(struct nlmsghdr *, + struct rtnl_tc *); +extern int rtnl_tc_msg_build(struct rtnl_tc *, int, + int, struct nl_msg **); + +extern void rtnl_tc_free_data(struct nl_object *); +extern int rtnl_tc_clone(struct nl_object *, + struct nl_object *); +extern void rtnl_tc_dump_line(struct nl_object *, + struct nl_dump_params *); +extern void rtnl_tc_dump_details(struct nl_object *, + struct nl_dump_params *); +extern void rtnl_tc_dump_stats(struct nl_object *, + struct nl_dump_params *); +extern int rtnl_tc_compare(struct nl_object *, + struct nl_object *, + uint32_t, int); + +extern void * rtnl_tc_data(struct rtnl_tc *); + +extern struct rtnl_tc_ops * rtnl_tc_lookup_ops(enum rtnl_tc_type, + const char *); +extern struct rtnl_tc_ops * rtnl_tc_get_ops(struct rtnl_tc *); +extern int rtnl_tc_register(struct rtnl_tc_ops *); +extern void rtnl_tc_unregister(struct rtnl_tc_ops *); + +extern void rtnl_tc_type_register(struct rtnl_tc_type_ops *); +extern void rtnl_tc_type_unregister(struct rtnl_tc_type_ops *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink/route/tc.h b/include/netlink/route/tc.h index 4ba0e06..17021be 100644 --- a/include/netlink/route/tc.h +++ b/include/netlink/route/tc.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2010 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_TC_H_ @@ -23,12 +23,31 @@ extern "C" { #endif +/** + * Traffic control object + * @ingroup tc + */ struct rtnl_tc; /** + * Macro to cast qdisc/class/classifier to tc object * @ingroup tc + * + * @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 */ -enum rtnl_tc_stats_id { +enum rtnl_tc_stat { RTNL_TC_PACKETS, /**< Number of packets seen */ RTNL_TC_BYTES, /**< Total bytes seen */ RTNL_TC_RATE_BPS, /**< Current bits/s (rate estimator) */ @@ -58,8 +77,9 @@ 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 *); +extern int rtnl_tc_set_kind(struct rtnl_tc *, const char *); extern char * rtnl_tc_get_kind(struct rtnl_tc *); -extern uint64_t rtnl_tc_get_stat(struct rtnl_tc *, int ); +extern uint64_t rtnl_tc_get_stat(struct rtnl_tc *, enum rtnl_tc_stat); extern int rtnl_tc_calc_txtime(int, int); extern int rtnl_tc_calc_bufsize(int, int); |