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