1 /* 2 * netlink-private/route/tc-api.h Traffic Control API 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation version 2.1 7 * of the License. 8 * 9 * Copyright (c) 2011-2013 Thomas Graf <tgraf (at) suug.ch> 10 */ 11 12 #ifndef NETLINK_TC_API_H_ 13 #define NETLINK_TC_API_H_ 14 15 #include <netlink/netlink.h> 16 #include <netlink/msg.h> 17 #include <netlink/route/tc.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * Traffic control object operations 25 * @ingroup tc 26 * 27 * This structure holds function pointers and settings implementing 28 * the features of each traffic control object implementation. 29 */ 30 struct rtnl_tc_ops 31 { 32 /** 33 * Name of traffic control module 34 */ 35 char *to_kind; 36 37 /** 38 * Type of traffic control object 39 */ 40 enum rtnl_tc_type to_type; 41 42 43 /** 44 * Size of private data 45 */ 46 size_t to_size; 47 48 /** 49 * Dump callbacks 50 */ 51 void (*to_dump[NL_DUMP_MAX+1])(struct rtnl_tc *, void *, 52 struct nl_dump_params *); 53 /** 54 * Used to fill the contents of TCA_OPTIONS 55 */ 56 int (*to_msg_fill)(struct rtnl_tc *, void *, struct nl_msg *); 57 58 /** 59 * Uesd to to fill tc related messages, unlike with to_msg_fill, 60 * the contents is not encapsulated with a TCA_OPTIONS nested 61 * attribute. 62 */ 63 int (*to_msg_fill_raw)(struct rtnl_tc *, void *, struct nl_msg *); 64 65 /** 66 * TCA_OPTIONS message parser 67 */ 68 int (*to_msg_parser)(struct rtnl_tc *, void *); 69 70 /** 71 * Called before a tc object is destroyed 72 */ 73 void (*to_free_data)(struct rtnl_tc *, void *); 74 75 /** 76 * Called whenever a classifier object needs to be cloned 77 */ 78 int (*to_clone)(void *, void *); 79 80 /** 81 * Internal, don't touch 82 */ 83 struct nl_list_head to_list; 84 }; 85 86 struct rtnl_tc_type_ops 87 { 88 enum rtnl_tc_type tt_type; 89 90 char *tt_dump_prefix; 91 92 /** 93 * Dump callbacks 94 */ 95 void (*tt_dump[NL_DUMP_MAX+1])(struct rtnl_tc *, 96 struct nl_dump_params *); 97 }; 98 99 extern int rtnl_tc_msg_parse(struct nlmsghdr *, 100 struct rtnl_tc *); 101 extern int rtnl_tc_msg_build(struct rtnl_tc *, int, 102 int, struct nl_msg **); 103 104 extern void rtnl_tc_free_data(struct nl_object *); 105 extern int rtnl_tc_clone(struct nl_object *, 106 struct nl_object *); 107 extern void rtnl_tc_dump_line(struct nl_object *, 108 struct nl_dump_params *); 109 extern void rtnl_tc_dump_details(struct nl_object *, 110 struct nl_dump_params *); 111 extern void rtnl_tc_dump_stats(struct nl_object *, 112 struct nl_dump_params *); 113 extern int rtnl_tc_compare(struct nl_object *, 114 struct nl_object *, 115 uint32_t, int); 116 117 extern void * rtnl_tc_data(struct rtnl_tc *); 118 extern void * rtnl_tc_data_check(struct rtnl_tc *, 119 struct rtnl_tc_ops *); 120 121 extern struct rtnl_tc_ops * rtnl_tc_lookup_ops(enum rtnl_tc_type, 122 const char *); 123 extern struct rtnl_tc_ops * rtnl_tc_get_ops(struct rtnl_tc *); 124 extern int rtnl_tc_register(struct rtnl_tc_ops *); 125 extern void rtnl_tc_unregister(struct rtnl_tc_ops *); 126 127 extern void rtnl_tc_type_register(struct rtnl_tc_type_ops *); 128 extern void rtnl_tc_type_unregister(struct rtnl_tc_type_ops *); 129 130 #ifdef __cplusplus 131 } 132 #endif 133 134 #endif 135