libnl
3.2.3
|
00001 /* 00002 * netlink/route/tc-api.h Traffic Control API 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) 2011 Thomas Graf <tgraf@suug.ch> 00010 */ 00011 00012 #ifndef NETLINK_TC_API_H_ 00013 #define NETLINK_TC_API_H_ 00014 00015 #include <netlink/netlink.h> 00016 #include <netlink/msg.h> 00017 #include <netlink/route/tc.h> 00018 00019 #ifdef __cplusplus 00020 extern "C" { 00021 #endif 00022 00023 enum rtnl_tc_type { 00024 RTNL_TC_TYPE_QDISC, 00025 RTNL_TC_TYPE_CLASS, 00026 RTNL_TC_TYPE_CLS, 00027 __RTNL_TC_TYPE_MAX, 00028 }; 00029 00030 #define RTNL_TC_TYPE_MAX (__RTNL_TC_TYPE_MAX - 1) 00031 00032 /** 00033 * Traffic control object operations 00034 * @ingroup tc 00035 * 00036 * This structure holds function pointers and settings implementing 00037 * the features of each traffic control object implementation. 00038 */ 00039 struct rtnl_tc_ops 00040 { 00041 /** 00042 * Name of traffic control module 00043 */ 00044 char *to_kind; 00045 00046 /** 00047 * Type of traffic control object 00048 */ 00049 enum rtnl_tc_type to_type; 00050 00051 00052 /** 00053 * Size of private data 00054 */ 00055 size_t to_size; 00056 00057 /** 00058 * Dump callbacks 00059 */ 00060 void (*to_dump[NL_DUMP_MAX+1])(struct rtnl_tc *, void *, 00061 struct nl_dump_params *); 00062 /** 00063 * Used to fill the contents of TCA_OPTIONS 00064 */ 00065 int (*to_msg_fill)(struct rtnl_tc *, void *, struct nl_msg *); 00066 00067 /** 00068 * Uesd to to fill tc related messages, unlike with to_msg_fill, 00069 * the contents is not encapsulated with a TCA_OPTIONS nested 00070 * attribute. 00071 */ 00072 int (*to_msg_fill_raw)(struct rtnl_tc *, void *, struct nl_msg *); 00073 00074 /** 00075 * TCA_OPTIONS message parser 00076 */ 00077 int (*to_msg_parser)(struct rtnl_tc *, void *); 00078 00079 /** 00080 * Called before a tc object is destroyed 00081 */ 00082 void (*to_free_data)(struct rtnl_tc *, void *); 00083 00084 /** 00085 * Called whenever a classifier object needs to be cloned 00086 */ 00087 int (*to_clone)(void *, void *); 00088 00089 /** 00090 * Internal, don't touch 00091 */ 00092 struct nl_list_head to_list; 00093 }; 00094 00095 struct rtnl_tc_type_ops 00096 { 00097 enum rtnl_tc_type tt_type; 00098 00099 char *tt_dump_prefix; 00100 00101 /** 00102 * Dump callbacks 00103 */ 00104 void (*tt_dump[NL_DUMP_MAX+1])(struct rtnl_tc *, 00105 struct nl_dump_params *); 00106 }; 00107 00108 extern int rtnl_tc_msg_parse(struct nlmsghdr *, 00109 struct rtnl_tc *); 00110 extern int rtnl_tc_msg_build(struct rtnl_tc *, int, 00111 int, struct nl_msg **); 00112 00113 extern void rtnl_tc_free_data(struct nl_object *); 00114 extern int rtnl_tc_clone(struct nl_object *, 00115 struct nl_object *); 00116 extern void rtnl_tc_dump_line(struct nl_object *, 00117 struct nl_dump_params *); 00118 extern void rtnl_tc_dump_details(struct nl_object *, 00119 struct nl_dump_params *); 00120 extern void rtnl_tc_dump_stats(struct nl_object *, 00121 struct nl_dump_params *); 00122 extern int rtnl_tc_compare(struct nl_object *, 00123 struct nl_object *, 00124 uint32_t, int); 00125 00126 extern void * rtnl_tc_data(struct rtnl_tc *); 00127 extern void * rtnl_tc_data_check(struct rtnl_tc *, 00128 struct rtnl_tc_ops *); 00129 00130 extern struct rtnl_tc_ops * rtnl_tc_lookup_ops(enum rtnl_tc_type, 00131 const char *); 00132 extern struct rtnl_tc_ops * rtnl_tc_get_ops(struct rtnl_tc *); 00133 extern int rtnl_tc_register(struct rtnl_tc_ops *); 00134 extern void rtnl_tc_unregister(struct rtnl_tc_ops *); 00135 00136 extern void rtnl_tc_type_register(struct rtnl_tc_type_ops *); 00137 extern void rtnl_tc_type_unregister(struct rtnl_tc_type_ops *); 00138 00139 #ifdef __cplusplus 00140 } 00141 #endif 00142 00143 #endif