From 9680f910f46b78d700ae66a16c08d8927dfc2199 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Thu, 24 Jan 2013 13:51:24 +0100 Subject: Move private header files to This clarifies the seperation between public and private header files. Signed-off-by: Thomas Graf --- include/Makefile.am | 17 +- include/netlink-generic.h | 20 - include/netlink-local.h | 257 --------- include/netlink-private/cache-api.h | 285 ++++++++++ include/netlink-private/genl.h | 20 + include/netlink-private/netlink.h | 257 +++++++++ include/netlink-private/object-api.h | 376 +++++++++++++ include/netlink-private/route/link/api.h | 153 ++++++ include/netlink-private/route/tc-api.h | 134 +++++ include/netlink-private/tc.h | 55 ++ include/netlink-private/types.h | 910 +++++++++++++++++++++++++++++++ include/netlink-tc.h | 55 -- include/netlink-types.h | 910 ------------------------------- include/netlink/cache-api.h | 285 ---------- include/netlink/object-api.h | 375 ------------- include/netlink/route/link/api.h | 153 ------ include/netlink/route/link/info-api.h | 20 - include/netlink/route/tc-api.h | 136 ----- include/netlink/route/tc.h | 2 + lib/addr.c | 2 +- lib/attr.c | 2 +- lib/cache.c | 2 +- lib/cache_mngr.c | 2 +- lib/cache_mngt.c | 2 +- lib/data.c | 2 +- lib/error.c | 2 +- lib/fib_lookup/lookup.c | 2 +- lib/fib_lookup/request.c | 2 +- lib/genl/ctrl.c | 2 +- lib/genl/family.c | 2 +- lib/genl/genl.c | 2 +- lib/genl/mngt.c | 2 +- lib/handlers.c | 2 +- lib/hashtable.c | 2 +- lib/msg.c | 2 +- lib/netfilter/ct.c | 2 +- lib/netfilter/ct_obj.c | 2 +- lib/netfilter/exp.c | 2 +- lib/netfilter/exp_obj.c | 2 +- lib/netfilter/log.c | 2 +- lib/netfilter/log_msg.c | 2 +- lib/netfilter/log_msg_obj.c | 2 +- lib/netfilter/log_obj.c | 2 +- lib/netfilter/netfilter.c | 2 +- lib/netfilter/nfnl.c | 2 +- lib/netfilter/queue.c | 2 +- lib/netfilter/queue_msg.c | 2 +- lib/netfilter/queue_msg_obj.c | 2 +- lib/netfilter/queue_obj.c | 2 +- lib/nl.c | 2 +- lib/object.c | 2 +- lib/route/addr.c | 2 +- lib/route/class.c | 8 +- lib/route/classid.c | 6 +- lib/route/cls.c | 8 +- lib/route/cls/basic.c | 8 +- lib/route/cls/cgroup.c | 8 +- lib/route/cls/ematch.c | 6 +- lib/route/cls/ematch/cmp.c | 6 +- lib/route/cls/ematch/container.c | 6 +- lib/route/cls/ematch/meta.c | 6 +- lib/route/cls/ematch/nbyte.c | 6 +- lib/route/cls/ematch/text.c | 6 +- lib/route/cls/ematch_grammar.l | 6 +- lib/route/cls/ematch_syntax.y | 6 +- lib/route/cls/fw.c | 8 +- lib/route/cls/police.c | 8 +- lib/route/cls/u32.c | 8 +- lib/route/link.c | 4 +- lib/route/link/api.c | 4 +- lib/route/link/bonding.c | 4 +- lib/route/link/bridge.c | 4 +- lib/route/link/can.c | 4 +- lib/route/link/dummy.c | 4 +- lib/route/link/inet.c | 4 +- lib/route/link/inet6.c | 4 +- lib/route/link/vlan.c | 4 +- lib/route/neigh.c | 2 +- lib/route/neightbl.c | 2 +- lib/route/nexthop.c | 2 +- lib/route/pktloc.c | 6 +- lib/route/pktloc_grammar.l | 4 +- lib/route/pktloc_syntax.y | 4 +- lib/route/qdisc.c | 6 +- lib/route/qdisc/blackhole.c | 4 +- lib/route/qdisc/cbq.c | 6 +- lib/route/qdisc/dsmark.c | 6 +- lib/route/qdisc/fifo.c | 6 +- lib/route/qdisc/htb.c | 6 +- lib/route/qdisc/netem.c | 6 +- lib/route/qdisc/plug.c | 6 +- lib/route/qdisc/prio.c | 6 +- lib/route/qdisc/red.c | 6 +- lib/route/qdisc/sfq.c | 6 +- lib/route/qdisc/tbf.c | 6 +- lib/route/route.c | 2 +- lib/route/route_obj.c | 2 +- lib/route/route_utils.c | 2 +- lib/route/rtnl.c | 2 +- lib/route/rule.c | 2 +- lib/route/tc.c | 6 +- lib/socket.c | 2 +- lib/utils.c | 2 +- src/lib/tc.c | 2 +- src/nl-list-caches.c | 2 +- 105 files changed, 2363 insertions(+), 2383 deletions(-) delete mode 100644 include/netlink-generic.h delete mode 100644 include/netlink-local.h create mode 100644 include/netlink-private/cache-api.h create mode 100644 include/netlink-private/genl.h create mode 100644 include/netlink-private/netlink.h create mode 100644 include/netlink-private/object-api.h create mode 100644 include/netlink-private/route/link/api.h create mode 100644 include/netlink-private/route/tc-api.h create mode 100644 include/netlink-private/tc.h create mode 100644 include/netlink-private/types.h delete mode 100644 include/netlink-tc.h delete mode 100644 include/netlink-types.h delete mode 100644 include/netlink/cache-api.h delete mode 100644 include/netlink/object-api.h delete mode 100644 include/netlink/route/link/api.h delete mode 100644 include/netlink/route/link/info-api.h delete mode 100644 include/netlink/route/tc-api.h diff --git a/include/Makefile.am b/include/Makefile.am index 50d1e4e..50f96b7 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -116,12 +116,11 @@ noinst_HEADERS = \ linux/rtnetlink.h \ linux/snmp.h \ linux/tc_ematch/tc_em_meta.h \ - netlink-generic.h \ - netlink-local.h \ - netlink-tc.h \ - netlink-types.h \ - netlink/cache-api.h \ - netlink/object-api.h \ - netlink/route/link/api.h \ - netlink/route/link/info-api.h \ - netlink/route/tc-api.h + netlink-private/genl.h \ + netlink-private/netlink.h \ + netlink-private/tc.h \ + netlink-private/types.h \ + netlink-private/cache-api.h \ + netlink-private/object-api.h \ + netlink-private/route/link/api.h \ + netlink-private/route/tc-api.h diff --git a/include/netlink-generic.h b/include/netlink-generic.h deleted file mode 100644 index 10aa2f0..0000000 --- a/include/netlink-generic.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * netlink-generic.h Local Generic Netlink Interface - * - * 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 - */ - -#ifndef NETLINK_GENL_PRIV_H_ -#define NETLINK_GENL_PRIV_H_ - -#include -#include - -#define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen)) - -#endif diff --git a/include/netlink-local.h b/include/netlink-local.h deleted file mode 100644 index c0915f8..0000000 --- a/include/netlink-local.h +++ /dev/null @@ -1,257 +0,0 @@ -/* - * netlink-local.h Local Netlink Interface - * - * 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-2011 Thomas Graf - */ - -#ifndef NETLINK_LOCAL_H_ -#define NETLINK_LOCAL_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#ifndef SOL_NETLINK -#define SOL_NETLINK 270 -#endif - -#include - -/* local header copies */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef DISABLE_PTHREADS -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -struct trans_tbl { - int i; - const char *a; -}; - -#define __ADD(id, name) { .i = id, .a = #name }, - -struct trans_list { - int i; - char *a; - struct nl_list_head list; -}; - -#define NL_DEBUG 1 - -#define NL_DBG(LVL,FMT,ARG...) \ - do { \ - if (LVL <= nl_debug) \ - fprintf(stderr, "DBG<" #LVL ">: " FMT, ##ARG); \ - } while (0) - -#define BUG() \ - do { \ - NL_DBG(1, "BUG: %s:%d\n", \ - __FILE__, __LINE__); \ - assert(0); \ - } while (0) - -#define APPBUG(msg) \ - do { \ - NL_DBG(1, "APPLICATION BUG: %s:%d:%s: %s\n", \ - __FILE__, __LINE__, __PRETTY_FUNCTION__, msg); \ - assert(0); \ - } while(0) - -extern int __nl_read_num_str_file(const char *path, - int (*cb)(long, const char *)); - -extern int __trans_list_add(int, const char *, struct nl_list_head *); -extern void __trans_list_clear(struct nl_list_head *); - -extern char *__type2str(int, char *, size_t, const struct trans_tbl *, size_t); -extern int __str2type(const char *, const struct trans_tbl *, size_t); - -extern char *__list_type2str(int, char *, size_t, struct nl_list_head *); -extern int __list_str2type(const char *, struct nl_list_head *); - -extern char *__flags2str(int, char *, size_t, const struct trans_tbl *, size_t); -extern int __str2flags(const char *, const struct trans_tbl *, size_t); - -extern void dump_from_ops(struct nl_object *, struct nl_dump_params *); - -static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg) -{ - return cb->cb_set[type](msg, cb->cb_args[type]); -} - -#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) - -/* This is also defined in stddef.h */ -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - -#define __init __attribute__ ((constructor)) -#define __exit __attribute__ ((destructor)) -#undef __deprecated -#define __deprecated __attribute__ ((deprecated)) - -#define min(x,y) ({ \ - typeof(x) _x = (x); \ - typeof(y) _y = (y); \ - (void) (&_x == &_y); \ - _x < _y ? _x : _y; }) - -#define max(x,y) ({ \ - typeof(x) _x = (x); \ - typeof(y) _y = (y); \ - (void) (&_x == &_y); \ - _x > _y ? _x : _y; }) - -#define min_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) -#define max_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) - -extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *, - struct nlmsghdr *, struct nl_parser_param *); - - -static inline void rtnl_copy_ratespec(struct rtnl_ratespec *dst, - struct tc_ratespec *src) -{ - dst->rs_cell_log = src->cell_log; - dst->rs_overhead = src->overhead; - dst->rs_cell_align = src->cell_align; - dst->rs_mpu = src->mpu; - dst->rs_rate = src->rate; -} - -static inline void rtnl_rcopy_ratespec(struct tc_ratespec *dst, - struct rtnl_ratespec *src) -{ - dst->cell_log = src->rs_cell_log; - dst->overhead = src->rs_overhead; - dst->cell_align = src->rs_cell_align; - dst->mpu = src->rs_mpu; - dst->rate = src->rs_rate; -} - -static inline char *nl_cache_name(struct nl_cache *cache) -{ - return cache->c_ops ? cache->c_ops->co_name : "unknown"; -} - -#define GENL_FAMILY(id, name) \ - { \ - { id, NL_ACT_UNSPEC, name }, \ - END_OF_MSGTYPES_LIST, \ - } - -static inline int wait_for_ack(struct nl_sock *sk) -{ - if (sk->s_flags & NL_NO_AUTO_ACK) - return 0; - else - return nl_wait_for_ack(sk); -} - -static inline int build_sysconf_path(char **strp, const char *filename) -{ - char *sysconfdir; - - sysconfdir = getenv("NLSYSCONFDIR"); - - if (!sysconfdir) - sysconfdir = SYSCONFDIR; - - return asprintf(strp, "%s/%s", sysconfdir, filename); -} - -#ifndef DISABLE_PTHREADS -#define NL_LOCK(NAME) pthread_mutex_t (NAME) = PTHREAD_MUTEX_INITIALIZER -#define NL_RW_LOCK(NAME) pthread_rwlock_t (NAME) = PTHREAD_RWLOCK_INITIALIZER - -static inline void nl_lock(pthread_mutex_t *lock) -{ - pthread_mutex_lock(lock); -} - -static inline void nl_unlock(pthread_mutex_t *lock) -{ - pthread_mutex_unlock(lock); -} - -static inline void nl_read_lock(pthread_rwlock_t *lock) -{ - pthread_rwlock_rdlock(lock); -} - -static inline void nl_read_unlock(pthread_rwlock_t *lock) -{ - pthread_rwlock_unlock(lock); -} - -static inline void nl_write_lock(pthread_rwlock_t *lock) -{ - pthread_rwlock_wrlock(lock); -} - -static inline void nl_write_unlock(pthread_rwlock_t *lock) -{ - pthread_rwlock_unlock(lock); -} - -#else -#define NL_LOCK(NAME) int __unused_lock_ ##NAME __attribute__((unused)) -#define NL_RW_LOCK(NAME) int __unused_lock_ ##NAME __attribute__((unused)) - -#define nl_lock(LOCK) do { } while(0) -#define nl_unlock(LOCK) do { } while(0) -#define nl_read_lock(LOCK) do { } while(0) -#define nl_read_unlock(LOCK) do { } while(0) -#define nl_write_lock(LOCK) do { } while(0) -#define nl_write_unlock(LOCK) do { } while(0) -#endif - -#endif diff --git a/include/netlink-private/cache-api.h b/include/netlink-private/cache-api.h new file mode 100644 index 0000000..5d9b0ad --- /dev/null +++ b/include/netlink-private/cache-api.h @@ -0,0 +1,285 @@ +/* + * netlink-private/cache-api.h Caching 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-2013 Thomas Graf + */ + +#ifndef NETLINK_CACHE_API_H_ +#define NETLINK_CACHE_API_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup cache + * @defgroup cache_api Cache Implementation + * @brief + * + * @par 1) Cache Definition + * @code + * struct nl_cache_ops my_cache_ops = { + * .co_name = "route/link", + * .co_protocol = NETLINK_ROUTE, + * .co_hdrsize = sizeof(struct ifinfomsg), + * .co_obj_ops = &my_obj_ops, + * }; + * @endcode + * + * @par 2) + * @code + * // The simplest way to fill a cache is by providing a request-update + * // function which must trigger a complete dump on the kernel-side of + * // whatever the cache covers. + * static int my_request_update(struct nl_cache *cache, + * struct nl_sock *socket) + * { + * // In this example, we request a full dump of the interface table + * return nl_rtgen_request(socket, RTM_GETLINK, AF_UNSPEC, NLM_F_DUMP); + * } + * + * // The resulting netlink messages sent back will be fed into a message + * // parser one at a time. The message parser has to extract all relevant + * // information from the message and create an object reflecting the + * // contents of the message and pass it on to the parser callback function + * // provide which will add the object to the cache. + * static int my_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, + * struct nlmsghdr *nlh, struct nl_parser_param *pp) + * { + * struct my_obj *obj; + * + * obj = my_obj_alloc(); + * obj->ce_msgtype = nlh->nlmsg_type; + * + * // Parse the netlink message and continue creating the object. + * + * err = pp->pp_cb((struct nl_object *) obj, pp); + * if (err < 0) + * goto errout; + * } + * + * struct nl_cache_ops my_cache_ops = { + * ... + * .co_request_update = my_request_update, + * .co_msg_parser = my_msg_parser, + * }; + * @endcode + * + * @par 3) Notification based Updates + * @code + * // Caches can be kept up-to-date based on notifications if the kernel + * // sends out notifications whenever an object is added/removed/changed. + * // + * // It is trivial to support this, first a list of groups needs to be + * // defined which are required to join in order to receive all necessary + * // notifications. The groups are separated by address family to support + * // the common situation where a separate group is used for each address + * // family. If there is only one group, simply specify AF_UNSPEC. + * static struct nl_af_group addr_groups[] = { + * { AF_INET, RTNLGRP_IPV4_IFADDR }, + * { AF_INET6, RTNLGRP_IPV6_IFADDR }, + * { END_OF_GROUP_LIST }, + * }; + * + * // In order for the caching system to know the meaning of each message + * // type it requires a table which maps each supported message type to + * // a cache action, e.g. RTM_NEWADDR means address has been added or + * // updated, RTM_DELADDR means address has been removed. + * static struct nl_cache_ops rtnl_addr_ops = { + * ... + * .co_msgtypes = { + * { RTM_NEWADDR, NL_ACT_NEW, "new" }, + * { RTM_DELADDR, NL_ACT_DEL, "del" }, + * { RTM_GETADDR, NL_ACT_GET, "get" }, + * END_OF_MSGTYPES_LIST, + * }, + * .co_groups = addr_groups, + * }; + * + * // It is now possible to keep the cache up-to-date using the cache manager. + * @endcode + * @{ + */ + +enum { + NL_ACT_UNSPEC, + NL_ACT_NEW, + NL_ACT_DEL, + NL_ACT_GET, + NL_ACT_SET, + NL_ACT_CHANGE, + __NL_ACT_MAX, +}; + +#define NL_ACT_MAX (__NL_ACT_MAX - 1) + +#define END_OF_MSGTYPES_LIST { -1, -1, NULL } + +/** + * Message type to cache action association + */ +struct nl_msgtype +{ + /** Netlink message type */ + int mt_id; + + /** Cache action to take */ + int mt_act; + + /** Name of operation for human-readable printing */ + char * mt_name; +}; + +/** + * Address family to netlink group association + */ +struct nl_af_group +{ + /** Address family */ + int ag_family; + + /** Netlink group identifier */ + int ag_group; +}; + +#define END_OF_GROUP_LIST AF_UNSPEC, 0 + +/** + * Parser parameters + * + * This structure is used to configure what kind of parser to use + * when parsing netlink messages to create objects. + */ +struct nl_parser_param +{ + /** Function to parse netlink messages into objects */ + int (*pp_cb)(struct nl_object *, struct nl_parser_param *); + + /** Arbitary argument to be passed to the parser */ + void * pp_arg; +}; + +/** + * Cache Operations + * + * This structure defines the characterstics of a cache type. It contains + * pointers to functions which implement the specifics of the object type + * the cache can hold. + */ +struct nl_cache_ops +{ + /** Name of cache type (must be unique) */ + char * co_name; + + /** Size of family specific netlink header */ + int co_hdrsize; + + /** Netlink protocol */ + int co_protocol; + + /** cache object hash size **/ + int co_hash_size; + + /** cache flags */ + unsigned int co_flags; + + /** Reference counter */ + unsigned int co_refcnt; + + /** Group definition */ + struct nl_af_group * co_groups; + + /** + * Called whenever an update of the cache is required. Must send + * a request message to the kernel requesting a complete dump. + */ + int (*co_request_update)(struct nl_cache *, struct nl_sock *); + + /** + * Called whenever a message was received that needs to be parsed. + * Must parse the message and call the paser callback function + * (nl_parser_param) provided via the argument. + */ + int (*co_msg_parser)(struct nl_cache_ops *, struct sockaddr_nl *, + struct nlmsghdr *, struct nl_parser_param *); + + /** + * The function registered under this callback is called after a + * netlink notification associated with this cache type has been + * parsed into an object and is being considered for inclusio into + * the specified cache. + * + * The purpose of this function is to filter out notifications + * which should be ignored when updating caches. + * + * The function must return NL_SKIP to prevent the object from + * being included, or NL_OK to include it. + * + * @code + * int my_filter(struct nl_cache *cache, struct nl_object *obj) + * { + * if (reason_to_not_include_obj(obj)) + * return NL_SKIP; + * + * return NL_OK; + * } + * @endcode + */ + int (*co_event_filter)(struct nl_cache *, struct nl_object *obj); + + /** + * The function registered under this callback is called when an + * object formed from a notification event needs to be included in + * a cache. + * + * For each modified object, the change callback \c change_cb must + * be called with the \c data argument provided. + * + * If no function is registered, the function nl_cache_include() + * will be used for this purpose. + * + * @see nl_cache_include() + */ + int (*co_include_event)(struct nl_cache *cache, struct nl_object *obj, + change_func_t change_cb, void *data); + + void (*reserved_1)(void); + void (*reserved_2)(void); + void (*reserved_3)(void); + void (*reserved_4)(void); + void (*reserved_5)(void); + void (*reserved_6)(void); + void (*reserved_7)(void); + void (*reserved_8)(void); + + /** Object operations */ + struct nl_object_ops * co_obj_ops; + + /** Internal, do not touch! */ + struct nl_cache_ops *co_next; + + struct nl_cache *co_major_cache; + struct genl_ops * co_genl; + + /* Message type definition */ + struct nl_msgtype co_msgtypes[]; +}; + +extern void nl_cache_ops_get(struct nl_cache_ops *); +extern void nl_cache_ops_put(struct nl_cache_ops *); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink-private/genl.h b/include/netlink-private/genl.h new file mode 100644 index 0000000..0aca6d7 --- /dev/null +++ b/include/netlink-private/genl.h @@ -0,0 +1,20 @@ +/* + * netlink-private/genl.h Local Generic Netlink Interface + * + * 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-2013 Thomas Graf + */ + +#ifndef NETLINK_GENL_PRIV_H_ +#define NETLINK_GENL_PRIV_H_ + +#include +#include + +#define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen)) + +#endif diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h new file mode 100644 index 0000000..6ae6d17 --- /dev/null +++ b/include/netlink-private/netlink.h @@ -0,0 +1,257 @@ +/* + * netlink-private/netlink.h Local Netlink Interface + * + * 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-2013 Thomas Graf + */ + +#ifndef NETLINK_LOCAL_H_ +#define NETLINK_LOCAL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#ifndef SOL_NETLINK +#define SOL_NETLINK 270 +#endif + +#include + +/* local header copies */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef DISABLE_PTHREADS +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +struct trans_tbl { + int i; + const char *a; +}; + +#define __ADD(id, name) { .i = id, .a = #name }, + +struct trans_list { + int i; + char *a; + struct nl_list_head list; +}; + +#define NL_DEBUG 1 + +#define NL_DBG(LVL,FMT,ARG...) \ + do { \ + if (LVL <= nl_debug) \ + fprintf(stderr, "DBG<" #LVL ">: " FMT, ##ARG); \ + } while (0) + +#define BUG() \ + do { \ + NL_DBG(1, "BUG: %s:%d\n", \ + __FILE__, __LINE__); \ + assert(0); \ + } while (0) + +#define APPBUG(msg) \ + do { \ + NL_DBG(1, "APPLICATION BUG: %s:%d:%s: %s\n", \ + __FILE__, __LINE__, __PRETTY_FUNCTION__, msg); \ + assert(0); \ + } while(0) + +extern int __nl_read_num_str_file(const char *path, + int (*cb)(long, const char *)); + +extern int __trans_list_add(int, const char *, struct nl_list_head *); +extern void __trans_list_clear(struct nl_list_head *); + +extern char *__type2str(int, char *, size_t, const struct trans_tbl *, size_t); +extern int __str2type(const char *, const struct trans_tbl *, size_t); + +extern char *__list_type2str(int, char *, size_t, struct nl_list_head *); +extern int __list_str2type(const char *, struct nl_list_head *); + +extern char *__flags2str(int, char *, size_t, const struct trans_tbl *, size_t); +extern int __str2flags(const char *, const struct trans_tbl *, size_t); + +extern void dump_from_ops(struct nl_object *, struct nl_dump_params *); + +static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg) +{ + return cb->cb_set[type](msg, cb->cb_args[type]); +} + +#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) + +/* This is also defined in stddef.h */ +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#define __init __attribute__ ((constructor)) +#define __exit __attribute__ ((destructor)) +#undef __deprecated +#define __deprecated __attribute__ ((deprecated)) + +#define min(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x < _y ? _x : _y; }) + +#define max(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x > _y ? _x : _y; }) + +#define min_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) +#define max_t(type,x,y) \ + ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) + +extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *, + struct nlmsghdr *, struct nl_parser_param *); + + +static inline void rtnl_copy_ratespec(struct rtnl_ratespec *dst, + struct tc_ratespec *src) +{ + dst->rs_cell_log = src->cell_log; + dst->rs_overhead = src->overhead; + dst->rs_cell_align = src->cell_align; + dst->rs_mpu = src->mpu; + dst->rs_rate = src->rate; +} + +static inline void rtnl_rcopy_ratespec(struct tc_ratespec *dst, + struct rtnl_ratespec *src) +{ + dst->cell_log = src->rs_cell_log; + dst->overhead = src->rs_overhead; + dst->cell_align = src->rs_cell_align; + dst->mpu = src->rs_mpu; + dst->rate = src->rs_rate; +} + +static inline char *nl_cache_name(struct nl_cache *cache) +{ + return cache->c_ops ? cache->c_ops->co_name : "unknown"; +} + +#define GENL_FAMILY(id, name) \ + { \ + { id, NL_ACT_UNSPEC, name }, \ + END_OF_MSGTYPES_LIST, \ + } + +static inline int wait_for_ack(struct nl_sock *sk) +{ + if (sk->s_flags & NL_NO_AUTO_ACK) + return 0; + else + return nl_wait_for_ack(sk); +} + +static inline int build_sysconf_path(char **strp, const char *filename) +{ + char *sysconfdir; + + sysconfdir = getenv("NLSYSCONFDIR"); + + if (!sysconfdir) + sysconfdir = SYSCONFDIR; + + return asprintf(strp, "%s/%s", sysconfdir, filename); +} + +#ifndef DISABLE_PTHREADS +#define NL_LOCK(NAME) pthread_mutex_t (NAME) = PTHREAD_MUTEX_INITIALIZER +#define NL_RW_LOCK(NAME) pthread_rwlock_t (NAME) = PTHREAD_RWLOCK_INITIALIZER + +static inline void nl_lock(pthread_mutex_t *lock) +{ + pthread_mutex_lock(lock); +} + +static inline void nl_unlock(pthread_mutex_t *lock) +{ + pthread_mutex_unlock(lock); +} + +static inline void nl_read_lock(pthread_rwlock_t *lock) +{ + pthread_rwlock_rdlock(lock); +} + +static inline void nl_read_unlock(pthread_rwlock_t *lock) +{ + pthread_rwlock_unlock(lock); +} + +static inline void nl_write_lock(pthread_rwlock_t *lock) +{ + pthread_rwlock_wrlock(lock); +} + +static inline void nl_write_unlock(pthread_rwlock_t *lock) +{ + pthread_rwlock_unlock(lock); +} + +#else +#define NL_LOCK(NAME) int __unused_lock_ ##NAME __attribute__((unused)) +#define NL_RW_LOCK(NAME) int __unused_lock_ ##NAME __attribute__((unused)) + +#define nl_lock(LOCK) do { } while(0) +#define nl_unlock(LOCK) do { } while(0) +#define nl_read_lock(LOCK) do { } while(0) +#define nl_read_unlock(LOCK) do { } while(0) +#define nl_write_lock(LOCK) do { } while(0) +#define nl_write_unlock(LOCK) do { } while(0) +#endif + +#endif diff --git a/include/netlink-private/object-api.h b/include/netlink-private/object-api.h new file mode 100644 index 0000000..f4fd71e --- /dev/null +++ b/include/netlink-private/object-api.h @@ -0,0 +1,376 @@ +/* + * netlink-private/object-api.c Object 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-2013 Thomas Graf + */ + +#ifndef NETLINK_OBJECT_API_H_ +#define NETLINK_OBJECT_API_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup object + * @defgroup object_api Object API + * @brief + * + * @par 1) Object Definition + * @code + * // Define your object starting with the common object header + * struct my_obj { + * NLHDR_COMMON + * int my_data; + * }; + * + * // Fill out the object operations structure + * struct nl_object_ops my_ops = { + * .oo_name = "my_obj", + * .oo_size = sizeof(struct my_obj), + * }; + * + * // At this point the object can be allocated, you may want to provide a + * // separate _alloc() function to ease allocting objects of this kind. + * struct nl_object *obj = nl_object_alloc(&my_ops); + * + * // And release it again... + * nl_object_put(obj); + * @endcode + * + * @par 2) Allocating additional data + * @code + * // You may require to allocate additional data and store it inside + * // object, f.e. assuming there is a field `ptr'. + * struct my_obj { + * NLHDR_COMMON + * void * ptr; + * }; + * + * // And at some point you may assign allocated data to this field: + * my_obj->ptr = calloc(1, ...); + * + * // In order to not introduce any memory leaks you have to release + * // this data again when the last reference is given back. + * static void my_obj_free_data(struct nl_object *obj) + * { + * struct my_obj *my_obj = nl_object_priv(obj); + * + * free(my_obj->ptr); + * } + * + * // Also when the object is cloned, you must ensure for your pointer + * // stay valid even if one of the clones is freed by either making + * // a clone as well or increase the reference count. + * static int my_obj_clone(struct nl_object *src, struct nl_object *dst) + * { + * struct my_obj *my_src = nl_object_priv(src); + * struct my_obj *my_dst = nl_object_priv(dst); + * + * if (src->ptr) { + * dst->ptr = calloc(1, ...); + * memcpy(dst->ptr, src->ptr, ...); + * } + * } + * + * struct nl_object_ops my_ops = { + * ... + * .oo_free_data = my_obj_free_data, + * .oo_clone = my_obj_clone, + * }; + * @endcode + * + * @par 3) Object Dumping + * @code + * static int my_obj_dump_detailed(struct nl_object *obj, + * struct nl_dump_params *params) + * { + * struct my_obj *my_obj = nl_object_priv(obj); + * + * // It is absolutely essential to use nl_dump() when printing + * // any text to make sure the dumping parameters are respected. + * nl_dump(params, "Obj Integer: %d\n", my_obj->my_int); + * + * // Before we can dump the next line, make sure to prefix + * // this line correctly. + * nl_new_line(params); + * + * // You may also split a line into multiple nl_dump() calls. + * nl_dump(params, "String: %s ", my_obj->my_string); + * nl_dump(params, "String-2: %s\n", my_obj->another_string); + * } + * + * struct nl_object_ops my_ops = { + * ... + * .oo_dump[NL_DUMP_FULL] = my_obj_dump_detailed, + * }; + * @endcode + * + * @par 4) Object Attributes + * @code + * // The concept of object attributes is optional but can ease the typical + * // case of objects that have optional attributes, e.g. a route may have a + * // nexthop assigned but it is not required to. + * + * // The first step to define your object specific bitmask listing all + * // attributes + * #define MY_ATTR_FOO (1<<0) + * #define MY_ATTR_BAR (1<<1) + * + * // When assigning an optional attribute to the object, make sure + * // to mark its availability. + * my_obj->foo = 123123; + * my_obj->ce_mask |= MY_ATTR_FOO; + * + * // At any time you may use this mask to check for the availability + * // of the attribute, e.g. while dumping + * if (my_obj->ce_mask & MY_ATTR_FOO) + * nl_dump(params, "foo %d ", my_obj->foo); + * + * // One of the big advantages of this concept is that it allows for + * // standardized comparisons which make it trivial for caches to + * // identify unique objects by use of unified comparison functions. + * // In order for it to work, your object implementation must provide + * // a comparison function and define a list of attributes which + * // combined together make an object unique. + * + * static int my_obj_compare(struct nl_object *_a, struct nl_object *_b, + * uint32_t attrs, int flags) + * { + * struct my_obj *a = nl_object_priv(_a): + * struct my_obj *b = nl_object_priv(_b): + * int diff = 0; + * + * // We help ourselves in defining our own DIFF macro which will + * // call ATTR_DIFF() on both objects which will make sure to only + * // compare the attributes if required. + * #define MY_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, MY_ATTR_##ATTR, a, b, EXPR) + * + * // Call our own diff macro for each attribute to build a bitmask + * // representing the attributes which mismatch. + * diff |= MY_DIFF(FOO, a->foo != b->foo) + * diff |= MY_DIFF(BAR, strcmp(a->bar, b->bar)) + * + * return diff; + * } + * + * // In order to identify identical objects with differing attributes + * // you must specify the attributes required to uniquely identify + * // your object. Make sure to not include too many attributes, this + * // list is used when caches look for an old version of an object. + * struct nl_object_ops my_ops = { + * ... + * .oo_id_attrs = MY_ATTR_FOO, + * .oo_compare = my_obj_compare, + * }; + * @endcode + * @{ + */ + +/** + * Common Object Header + * + * This macro must be included as first member in every object + * definition to allow objects to be cached. + */ +#define NLHDR_COMMON \ + int ce_refcnt; \ + struct nl_object_ops * ce_ops; \ + struct nl_cache * ce_cache; \ + struct nl_list_head ce_list; \ + int ce_msgtype; \ + int ce_flags; \ + uint32_t ce_mask; + +struct nl_object +{ + NLHDR_COMMON +}; + + +/** + * Return true if attribute is available in both objects + * @arg A an object + * @arg B another object + * @arg ATTR attribute bit + * + * @return True if the attribute is available, otherwise false is returned. + */ +#define AVAILABLE(A, B, ATTR) (((A)->ce_mask & (B)->ce_mask) & (ATTR)) + +/** + * Return true if attribute is available in only one of both objects + * @arg A an object + * @arg B another object + * @arg ATTR attribute bit + * + * @return True if the attribute is available in only one of both objects, + * otherwise false is returned. + */ +#define AVAILABLE_MISMATCH(A, B, ATTR) (((A)->ce_mask ^ (B)->ce_mask) & (ATTR)) + +/** + * Return true if attributes mismatch + * @arg A an object + * @arg B another object + * @arg ATTR attribute bit + * @arg EXPR Comparison expression + * + * This function will check if the attribute in question is available + * in both objects, if not this will count as a mismatch. + * + * If available the function will execute the expression which must + * return true if the attributes mismatch. + * + * @return True if the attribute mismatch, or false if they match. + */ +#define ATTR_MISMATCH(A, B, ATTR, EXPR) (AVAILABLE_MISMATCH(A, B, ATTR) || \ + (AVAILABLE(A, B, ATTR) && (EXPR))) + +/** + * Return attribute bit if attribute does not match + * @arg LIST list of attributes to be compared + * @arg ATTR attribute bit + * @arg A an object + * @arg B another object + * @arg EXPR Comparison expression + * + * This function will check if the attribute in question is available + * in both objects, if not this will count as a mismatch. + * + * If available the function will execute the expression which must + * return true if the attributes mismatch. + * + * In case the attributes mismatch, the attribute is returned, otherwise + * 0 is returned. + * + * @code + * diff |= ATTR_DIFF(attrs, MY_ATTR_FOO, a, b, a->foo != b->foo); + * @endcode + */ +#define ATTR_DIFF(LIST, ATTR, A, B, EXPR) \ +({ int diff = 0; \ + if (((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR)) \ + diff = ATTR; \ + diff; }) + +/** + * Object Operations + */ +struct nl_object_ops +{ + /** + * Unique name of object type + * + * Must be in the form family/name, e.g. "route/addr" + */ + char * oo_name; + + /** Size of object including its header */ + size_t oo_size; + + /* List of attributes needed to uniquely identify the object */ + uint32_t oo_id_attrs; + + /** + * Constructor function + * + * Will be called when a new object of this type is allocated. + * Can be used to initialize members such as lists etc. + */ + void (*oo_constructor)(struct nl_object *); + + /** + * Destructor function + * + * Will be called when an object is freed. Must free all + * resources which may have been allocated as part of this + * object. + */ + void (*oo_free_data)(struct nl_object *); + + /** + * Cloning function + * + * Will be called when an object needs to be cloned. Please + * note that the generic object code will make an exact + * copy of the object first, therefore you only need to take + * care of members which require reference counting etc. + * + * May return a negative error code to abort cloning. + */ + int (*oo_clone)(struct nl_object *, struct nl_object *); + + /** + * Dumping functions + * + * Will be called when an object is dumped. The implementations + * have to use nl_dump(), nl_dump_line(), and nl_new_line() to + * dump objects. + * + * The functions must return the number of lines printed. + */ + void (*oo_dump[NL_DUMP_MAX+1])(struct nl_object *, + struct nl_dump_params *); + + /** + * Comparison function + * + * Will be called when two objects of the same type are + * compared. It takes the two objects in question, an object + * specific bitmask defining which attributes should be + * compared and flags to control the behaviour. + * + * The function must return a bitmask with the relevant bit + * set for each attribute that mismatches. + */ + int (*oo_compare)(struct nl_object *, struct nl_object *, + uint32_t, int); + + + /** + * update function + * + * Will be called when the object given by first argument + * needs to be updated with the contents of the second object + * + * The function must return 0 for success and error for failure + * to update. In case of failure its assumed that the original + * object is not touched + */ + int (*oo_update)(struct nl_object *, struct nl_object *); + + /** + * Hash Key generator function + * + * When called returns a hash key for the object being + * referenced. This key will be used by higher level hash functions + * to build association lists. Each object type gets to specify + * it's own key formulation + */ + void (*oo_keygen)(struct nl_object *, uint32_t *, uint32_t); + + char *(*oo_attrs2str)(int, char *, size_t); + + /** + * Get key attributes by family function + */ + uint32_t (*oo_id_attrs_get)(struct nl_object *); +}; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink-private/route/link/api.h b/include/netlink-private/route/link/api.h new file mode 100644 index 0000000..bb98ccc --- /dev/null +++ b/include/netlink-private/route/link/api.h @@ -0,0 +1,153 @@ +/* + * netlink-private/route/link/api.h Link Modules 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-2013 Thomas Graf + */ + +#ifndef NETLINK_LINK_API_H_ +#define NETLINK_LINK_API_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup link_api + * + * Available operations to modules implementing a link info type. + */ +struct rtnl_link_info_ops +{ + /** Name of link info type, must match name on kernel side */ + char * io_name; + + /** Reference count, DO NOT MODIFY */ + int io_refcnt; + + /** Called to assign an info type to a link. + * Has to allocate enough resources to hold attributes. Can + * use link->l_info to store a pointer. */ + int (*io_alloc)(struct rtnl_link *); + + /** Called to parse the link info attribute. + * Must parse the attribute and assign all values to the link. + */ + int (*io_parse)(struct rtnl_link *, + struct nlattr *, + struct nlattr *); + + /** Called when the link object is dumped. + * Must dump the info type specific attributes. */ + void (*io_dump[NL_DUMP_MAX+1])(struct rtnl_link *, + struct nl_dump_params *); + + /** Called when a link object is cloned. + * Must clone all info type specific attributes. */ + int (*io_clone)(struct rtnl_link *, struct rtnl_link *); + + /** Called when construction a link netlink message. + * Must append all info type specific attributes to the message. */ + int (*io_put_attrs)(struct nl_msg *, struct rtnl_link *); + + /** Called to release all resources previously allocated + * in either io_alloc() or io_parse(). */ + void (*io_free)(struct rtnl_link *); + + struct nl_list_head io_list; +}; + +extern struct rtnl_link_info_ops *rtnl_link_info_ops_lookup(const char *); +extern void rtnl_link_info_ops_put(struct rtnl_link_info_ops *); +extern int rtnl_link_register_info(struct rtnl_link_info_ops *); +extern int rtnl_link_unregister_info(struct rtnl_link_info_ops *); + + +/** + * @ingroup link_api + * + * Available operations to modules implementing a link address family. + */ +struct rtnl_link_af_ops +{ + /** The address family this operations set implements */ + const unsigned int ao_family; + + /** Number of users of this operations, DO NOT MODIFY. */ + int ao_refcnt; + + /** Validation policy for IFLA_PROTINFO attribute. This pointer + * can be set to a nla_policy structure describing the minimal + * requirements the attribute must meet. Failure of meeting these + * requirements will result in a parsing error. */ + const struct nla_policy *ao_protinfo_policy; + + /** Called after address family has been assigned to link. Must + * allocate data buffer to hold address family specific data and + * store it in link->l_af_data. */ + void * (*ao_alloc)(struct rtnl_link *); + + /** Called when the link is cloned, must allocate a clone of the + * address family specific buffer and return it. */ + void * (*ao_clone)(struct rtnl_link *, void *); + + /** Called when the link gets freed. Must free all allocated data */ + void (*ao_free)(struct rtnl_link *, void *); + + /** Called if a IFLA_PROTINFO attribute needs to be parsed. Typically + * stores the parsed data in the address family specific buffer. */ + int (*ao_parse_protinfo)(struct rtnl_link *, + struct nlattr *, void *); + + /** Called if a IFLA_AF_SPEC attribute needs to be parsed. Typically + * stores the parsed data in the address family specific buffer. */ + int (*ao_parse_af)(struct rtnl_link *, + struct nlattr *, void *); + + /** Called if a link message is sent to the kernel. Must append the + * link address family specific attributes to the message. */ + int (*ao_fill_af)(struct rtnl_link *, + struct nl_msg *msg, void *); + + /** Dump address family specific link attributes */ + void (*ao_dump[NL_DUMP_MAX+1])(struct rtnl_link *, + struct nl_dump_params *, + void *); + + /** Comparison function + * + * Will be called when two links are compared for their af data. It + * takes two link objects in question, an object specific bitmask + * defining which attributes should be compared and flags to control + * the behaviour + * + * The function must return a bitmask with the relevant bit set for + * each attribute that mismatches + */ + int (*ao_compare)(struct rtnl_link *, + struct rtnl_link *, int, uint32_t, int); +}; + +extern struct rtnl_link_af_ops *rtnl_link_af_ops_lookup(unsigned int); +extern void rtnl_link_af_ops_put(struct rtnl_link_af_ops *); +extern void * rtnl_link_af_alloc(struct rtnl_link *, + const struct rtnl_link_af_ops *); +extern void * rtnl_link_af_data(const struct rtnl_link *, + const struct rtnl_link_af_ops *); +extern int rtnl_link_af_register(struct rtnl_link_af_ops *); +extern int rtnl_link_af_unregister(struct rtnl_link_af_ops *); +extern int rtnl_link_af_data_compare(struct rtnl_link *a, + struct rtnl_link *b, + int family); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink-private/route/tc-api.h b/include/netlink-private/route/tc-api.h new file mode 100644 index 0000000..bf0c8a3 --- /dev/null +++ b/include/netlink-private/route/tc-api.h @@ -0,0 +1,134 @@ +/* + * netlink-private/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-2013 Thomas Graf + */ + +#ifndef NETLINK_TC_API_H_ +#define NETLINK_TC_API_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * 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 void * rtnl_tc_data_check(struct rtnl_tc *, + struct rtnl_tc_ops *); + +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-private/tc.h b/include/netlink-private/tc.h new file mode 100644 index 0000000..182adaa --- /dev/null +++ b/include/netlink-private/tc.h @@ -0,0 +1,55 @@ +/* + * netlink-private/tc.h Local Traffic Control Interface + * + * 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-2013 Thomas Graf + */ + +#ifndef NETLINK_TC_PRIV_H_ +#define NETLINK_TC_PRIV_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TCA_ATTR_HANDLE 0x0001 +#define TCA_ATTR_PARENT 0x0002 +#define TCA_ATTR_IFINDEX 0x0004 +#define TCA_ATTR_KIND 0x0008 +#define TCA_ATTR_FAMILY 0x0010 +#define TCA_ATTR_INFO 0x0020 +#define TCA_ATTR_OPTS 0x0040 +#define TCA_ATTR_STATS 0x0080 +#define TCA_ATTR_XSTATS 0x0100 +#define TCA_ATTR_LINK 0x0200 +#define TCA_ATTR_MTU 0x0400 +#define TCA_ATTR_MPU 0x0800 +#define TCA_ATTR_OVERHEAD 0x1000 +#define TCA_ATTR_LINKTYPE 0x2000 +#define TCA_ATTR_MAX TCA_ATTR_LINKTYPE + +extern int tca_parse(struct nlattr **, int, struct rtnl_tc *, + struct nla_policy *); + +#define RTNL_TC_RTABLE_SIZE 256 + +extern int rtnl_tc_build_rate_table(struct rtnl_tc *tc, struct rtnl_ratespec *, + uint32_t *); + + +static inline void *tca_xstats(struct rtnl_tc *tca) +{ + return tca->tc_xstats->d_data; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h new file mode 100644 index 0000000..60a3bce --- /dev/null +++ b/include/netlink-private/types.h @@ -0,0 +1,910 @@ +/* + * netlink-private/types.h Netlink Types (Private) + * + * 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-2013 Thomas Graf + */ + +#ifndef NETLINK_LOCAL_TYPES_H_ +#define NETLINK_LOCAL_TYPES_H_ + +#include +#include +#include +#include +#include +#include + +#define NL_SOCK_BUFSIZE_SET (1<<0) +#define NL_SOCK_PASSCRED (1<<1) +#define NL_OWN_PORT (1<<2) +#define NL_MSG_PEEK (1<<3) +#define NL_NO_AUTO_ACK (1<<4) + +#define NL_MSG_CRED_PRESENT 1 + +struct nl_cache_ops; +struct nl_sock; +struct nl_object; +struct nl_hash_table; + +struct nl_cb +{ + nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1]; + void * cb_args[NL_CB_TYPE_MAX+1]; + + nl_recvmsg_err_cb_t cb_err; + void * cb_err_arg; + + /** May be used to replace nl_recvmsgs with your own implementation + * in all internal calls to nl_recvmsgs. */ + int (*cb_recvmsgs_ow)(struct nl_sock *, + struct nl_cb *); + + /** Overwrite internal calls to nl_recv, must return the number of + * octets read and allocate a buffer for the received data. */ + int (*cb_recv_ow)(struct nl_sock *, + struct sockaddr_nl *, + unsigned char **, + struct ucred **); + + /** Overwrites internal calls to nl_send, must send the netlink + * message. */ + int (*cb_send_ow)(struct nl_sock *, + struct nl_msg *); + + int cb_refcnt; +}; + +struct nl_sock +{ + struct sockaddr_nl s_local; + struct sockaddr_nl s_peer; + int s_fd; + int s_proto; + unsigned int s_seq_next; + unsigned int s_seq_expect; + int s_flags; + struct nl_cb * s_cb; + size_t s_bufsize; +}; + +struct nl_cache +{ + struct nl_list_head c_items; + int c_nitems; + int c_iarg1; + int c_iarg2; + int c_refcnt; + unsigned int c_flags; + struct nl_hash_table * hashtable; + struct nl_cache_ops * c_ops; +}; + +struct nl_cache_assoc +{ + struct nl_cache * ca_cache; + change_func_t ca_change; + void * ca_change_data; +}; + +struct nl_cache_mngr +{ + int cm_protocol; + int cm_flags; + int cm_nassocs; + struct nl_sock * cm_sock; + struct nl_sock * cm_sync_sock; + struct nl_cache_assoc * cm_assocs; +}; + +struct nl_parser_param; + +#define LOOSE_COMPARISON 1 + +#define NL_OBJ_MARK 1 + +struct nl_data +{ + size_t d_size; + void * d_data; +}; + +struct nl_addr +{ + int a_family; + unsigned int a_maxsize; + unsigned int a_len; + int a_prefixlen; + int a_refcnt; + char a_addr[0]; +}; + +struct nl_msg +{ + int nm_protocol; + int nm_flags; + struct sockaddr_nl nm_src; + struct sockaddr_nl nm_dst; + struct ucred nm_creds; + struct nlmsghdr * nm_nlh; + size_t nm_size; + int nm_refcnt; +}; + +struct rtnl_link_map +{ + uint64_t lm_mem_start; + uint64_t lm_mem_end; + uint64_t lm_base_addr; + uint16_t lm_irq; + uint8_t lm_dma; + uint8_t lm_port; +}; + +#define IFQDISCSIZ 32 + +struct rtnl_link +{ + NLHDR_COMMON + + char l_name[IFNAMSIZ]; + uint32_t l_family; + uint32_t l_arptype; + uint32_t l_index; + uint32_t l_flags; + uint32_t l_change; + uint32_t l_mtu; + uint32_t l_link; + uint32_t l_txqlen; + uint32_t l_weight; + uint32_t l_master; + struct nl_addr * l_addr; + struct nl_addr * l_bcast; + char l_qdisc[IFQDISCSIZ]; + struct rtnl_link_map l_map; + uint64_t l_stats[RTNL_LINK_STATS_MAX+1]; + uint32_t l_flag_mask; + uint32_t l_num_vf; + uint8_t l_operstate; + uint8_t l_linkmode; + /* 2 byte hole */ + char * l_info_kind; + struct rtnl_link_info_ops * l_info_ops; + void * l_af_data[AF_MAX]; + void * l_info; + char * l_ifalias; + uint32_t l_promiscuity; + uint32_t l_num_tx_queues; + uint32_t l_num_rx_queues; + uint32_t l_group; + uint8_t l_carrier; +}; + +struct rtnl_ncacheinfo +{ + uint32_t nci_confirmed; /**< Time since neighbour validty was last confirmed */ + uint32_t nci_used; /**< Time since neighbour entry was last ued */ + uint32_t nci_updated; /**< Time since last update */ + uint32_t nci_refcnt; /**< Reference counter */ +}; + + +struct rtnl_neigh +{ + NLHDR_COMMON + uint32_t n_family; + uint32_t n_ifindex; + uint16_t n_state; + uint8_t n_flags; + uint8_t n_type; + struct nl_addr *n_lladdr; + struct nl_addr *n_dst; + uint32_t n_probes; + struct rtnl_ncacheinfo n_cacheinfo; + uint32_t n_state_mask; + uint32_t n_flag_mask; + uint32_t n_master; +}; + + +struct rtnl_addr_cacheinfo +{ + /* Preferred lifetime in seconds */ + uint32_t aci_prefered; + + /* Valid lifetime in seconds */ + uint32_t aci_valid; + + /* Timestamp of creation in 1/100s seince boottime */ + uint32_t aci_cstamp; + + /* Timestamp of last update in 1/100s since boottime */ + uint32_t aci_tstamp; +}; + +struct rtnl_addr +{ + NLHDR_COMMON + + uint8_t a_family; + uint8_t a_prefixlen; + uint8_t a_flags; + uint8_t a_scope; + uint32_t a_ifindex; + + struct nl_addr *a_peer; + struct nl_addr *a_local; + struct nl_addr *a_bcast; + struct nl_addr *a_anycast; + struct nl_addr *a_multicast; + + struct rtnl_addr_cacheinfo a_cacheinfo; + + char a_label[IFNAMSIZ]; + uint32_t a_flag_mask; + struct rtnl_link *a_link; +}; + +struct rtnl_nexthop +{ + uint8_t rtnh_flags; + uint8_t rtnh_flag_mask; + uint8_t rtnh_weight; + /* 1 byte spare */ + uint32_t rtnh_ifindex; + struct nl_addr * rtnh_gateway; + uint32_t ce_mask; /* HACK to support attr macros */ + struct nl_list_head rtnh_list; + uint32_t rtnh_realms; +}; + +struct rtnl_route +{ + NLHDR_COMMON + + uint8_t rt_family; + uint8_t rt_dst_len; + uint8_t rt_src_len; + uint8_t rt_tos; + uint8_t rt_protocol; + uint8_t rt_scope; + uint8_t rt_type; + uint8_t rt_nmetrics; + uint32_t rt_flags; + struct nl_addr * rt_dst; + struct nl_addr * rt_src; + uint32_t rt_table; + uint32_t rt_iif; + uint32_t rt_prio; + uint32_t rt_metrics[RTAX_MAX]; + uint32_t rt_metrics_mask; + uint32_t rt_nr_nh; + struct nl_addr * rt_pref_src; + struct nl_list_head rt_nexthops; + struct rtnl_rtcacheinfo rt_cacheinfo; + uint32_t rt_flag_mask; +}; + +struct rtnl_rule +{ + NLHDR_COMMON + uint8_t r_family; + uint8_t r_action; + uint8_t r_dsfield; /* ipv4 only */ + uint8_t r_unused; + uint32_t r_table; + uint32_t r_flags; + uint32_t r_prio; + uint32_t r_mark; + uint32_t r_mask; + uint32_t r_goto; + uint32_t r_flow; /* ipv4 only */ + struct nl_addr *r_src; + struct nl_addr *r_dst; + char r_iifname[IFNAMSIZ]; + char r_oifname[IFNAMSIZ]; +}; + +struct rtnl_neightbl_parms +{ + /** + * Interface index of the device this parameter set is assigned + * to or 0 for the default set. + */ + uint32_t ntp_ifindex; + + /** + * Number of references to this parameter set. + */ + uint32_t ntp_refcnt; + + /** + * Queue length for pending arp requests, i.e. the number of + * packets which are accepted from other layers while the + * neighbour address is still being resolved + */ + uint32_t ntp_queue_len; + + /** + * Number of requests to send to the user level ARP daemon. + * Specify 0 to disable. + */ + uint32_t ntp_app_probes; + + /** + * Maximum number of retries for unicast solicitation. + */ + uint32_t ntp_ucast_probes; + + /** + * Maximum number of retries for multicast solicitation. + */ + uint32_t ntp_mcast_probes; + + /** + * Base value in milliseconds to ompute reachable time, see RFC2461. + */ + uint64_t ntp_base_reachable_time; + + /** + * Actual reachable time (read-only) + */ + uint64_t ntp_reachable_time; /* secs */ + + /** + * The time in milliseconds between retransmitted Neighbor + * Solicitation messages. + */ + uint64_t ntp_retrans_time; + + /** + * Interval in milliseconds to check for stale neighbour + * entries. + */ + uint64_t ntp_gc_stale_time; /* secs */ + + /** + * Delay in milliseconds for the first time probe if + * the neighbour is reachable. + */ + uint64_t ntp_probe_delay; /* secs */ + + /** + * Maximum delay in milliseconds of an answer to a neighbour + * solicitation message. + */ + uint64_t ntp_anycast_delay; + + /** + * Minimum age in milliseconds before a neighbour entry + * may be replaced. + */ + uint64_t ntp_locktime; + + /** + * Delay in milliseconds before answering to an ARP request + * for which a proxy ARP entry exists. + */ + uint64_t ntp_proxy_delay; + + /** + * Queue length for the delayed proxy arp requests. + */ + uint32_t ntp_proxy_qlen; + + /** + * Mask of available parameter attributes + */ + uint32_t ntp_mask; +}; + +#define NTBLNAMSIZ 32 + +/** + * Neighbour table + * @ingroup neightbl + */ +struct rtnl_neightbl +{ + NLHDR_COMMON + + char nt_name[NTBLNAMSIZ]; + uint32_t nt_family; + uint32_t nt_gc_thresh1; + uint32_t nt_gc_thresh2; + uint32_t nt_gc_thresh3; + uint64_t nt_gc_interval; + struct ndt_config nt_config; + struct rtnl_neightbl_parms nt_parms; + struct ndt_stats nt_stats; +}; + +struct rtnl_ratespec +{ + uint8_t rs_cell_log; + uint16_t rs_overhead; + int16_t rs_cell_align; + uint16_t rs_mpu; + uint32_t rs_rate; +}; + +struct rtnl_tstats +{ + struct { + uint64_t bytes; + uint64_t packets; + } tcs_basic; + + struct { + uint32_t bps; + uint32_t pps; + } tcs_rate_est; + + struct { + uint32_t qlen; + uint32_t backlog; + uint32_t drops; + uint32_t requeues; + uint32_t overlimits; + } tcs_queue; +}; + +#define TCKINDSIZ 32 + +#define NL_TC_GENERIC(pre) \ + NLHDR_COMMON \ + uint32_t pre ##_family; \ + uint32_t pre ##_ifindex; \ + uint32_t pre ##_handle; \ + uint32_t pre ##_parent; \ + uint32_t pre ##_info; \ + uint32_t pre ##_mtu; \ + uint32_t pre ##_mpu; \ + uint32_t pre ##_overhead; \ + uint32_t pre ##_linktype; \ + char pre ##_kind[TCKINDSIZ]; \ + struct nl_data * pre ##_opts; \ + 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_tc_ops * pre ##_ops; \ + enum rtnl_tc_type pre ##_type + +struct rtnl_tc +{ + NL_TC_GENERIC(tc); +}; + +struct rtnl_qdisc +{ + NL_TC_GENERIC(q); +}; + +struct rtnl_class +{ + NL_TC_GENERIC(c); +}; + +struct rtnl_cls +{ + NL_TC_GENERIC(c); + uint16_t c_prio; + uint16_t c_protocol; +}; + +struct rtnl_u32 +{ + uint32_t cu_divisor; + uint32_t cu_hash; + uint32_t cu_classid; + uint32_t cu_link; + struct nl_data * cu_pcnt; + struct nl_data * cu_selector; + struct nl_data * cu_act; + struct nl_data * cu_police; + char cu_indev[IFNAMSIZ]; + int cu_mask; +}; + +struct rtnl_cgroup +{ + struct rtnl_ematch_tree *cg_ematch; + int cg_mask; +}; + +struct rtnl_fw +{ + uint32_t cf_classid; + struct nl_data * cf_act; + struct nl_data * cf_police; + char cf_indev[IFNAMSIZ]; + uint32_t cf_fwmask; + int cf_mask; +}; + +struct rtnl_ematch +{ + uint16_t e_id; + uint16_t e_kind; + uint16_t e_flags; + uint16_t e_index; + size_t e_datalen; + + struct nl_list_head e_childs; + struct nl_list_head e_list; + struct rtnl_ematch_ops *e_ops; + + void * e_data; +}; + +struct rtnl_ematch_tree +{ + uint16_t et_progid; + struct nl_list_head et_list; + +}; + +struct rtnl_dsmark_qdisc +{ + uint16_t qdm_indices; + uint16_t qdm_default_index; + uint32_t qdm_set_tc_index; + uint32_t qdm_mask; +}; + +struct rtnl_dsmark_class +{ + uint8_t cdm_bmask; + uint8_t cdm_value; + uint32_t cdm_mask; +}; + +struct rtnl_fifo +{ + uint32_t qf_limit; + uint32_t qf_mask; +}; + +struct rtnl_prio +{ + uint32_t qp_bands; + uint8_t qp_priomap[TC_PRIO_MAX+1]; + uint32_t qp_mask; +}; + +struct rtnl_tbf +{ + uint32_t qt_limit; + struct rtnl_ratespec qt_rate; + uint32_t qt_rate_bucket; + uint32_t qt_rate_txtime; + struct rtnl_ratespec qt_peakrate; + uint32_t qt_peakrate_bucket; + uint32_t qt_peakrate_txtime; + uint32_t qt_mask; +}; + +struct rtnl_sfq +{ + uint32_t qs_quantum; + uint32_t qs_perturb; + uint32_t qs_limit; + uint32_t qs_divisor; + uint32_t qs_flows; + uint32_t qs_mask; +}; + +struct rtnl_netem_corr +{ + uint32_t nmc_delay; + uint32_t nmc_loss; + uint32_t nmc_duplicate; +}; + +struct rtnl_netem_reo +{ + uint32_t nmro_probability; + uint32_t nmro_correlation; +}; + +struct rtnl_netem_crpt +{ + uint32_t nmcr_probability; + uint32_t nmcr_correlation; +}; + +struct rtnl_netem_dist +{ + int16_t * dist_data; + size_t dist_size; +}; + +struct rtnl_netem +{ + uint32_t qnm_latency; + uint32_t qnm_limit; + uint32_t qnm_loss; + uint32_t qnm_gap; + uint32_t qnm_duplicate; + uint32_t qnm_jitter; + uint32_t qnm_mask; + struct rtnl_netem_corr qnm_corr; + struct rtnl_netem_reo qnm_ro; + struct rtnl_netem_crpt qnm_crpt; + struct rtnl_netem_dist qnm_dist; +}; + +struct rtnl_htb_qdisc +{ + uint32_t qh_rate2quantum; + uint32_t qh_defcls; + uint32_t qh_mask; + uint32_t qh_direct_pkts; +}; + +struct rtnl_htb_class +{ + uint32_t ch_prio; + struct rtnl_ratespec ch_rate; + struct rtnl_ratespec ch_ceil; + uint32_t ch_rbuffer; + uint32_t ch_cbuffer; + uint32_t ch_quantum; + uint32_t ch_mask; + uint32_t ch_level; +}; + +struct rtnl_cbq +{ + struct tc_cbq_lssopt cbq_lss; + struct tc_ratespec cbq_rate; + struct tc_cbq_wrropt cbq_wrr; + struct tc_cbq_ovl cbq_ovl; + struct tc_cbq_fopt cbq_fopt; + struct tc_cbq_police cbq_police; +}; + +struct rtnl_red +{ + uint32_t qr_limit; + uint32_t qr_qth_min; + uint32_t qr_qth_max; + uint8_t qr_flags; + uint8_t qr_wlog; + uint8_t qr_plog; + uint8_t qr_scell_log; + uint32_t qr_mask; +}; + +struct rtnl_plug +{ + int action; + uint32_t limit; +}; + +struct flnl_request +{ + NLHDR_COMMON + + struct nl_addr * lr_addr; + uint32_t lr_fwmark; + uint8_t lr_tos; + uint8_t lr_scope; + uint8_t lr_table; +}; + + +struct flnl_result +{ + NLHDR_COMMON + + struct flnl_request * fr_req; + uint8_t fr_table_id; + uint8_t fr_prefixlen; + uint8_t fr_nh_sel; + uint8_t fr_type; + uint8_t fr_scope; + uint32_t fr_error; +}; + +#define GENL_OP_HAS_POLICY 1 +#define GENL_OP_HAS_DOIT 2 +#define GENL_OP_HAS_DUMPIT 4 + +struct genl_family_op +{ + uint32_t o_id; + uint32_t o_flags; + + struct nl_list_head o_list; +}; + +struct genl_family_grp { + struct genl_family *family; /* private */ + struct nl_list_head list; /* private */ + char name[GENL_NAMSIZ]; + u_int32_t id; +}; + +struct genl_family +{ + NLHDR_COMMON + + uint16_t gf_id; + char gf_name[GENL_NAMSIZ]; + uint32_t gf_version; + uint32_t gf_hdrsize; + uint32_t gf_maxattr; + + struct nl_list_head gf_ops; + struct nl_list_head gf_mc_grps; +}; + +union nfnl_ct_proto +{ + struct { + uint16_t src; + uint16_t dst; + } port; + struct { + uint16_t id; + uint8_t type; + uint8_t code; + } icmp; +}; + +struct nfnl_ct_dir { + struct nl_addr * src; + struct nl_addr * dst; + union nfnl_ct_proto proto; + uint64_t packets; + uint64_t bytes; +}; + +union nfnl_ct_protoinfo { + struct { + uint8_t state; + } tcp; +}; + +struct nfnl_ct { + NLHDR_COMMON + + uint8_t ct_family; + uint8_t ct_proto; + union nfnl_ct_protoinfo ct_protoinfo; + + uint32_t ct_status; + uint32_t ct_status_mask; + uint32_t ct_timeout; + uint32_t ct_mark; + uint32_t ct_use; + uint32_t ct_id; + + struct nfnl_ct_dir ct_orig; + struct nfnl_ct_dir ct_repl; +}; + +union nfnl_exp_protodata { + struct { + uint16_t src; + uint16_t dst; + } port; + struct { + uint16_t id; + uint8_t type; + uint8_t code; + } icmp; +}; + +// Allow for different master/expect l4 protocols +struct nfnl_exp_proto +{ + uint8_t l4protonum; + union nfnl_exp_protodata l4protodata; +}; + +struct nfnl_exp_dir { + struct nl_addr * src; + struct nl_addr * dst; + struct nfnl_exp_proto proto; +}; + +struct nfnl_exp { + NLHDR_COMMON + + uint8_t exp_family; + uint32_t exp_timeout; + uint32_t exp_id; + uint16_t exp_zone; + uint32_t exp_class; + uint32_t exp_flags; + char * exp_helper_name; + char * exp_fn; + uint8_t exp_nat_dir; + + struct nfnl_exp_dir exp_expect; + struct nfnl_exp_dir exp_master; + struct nfnl_exp_dir exp_mask; + struct nfnl_exp_dir exp_nat; +}; + +struct nfnl_log { + NLHDR_COMMON + + uint16_t log_group; + uint8_t log_copy_mode; + uint32_t log_copy_range; + uint32_t log_flush_timeout; + uint32_t log_alloc_size; + uint32_t log_queue_threshold; + uint32_t log_flags; + uint32_t log_flag_mask; +}; + +struct nfnl_log_msg { + NLHDR_COMMON + + uint8_t log_msg_family; + uint8_t log_msg_hook; + uint16_t log_msg_hwproto; + uint32_t log_msg_mark; + struct timeval log_msg_timestamp; + uint32_t log_msg_indev; + uint32_t log_msg_outdev; + uint32_t log_msg_physindev; + uint32_t log_msg_physoutdev; + uint8_t log_msg_hwaddr[8]; + int log_msg_hwaddr_len; + void * log_msg_payload; + int log_msg_payload_len; + char * log_msg_prefix; + uint32_t log_msg_uid; + uint32_t log_msg_gid; + uint32_t log_msg_seq; + uint32_t log_msg_seq_global; +}; + +struct nfnl_queue { + NLHDR_COMMON + + uint16_t queue_group; + uint32_t queue_maxlen; + uint32_t queue_copy_range; + uint8_t queue_copy_mode; +}; + +struct nfnl_queue_msg { + NLHDR_COMMON + + uint16_t queue_msg_group; + uint8_t queue_msg_family; + uint8_t queue_msg_hook; + uint16_t queue_msg_hwproto; + uint32_t queue_msg_packetid; + uint32_t queue_msg_mark; + struct timeval queue_msg_timestamp; + uint32_t queue_msg_indev; + uint32_t queue_msg_outdev; + uint32_t queue_msg_physindev; + uint32_t queue_msg_physoutdev; + uint8_t queue_msg_hwaddr[8]; + int queue_msg_hwaddr_len; + void * queue_msg_payload; + int queue_msg_payload_len; + uint32_t queue_msg_verdict; +}; + +struct ematch_quoted { + char * data; + size_t len; + int index; +}; + +#endif diff --git a/include/netlink-tc.h b/include/netlink-tc.h deleted file mode 100644 index 3e44642..0000000 --- a/include/netlink-tc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * netlink-tc.h Local Traffic Control Interface - * - * 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-2010 Thomas Graf - */ - -#ifndef NETLINK_TC_PRIV_H_ -#define NETLINK_TC_PRIV_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define TCA_ATTR_HANDLE 0x0001 -#define TCA_ATTR_PARENT 0x0002 -#define TCA_ATTR_IFINDEX 0x0004 -#define TCA_ATTR_KIND 0x0008 -#define TCA_ATTR_FAMILY 0x0010 -#define TCA_ATTR_INFO 0x0020 -#define TCA_ATTR_OPTS 0x0040 -#define TCA_ATTR_STATS 0x0080 -#define TCA_ATTR_XSTATS 0x0100 -#define TCA_ATTR_LINK 0x0200 -#define TCA_ATTR_MTU 0x0400 -#define TCA_ATTR_MPU 0x0800 -#define TCA_ATTR_OVERHEAD 0x1000 -#define TCA_ATTR_LINKTYPE 0x2000 -#define TCA_ATTR_MAX TCA_ATTR_LINKTYPE - -extern int tca_parse(struct nlattr **, int, struct rtnl_tc *, - struct nla_policy *); - -#define RTNL_TC_RTABLE_SIZE 256 - -extern int rtnl_tc_build_rate_table(struct rtnl_tc *tc, struct rtnl_ratespec *, - uint32_t *); - - -static inline void *tca_xstats(struct rtnl_tc *tca) -{ - return tca->tc_xstats->d_data; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/netlink-types.h b/include/netlink-types.h deleted file mode 100644 index 46856a3..0000000 --- a/include/netlink-types.h +++ /dev/null @@ -1,910 +0,0 @@ -/* - * netlink-types.h Netlink Types (Private) - * - * 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-2012 Thomas Graf - */ - -#ifndef NETLINK_LOCAL_TYPES_H_ -#define NETLINK_LOCAL_TYPES_H_ - -#include -#include -#include -#include -#include -#include - -#define NL_SOCK_BUFSIZE_SET (1<<0) -#define NL_SOCK_PASSCRED (1<<1) -#define NL_OWN_PORT (1<<2) -#define NL_MSG_PEEK (1<<3) -#define NL_NO_AUTO_ACK (1<<4) - -#define NL_MSG_CRED_PRESENT 1 - -struct nl_cache_ops; -struct nl_sock; -struct nl_object; -struct nl_hash_table; - -struct nl_cb -{ - nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1]; - void * cb_args[NL_CB_TYPE_MAX+1]; - - nl_recvmsg_err_cb_t cb_err; - void * cb_err_arg; - - /** May be used to replace nl_recvmsgs with your own implementation - * in all internal calls to nl_recvmsgs. */ - int (*cb_recvmsgs_ow)(struct nl_sock *, - struct nl_cb *); - - /** Overwrite internal calls to nl_recv, must return the number of - * octets read and allocate a buffer for the received data. */ - int (*cb_recv_ow)(struct nl_sock *, - struct sockaddr_nl *, - unsigned char **, - struct ucred **); - - /** Overwrites internal calls to nl_send, must send the netlink - * message. */ - int (*cb_send_ow)(struct nl_sock *, - struct nl_msg *); - - int cb_refcnt; -}; - -struct nl_sock -{ - struct sockaddr_nl s_local; - struct sockaddr_nl s_peer; - int s_fd; - int s_proto; - unsigned int s_seq_next; - unsigned int s_seq_expect; - int s_flags; - struct nl_cb * s_cb; - size_t s_bufsize; -}; - -struct nl_cache -{ - struct nl_list_head c_items; - int c_nitems; - int c_iarg1; - int c_iarg2; - int c_refcnt; - unsigned int c_flags; - struct nl_hash_table * hashtable; - struct nl_cache_ops * c_ops; -}; - -struct nl_cache_assoc -{ - struct nl_cache * ca_cache; - change_func_t ca_change; - void * ca_change_data; -}; - -struct nl_cache_mngr -{ - int cm_protocol; - int cm_flags; - int cm_nassocs; - struct nl_sock * cm_sock; - struct nl_sock * cm_sync_sock; - struct nl_cache_assoc * cm_assocs; -}; - -struct nl_parser_param; - -#define LOOSE_COMPARISON 1 - -#define NL_OBJ_MARK 1 - -struct nl_data -{ - size_t d_size; - void * d_data; -}; - -struct nl_addr -{ - int a_family; - unsigned int a_maxsize; - unsigned int a_len; - int a_prefixlen; - int a_refcnt; - char a_addr[0]; -}; - -struct nl_msg -{ - int nm_protocol; - int nm_flags; - struct sockaddr_nl nm_src; - struct sockaddr_nl nm_dst; - struct ucred nm_creds; - struct nlmsghdr * nm_nlh; - size_t nm_size; - int nm_refcnt; -}; - -struct rtnl_link_map -{ - uint64_t lm_mem_start; - uint64_t lm_mem_end; - uint64_t lm_base_addr; - uint16_t lm_irq; - uint8_t lm_dma; - uint8_t lm_port; -}; - -#define IFQDISCSIZ 32 - -struct rtnl_link -{ - NLHDR_COMMON - - char l_name[IFNAMSIZ]; - uint32_t l_family; - uint32_t l_arptype; - uint32_t l_index; - uint32_t l_flags; - uint32_t l_change; - uint32_t l_mtu; - uint32_t l_link; - uint32_t l_txqlen; - uint32_t l_weight; - uint32_t l_master; - struct nl_addr * l_addr; - struct nl_addr * l_bcast; - char l_qdisc[IFQDISCSIZ]; - struct rtnl_link_map l_map; - uint64_t l_stats[RTNL_LINK_STATS_MAX+1]; - uint32_t l_flag_mask; - uint32_t l_num_vf; - uint8_t l_operstate; - uint8_t l_linkmode; - /* 2 byte hole */ - char * l_info_kind; - struct rtnl_link_info_ops * l_info_ops; - void * l_af_data[AF_MAX]; - void * l_info; - char * l_ifalias; - uint32_t l_promiscuity; - uint32_t l_num_tx_queues; - uint32_t l_num_rx_queues; - uint32_t l_group; - uint8_t l_carrier; -}; - -struct rtnl_ncacheinfo -{ - uint32_t nci_confirmed; /**< Time since neighbour validty was last confirmed */ - uint32_t nci_used; /**< Time since neighbour entry was last ued */ - uint32_t nci_updated; /**< Time since last update */ - uint32_t nci_refcnt; /**< Reference counter */ -}; - - -struct rtnl_neigh -{ - NLHDR_COMMON - uint32_t n_family; - uint32_t n_ifindex; - uint16_t n_state; - uint8_t n_flags; - uint8_t n_type; - struct nl_addr *n_lladdr; - struct nl_addr *n_dst; - uint32_t n_probes; - struct rtnl_ncacheinfo n_cacheinfo; - uint32_t n_state_mask; - uint32_t n_flag_mask; - uint32_t n_master; -}; - - -struct rtnl_addr_cacheinfo -{ - /* Preferred lifetime in seconds */ - uint32_t aci_prefered; - - /* Valid lifetime in seconds */ - uint32_t aci_valid; - - /* Timestamp of creation in 1/100s seince boottime */ - uint32_t aci_cstamp; - - /* Timestamp of last update in 1/100s since boottime */ - uint32_t aci_tstamp; -}; - -struct rtnl_addr -{ - NLHDR_COMMON - - uint8_t a_family; - uint8_t a_prefixlen; - uint8_t a_flags; - uint8_t a_scope; - uint32_t a_ifindex; - - struct nl_addr *a_peer; - struct nl_addr *a_local; - struct nl_addr *a_bcast; - struct nl_addr *a_anycast; - struct nl_addr *a_multicast; - - struct rtnl_addr_cacheinfo a_cacheinfo; - - char a_label[IFNAMSIZ]; - uint32_t a_flag_mask; - struct rtnl_link *a_link; -}; - -struct rtnl_nexthop -{ - uint8_t rtnh_flags; - uint8_t rtnh_flag_mask; - uint8_t rtnh_weight; - /* 1 byte spare */ - uint32_t rtnh_ifindex; - struct nl_addr * rtnh_gateway; - uint32_t ce_mask; /* HACK to support attr macros */ - struct nl_list_head rtnh_list; - uint32_t rtnh_realms; -}; - -struct rtnl_route -{ - NLHDR_COMMON - - uint8_t rt_family; - uint8_t rt_dst_len; - uint8_t rt_src_len; - uint8_t rt_tos; - uint8_t rt_protocol; - uint8_t rt_scope; - uint8_t rt_type; - uint8_t rt_nmetrics; - uint32_t rt_flags; - struct nl_addr * rt_dst; - struct nl_addr * rt_src; - uint32_t rt_table; - uint32_t rt_iif; - uint32_t rt_prio; - uint32_t rt_metrics[RTAX_MAX]; - uint32_t rt_metrics_mask; - uint32_t rt_nr_nh; - struct nl_addr * rt_pref_src; - struct nl_list_head rt_nexthops; - struct rtnl_rtcacheinfo rt_cacheinfo; - uint32_t rt_flag_mask; -}; - -struct rtnl_rule -{ - NLHDR_COMMON - uint8_t r_family; - uint8_t r_action; - uint8_t r_dsfield; /* ipv4 only */ - uint8_t r_unused; - uint32_t r_table; - uint32_t r_flags; - uint32_t r_prio; - uint32_t r_mark; - uint32_t r_mask; - uint32_t r_goto; - uint32_t r_flow; /* ipv4 only */ - struct nl_addr *r_src; - struct nl_addr *r_dst; - char r_iifname[IFNAMSIZ]; - char r_oifname[IFNAMSIZ]; -}; - -struct rtnl_neightbl_parms -{ - /** - * Interface index of the device this parameter set is assigned - * to or 0 for the default set. - */ - uint32_t ntp_ifindex; - - /** - * Number of references to this parameter set. - */ - uint32_t ntp_refcnt; - - /** - * Queue length for pending arp requests, i.e. the number of - * packets which are accepted from other layers while the - * neighbour address is still being resolved - */ - uint32_t ntp_queue_len; - - /** - * Number of requests to send to the user level ARP daemon. - * Specify 0 to disable. - */ - uint32_t ntp_app_probes; - - /** - * Maximum number of retries for unicast solicitation. - */ - uint32_t ntp_ucast_probes; - - /** - * Maximum number of retries for multicast solicitation. - */ - uint32_t ntp_mcast_probes; - - /** - * Base value in milliseconds to ompute reachable time, see RFC2461. - */ - uint64_t ntp_base_reachable_time; - - /** - * Actual reachable time (read-only) - */ - uint64_t ntp_reachable_time; /* secs */ - - /** - * The time in milliseconds between retransmitted Neighbor - * Solicitation messages. - */ - uint64_t ntp_retrans_time; - - /** - * Interval in milliseconds to check for stale neighbour - * entries. - */ - uint64_t ntp_gc_stale_time; /* secs */ - - /** - * Delay in milliseconds for the first time probe if - * the neighbour is reachable. - */ - uint64_t ntp_probe_delay; /* secs */ - - /** - * Maximum delay in milliseconds of an answer to a neighbour - * solicitation message. - */ - uint64_t ntp_anycast_delay; - - /** - * Minimum age in milliseconds before a neighbour entry - * may be replaced. - */ - uint64_t ntp_locktime; - - /** - * Delay in milliseconds before answering to an ARP request - * for which a proxy ARP entry exists. - */ - uint64_t ntp_proxy_delay; - - /** - * Queue length for the delayed proxy arp requests. - */ - uint32_t ntp_proxy_qlen; - - /** - * Mask of available parameter attributes - */ - uint32_t ntp_mask; -}; - -#define NTBLNAMSIZ 32 - -/** - * Neighbour table - * @ingroup neightbl - */ -struct rtnl_neightbl -{ - NLHDR_COMMON - - char nt_name[NTBLNAMSIZ]; - uint32_t nt_family; - uint32_t nt_gc_thresh1; - uint32_t nt_gc_thresh2; - uint32_t nt_gc_thresh3; - uint64_t nt_gc_interval; - struct ndt_config nt_config; - struct rtnl_neightbl_parms nt_parms; - struct ndt_stats nt_stats; -}; - -struct rtnl_ratespec -{ - uint8_t rs_cell_log; - uint16_t rs_overhead; - int16_t rs_cell_align; - uint16_t rs_mpu; - uint32_t rs_rate; -}; - -struct rtnl_tstats -{ - struct { - uint64_t bytes; - uint64_t packets; - } tcs_basic; - - struct { - uint32_t bps; - uint32_t pps; - } tcs_rate_est; - - struct { - uint32_t qlen; - uint32_t backlog; - uint32_t drops; - uint32_t requeues; - uint32_t overlimits; - } tcs_queue; -}; - -#define TCKINDSIZ 32 - -#define NL_TC_GENERIC(pre) \ - NLHDR_COMMON \ - uint32_t pre ##_family; \ - uint32_t pre ##_ifindex; \ - uint32_t pre ##_handle; \ - uint32_t pre ##_parent; \ - uint32_t pre ##_info; \ - uint32_t pre ##_mtu; \ - uint32_t pre ##_mpu; \ - uint32_t pre ##_overhead; \ - uint32_t pre ##_linktype; \ - char pre ##_kind[TCKINDSIZ]; \ - struct nl_data * pre ##_opts; \ - 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_tc_ops * pre ##_ops; \ - enum rtnl_tc_type pre ##_type - -struct rtnl_tc -{ - NL_TC_GENERIC(tc); -}; - -struct rtnl_qdisc -{ - NL_TC_GENERIC(q); -}; - -struct rtnl_class -{ - NL_TC_GENERIC(c); -}; - -struct rtnl_cls -{ - NL_TC_GENERIC(c); - uint16_t c_prio; - uint16_t c_protocol; -}; - -struct rtnl_u32 -{ - uint32_t cu_divisor; - uint32_t cu_hash; - uint32_t cu_classid; - uint32_t cu_link; - struct nl_data * cu_pcnt; - struct nl_data * cu_selector; - struct nl_data * cu_act; - struct nl_data * cu_police; - char cu_indev[IFNAMSIZ]; - int cu_mask; -}; - -struct rtnl_cgroup -{ - struct rtnl_ematch_tree *cg_ematch; - int cg_mask; -}; - -struct rtnl_fw -{ - uint32_t cf_classid; - struct nl_data * cf_act; - struct nl_data * cf_police; - char cf_indev[IFNAMSIZ]; - uint32_t cf_fwmask; - int cf_mask; -}; - -struct rtnl_ematch -{ - uint16_t e_id; - uint16_t e_kind; - uint16_t e_flags; - uint16_t e_index; - size_t e_datalen; - - struct nl_list_head e_childs; - struct nl_list_head e_list; - struct rtnl_ematch_ops *e_ops; - - void * e_data; -}; - -struct rtnl_ematch_tree -{ - uint16_t et_progid; - struct nl_list_head et_list; - -}; - -struct rtnl_dsmark_qdisc -{ - uint16_t qdm_indices; - uint16_t qdm_default_index; - uint32_t qdm_set_tc_index; - uint32_t qdm_mask; -}; - -struct rtnl_dsmark_class -{ - uint8_t cdm_bmask; - uint8_t cdm_value; - uint32_t cdm_mask; -}; - -struct rtnl_fifo -{ - uint32_t qf_limit; - uint32_t qf_mask; -}; - -struct rtnl_prio -{ - uint32_t qp_bands; - uint8_t qp_priomap[TC_PRIO_MAX+1]; - uint32_t qp_mask; -}; - -struct rtnl_tbf -{ - uint32_t qt_limit; - struct rtnl_ratespec qt_rate; - uint32_t qt_rate_bucket; - uint32_t qt_rate_txtime; - struct rtnl_ratespec qt_peakrate; - uint32_t qt_peakrate_bucket; - uint32_t qt_peakrate_txtime; - uint32_t qt_mask; -}; - -struct rtnl_sfq -{ - uint32_t qs_quantum; - uint32_t qs_perturb; - uint32_t qs_limit; - uint32_t qs_divisor; - uint32_t qs_flows; - uint32_t qs_mask; -}; - -struct rtnl_netem_corr -{ - uint32_t nmc_delay; - uint32_t nmc_loss; - uint32_t nmc_duplicate; -}; - -struct rtnl_netem_reo -{ - uint32_t nmro_probability; - uint32_t nmro_correlation; -}; - -struct rtnl_netem_crpt -{ - uint32_t nmcr_probability; - uint32_t nmcr_correlation; -}; - -struct rtnl_netem_dist -{ - int16_t * dist_data; - size_t dist_size; -}; - -struct rtnl_netem -{ - uint32_t qnm_latency; - uint32_t qnm_limit; - uint32_t qnm_loss; - uint32_t qnm_gap; - uint32_t qnm_duplicate; - uint32_t qnm_jitter; - uint32_t qnm_mask; - struct rtnl_netem_corr qnm_corr; - struct rtnl_netem_reo qnm_ro; - struct rtnl_netem_crpt qnm_crpt; - struct rtnl_netem_dist qnm_dist; -}; - -struct rtnl_htb_qdisc -{ - uint32_t qh_rate2quantum; - uint32_t qh_defcls; - uint32_t qh_mask; - uint32_t qh_direct_pkts; -}; - -struct rtnl_htb_class -{ - uint32_t ch_prio; - struct rtnl_ratespec ch_rate; - struct rtnl_ratespec ch_ceil; - uint32_t ch_rbuffer; - uint32_t ch_cbuffer; - uint32_t ch_quantum; - uint32_t ch_mask; - uint32_t ch_level; -}; - -struct rtnl_cbq -{ - struct tc_cbq_lssopt cbq_lss; - struct tc_ratespec cbq_rate; - struct tc_cbq_wrropt cbq_wrr; - struct tc_cbq_ovl cbq_ovl; - struct tc_cbq_fopt cbq_fopt; - struct tc_cbq_police cbq_police; -}; - -struct rtnl_red -{ - uint32_t qr_limit; - uint32_t qr_qth_min; - uint32_t qr_qth_max; - uint8_t qr_flags; - uint8_t qr_wlog; - uint8_t qr_plog; - uint8_t qr_scell_log; - uint32_t qr_mask; -}; - -struct rtnl_plug -{ - int action; - uint32_t limit; -}; - -struct flnl_request -{ - NLHDR_COMMON - - struct nl_addr * lr_addr; - uint32_t lr_fwmark; - uint8_t lr_tos; - uint8_t lr_scope; - uint8_t lr_table; -}; - - -struct flnl_result -{ - NLHDR_COMMON - - struct flnl_request * fr_req; - uint8_t fr_table_id; - uint8_t fr_prefixlen; - uint8_t fr_nh_sel; - uint8_t fr_type; - uint8_t fr_scope; - uint32_t fr_error; -}; - -#define GENL_OP_HAS_POLICY 1 -#define GENL_OP_HAS_DOIT 2 -#define GENL_OP_HAS_DUMPIT 4 - -struct genl_family_op -{ - uint32_t o_id; - uint32_t o_flags; - - struct nl_list_head o_list; -}; - -struct genl_family_grp { - struct genl_family *family; /* private */ - struct nl_list_head list; /* private */ - char name[GENL_NAMSIZ]; - u_int32_t id; -}; - -struct genl_family -{ - NLHDR_COMMON - - uint16_t gf_id; - char gf_name[GENL_NAMSIZ]; - uint32_t gf_version; - uint32_t gf_hdrsize; - uint32_t gf_maxattr; - - struct nl_list_head gf_ops; - struct nl_list_head gf_mc_grps; -}; - -union nfnl_ct_proto -{ - struct { - uint16_t src; - uint16_t dst; - } port; - struct { - uint16_t id; - uint8_t type; - uint8_t code; - } icmp; -}; - -struct nfnl_ct_dir { - struct nl_addr * src; - struct nl_addr * dst; - union nfnl_ct_proto proto; - uint64_t packets; - uint64_t bytes; -}; - -union nfnl_ct_protoinfo { - struct { - uint8_t state; - } tcp; -}; - -struct nfnl_ct { - NLHDR_COMMON - - uint8_t ct_family; - uint8_t ct_proto; - union nfnl_ct_protoinfo ct_protoinfo; - - uint32_t ct_status; - uint32_t ct_status_mask; - uint32_t ct_timeout; - uint32_t ct_mark; - uint32_t ct_use; - uint32_t ct_id; - - struct nfnl_ct_dir ct_orig; - struct nfnl_ct_dir ct_repl; -}; - -union nfnl_exp_protodata { - struct { - uint16_t src; - uint16_t dst; - } port; - struct { - uint16_t id; - uint8_t type; - uint8_t code; - } icmp; -}; - -// Allow for different master/expect l4 protocols -struct nfnl_exp_proto -{ - uint8_t l4protonum; - union nfnl_exp_protodata l4protodata; -}; - -struct nfnl_exp_dir { - struct nl_addr * src; - struct nl_addr * dst; - struct nfnl_exp_proto proto; -}; - -struct nfnl_exp { - NLHDR_COMMON - - uint8_t exp_family; - uint32_t exp_timeout; - uint32_t exp_id; - uint16_t exp_zone; - uint32_t exp_class; - uint32_t exp_flags; - char * exp_helper_name; - char * exp_fn; - uint8_t exp_nat_dir; - - struct nfnl_exp_dir exp_expect; - struct nfnl_exp_dir exp_master; - struct nfnl_exp_dir exp_mask; - struct nfnl_exp_dir exp_nat; -}; - -struct nfnl_log { - NLHDR_COMMON - - uint16_t log_group; - uint8_t log_copy_mode; - uint32_t log_copy_range; - uint32_t log_flush_timeout; - uint32_t log_alloc_size; - uint32_t log_queue_threshold; - uint32_t log_flags; - uint32_t log_flag_mask; -}; - -struct nfnl_log_msg { - NLHDR_COMMON - - uint8_t log_msg_family; - uint8_t log_msg_hook; - uint16_t log_msg_hwproto; - uint32_t log_msg_mark; - struct timeval log_msg_timestamp; - uint32_t log_msg_indev; - uint32_t log_msg_outdev; - uint32_t log_msg_physindev; - uint32_t log_msg_physoutdev; - uint8_t log_msg_hwaddr[8]; - int log_msg_hwaddr_len; - void * log_msg_payload; - int log_msg_payload_len; - char * log_msg_prefix; - uint32_t log_msg_uid; - uint32_t log_msg_gid; - uint32_t log_msg_seq; - uint32_t log_msg_seq_global; -}; - -struct nfnl_queue { - NLHDR_COMMON - - uint16_t queue_group; - uint32_t queue_maxlen; - uint32_t queue_copy_range; - uint8_t queue_copy_mode; -}; - -struct nfnl_queue_msg { - NLHDR_COMMON - - uint16_t queue_msg_group; - uint8_t queue_msg_family; - uint8_t queue_msg_hook; - uint16_t queue_msg_hwproto; - uint32_t queue_msg_packetid; - uint32_t queue_msg_mark; - struct timeval queue_msg_timestamp; - uint32_t queue_msg_indev; - uint32_t queue_msg_outdev; - uint32_t queue_msg_physindev; - uint32_t queue_msg_physoutdev; - uint8_t queue_msg_hwaddr[8]; - int queue_msg_hwaddr_len; - void * queue_msg_payload; - int queue_msg_payload_len; - uint32_t queue_msg_verdict; -}; - -struct ematch_quoted { - char * data; - size_t len; - int index; -}; - -#endif diff --git a/include/netlink/cache-api.h b/include/netlink/cache-api.h deleted file mode 100644 index 493a551..0000000 --- a/include/netlink/cache-api.h +++ /dev/null @@ -1,285 +0,0 @@ -/* - * netlink/cache-api.h Caching 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-2012 Thomas Graf - */ - -#ifndef NETLINK_CACHE_API_H_ -#define NETLINK_CACHE_API_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup cache - * @defgroup cache_api Cache Implementation - * @brief - * - * @par 1) Cache Definition - * @code - * struct nl_cache_ops my_cache_ops = { - * .co_name = "route/link", - * .co_protocol = NETLINK_ROUTE, - * .co_hdrsize = sizeof(struct ifinfomsg), - * .co_obj_ops = &my_obj_ops, - * }; - * @endcode - * - * @par 2) - * @code - * // The simplest way to fill a cache is by providing a request-update - * // function which must trigger a complete dump on the kernel-side of - * // whatever the cache covers. - * static int my_request_update(struct nl_cache *cache, - * struct nl_sock *socket) - * { - * // In this example, we request a full dump of the interface table - * return nl_rtgen_request(socket, RTM_GETLINK, AF_UNSPEC, NLM_F_DUMP); - * } - * - * // The resulting netlink messages sent back will be fed into a message - * // parser one at a time. The message parser has to extract all relevant - * // information from the message and create an object reflecting the - * // contents of the message and pass it on to the parser callback function - * // provide which will add the object to the cache. - * static int my_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, - * struct nlmsghdr *nlh, struct nl_parser_param *pp) - * { - * struct my_obj *obj; - * - * obj = my_obj_alloc(); - * obj->ce_msgtype = nlh->nlmsg_type; - * - * // Parse the netlink message and continue creating the object. - * - * err = pp->pp_cb((struct nl_object *) obj, pp); - * if (err < 0) - * goto errout; - * } - * - * struct nl_cache_ops my_cache_ops = { - * ... - * .co_request_update = my_request_update, - * .co_msg_parser = my_msg_parser, - * }; - * @endcode - * - * @par 3) Notification based Updates - * @code - * // Caches can be kept up-to-date based on notifications if the kernel - * // sends out notifications whenever an object is added/removed/changed. - * // - * // It is trivial to support this, first a list of groups needs to be - * // defined which are required to join in order to receive all necessary - * // notifications. The groups are separated by address family to support - * // the common situation where a separate group is used for each address - * // family. If there is only one group, simply specify AF_UNSPEC. - * static struct nl_af_group addr_groups[] = { - * { AF_INET, RTNLGRP_IPV4_IFADDR }, - * { AF_INET6, RTNLGRP_IPV6_IFADDR }, - * { END_OF_GROUP_LIST }, - * }; - * - * // In order for the caching system to know the meaning of each message - * // type it requires a table which maps each supported message type to - * // a cache action, e.g. RTM_NEWADDR means address has been added or - * // updated, RTM_DELADDR means address has been removed. - * static struct nl_cache_ops rtnl_addr_ops = { - * ... - * .co_msgtypes = { - * { RTM_NEWADDR, NL_ACT_NEW, "new" }, - * { RTM_DELADDR, NL_ACT_DEL, "del" }, - * { RTM_GETADDR, NL_ACT_GET, "get" }, - * END_OF_MSGTYPES_LIST, - * }, - * .co_groups = addr_groups, - * }; - * - * // It is now possible to keep the cache up-to-date using the cache manager. - * @endcode - * @{ - */ - -enum { - NL_ACT_UNSPEC, - NL_ACT_NEW, - NL_ACT_DEL, - NL_ACT_GET, - NL_ACT_SET, - NL_ACT_CHANGE, - __NL_ACT_MAX, -}; - -#define NL_ACT_MAX (__NL_ACT_MAX - 1) - -#define END_OF_MSGTYPES_LIST { -1, -1, NULL } - -/** - * Message type to cache action association - */ -struct nl_msgtype -{ - /** Netlink message type */ - int mt_id; - - /** Cache action to take */ - int mt_act; - - /** Name of operation for human-readable printing */ - char * mt_name; -}; - -/** - * Address family to netlink group association - */ -struct nl_af_group -{ - /** Address family */ - int ag_family; - - /** Netlink group identifier */ - int ag_group; -}; - -#define END_OF_GROUP_LIST AF_UNSPEC, 0 - -/** - * Parser parameters - * - * This structure is used to configure what kind of parser to use - * when parsing netlink messages to create objects. - */ -struct nl_parser_param -{ - /** Function to parse netlink messages into objects */ - int (*pp_cb)(struct nl_object *, struct nl_parser_param *); - - /** Arbitary argument to be passed to the parser */ - void * pp_arg; -}; - -/** - * Cache Operations - * - * This structure defines the characterstics of a cache type. It contains - * pointers to functions which implement the specifics of the object type - * the cache can hold. - */ -struct nl_cache_ops -{ - /** Name of cache type (must be unique) */ - char * co_name; - - /** Size of family specific netlink header */ - int co_hdrsize; - - /** Netlink protocol */ - int co_protocol; - - /** cache object hash size **/ - int co_hash_size; - - /** cache flags */ - unsigned int co_flags; - - /** Reference counter */ - unsigned int co_refcnt; - - /** Group definition */ - struct nl_af_group * co_groups; - - /** - * Called whenever an update of the cache is required. Must send - * a request message to the kernel requesting a complete dump. - */ - int (*co_request_update)(struct nl_cache *, struct nl_sock *); - - /** - * Called whenever a message was received that needs to be parsed. - * Must parse the message and call the paser callback function - * (nl_parser_param) provided via the argument. - */ - int (*co_msg_parser)(struct nl_cache_ops *, struct sockaddr_nl *, - struct nlmsghdr *, struct nl_parser_param *); - - /** - * The function registered under this callback is called after a - * netlink notification associated with this cache type has been - * parsed into an object and is being considered for inclusio into - * the specified cache. - * - * The purpose of this function is to filter out notifications - * which should be ignored when updating caches. - * - * The function must return NL_SKIP to prevent the object from - * being included, or NL_OK to include it. - * - * @code - * int my_filter(struct nl_cache *cache, struct nl_object *obj) - * { - * if (reason_to_not_include_obj(obj)) - * return NL_SKIP; - * - * return NL_OK; - * } - * @endcode - */ - int (*co_event_filter)(struct nl_cache *, struct nl_object *obj); - - /** - * The function registered under this callback is called when an - * object formed from a notification event needs to be included in - * a cache. - * - * For each modified object, the change callback \c change_cb must - * be called with the \c data argument provided. - * - * If no function is registered, the function nl_cache_include() - * will be used for this purpose. - * - * @see nl_cache_include() - */ - int (*co_include_event)(struct nl_cache *cache, struct nl_object *obj, - change_func_t change_cb, void *data); - - void (*reserved_1)(void); - void (*reserved_2)(void); - void (*reserved_3)(void); - void (*reserved_4)(void); - void (*reserved_5)(void); - void (*reserved_6)(void); - void (*reserved_7)(void); - void (*reserved_8)(void); - - /** Object operations */ - struct nl_object_ops * co_obj_ops; - - /** Internal, do not touch! */ - struct nl_cache_ops *co_next; - - struct nl_cache *co_major_cache; - struct genl_ops * co_genl; - - /* Message type definition */ - struct nl_msgtype co_msgtypes[]; -}; - -extern void nl_cache_ops_get(struct nl_cache_ops *); -extern void nl_cache_ops_put(struct nl_cache_ops *); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/netlink/object-api.h b/include/netlink/object-api.h deleted file mode 100644 index ae6180a..0000000 --- a/include/netlink/object-api.h +++ /dev/null @@ -1,375 +0,0 @@ -/* - * netlink/object-api.c Object 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-2007 Thomas Graf - */ - -#ifndef NETLINK_OBJECT_API_H_ -#define NETLINK_OBJECT_API_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup object - * @defgroup object_api Object API - * @brief - * - * @par 1) Object Definition - * @code - * // Define your object starting with the common object header - * struct my_obj { - * NLHDR_COMMON - * int my_data; - * }; - * - * // Fill out the object operations structure - * struct nl_object_ops my_ops = { - * .oo_name = "my_obj", - * .oo_size = sizeof(struct my_obj), - * }; - * - * // At this point the object can be allocated, you may want to provide a - * // separate _alloc() function to ease allocting objects of this kind. - * struct nl_object *obj = nl_object_alloc(&my_ops); - * - * // And release it again... - * nl_object_put(obj); - * @endcode - * - * @par 2) Allocating additional data - * @code - * // You may require to allocate additional data and store it inside - * // object, f.e. assuming there is a field `ptr'. - * struct my_obj { - * NLHDR_COMMON - * void * ptr; - * }; - * - * // And at some point you may assign allocated data to this field: - * my_obj->ptr = calloc(1, ...); - * - * // In order to not introduce any memory leaks you have to release - * // this data again when the last reference is given back. - * static void my_obj_free_data(struct nl_object *obj) - * { - * struct my_obj *my_obj = nl_object_priv(obj); - * - * free(my_obj->ptr); - * } - * - * // Also when the object is cloned, you must ensure for your pointer - * // stay valid even if one of the clones is freed by either making - * // a clone as well or increase the reference count. - * static int my_obj_clone(struct nl_object *src, struct nl_object *dst) - * { - * struct my_obj *my_src = nl_object_priv(src); - * struct my_obj *my_dst = nl_object_priv(dst); - * - * if (src->ptr) { - * dst->ptr = calloc(1, ...); - * memcpy(dst->ptr, src->ptr, ...); - * } - * } - * - * struct nl_object_ops my_ops = { - * ... - * .oo_free_data = my_obj_free_data, - * .oo_clone = my_obj_clone, - * }; - * @endcode - * - * @par 3) Object Dumping - * @code - * static int my_obj_dump_detailed(struct nl_object *obj, - * struct nl_dump_params *params) - * { - * struct my_obj *my_obj = nl_object_priv(obj); - * - * // It is absolutely essential to use nl_dump() when printing - * // any text to make sure the dumping parameters are respected. - * nl_dump(params, "Obj Integer: %d\n", my_obj->my_int); - * - * // Before we can dump the next line, make sure to prefix - * // this line correctly. - * nl_new_line(params); - * - * // You may also split a line into multiple nl_dump() calls. - * nl_dump(params, "String: %s ", my_obj->my_string); - * nl_dump(params, "String-2: %s\n", my_obj->another_string); - * } - * - * struct nl_object_ops my_ops = { - * ... - * .oo_dump[NL_DUMP_FULL] = my_obj_dump_detailed, - * }; - * @endcode - * - * @par 4) Object Attributes - * @code - * // The concept of object attributes is optional but can ease the typical - * // case of objects that have optional attributes, e.g. a route may have a - * // nexthop assigned but it is not required to. - * - * // The first step to define your object specific bitmask listing all - * // attributes - * #define MY_ATTR_FOO (1<<0) - * #define MY_ATTR_BAR (1<<1) - * - * // When assigning an optional attribute to the object, make sure - * // to mark its availability. - * my_obj->foo = 123123; - * my_obj->ce_mask |= MY_ATTR_FOO; - * - * // At any time you may use this mask to check for the availability - * // of the attribute, e.g. while dumping - * if (my_obj->ce_mask & MY_ATTR_FOO) - * nl_dump(params, "foo %d ", my_obj->foo); - * - * // One of the big advantages of this concept is that it allows for - * // standardized comparisons which make it trivial for caches to - * // identify unique objects by use of unified comparison functions. - * // In order for it to work, your object implementation must provide - * // a comparison function and define a list of attributes which - * // combined together make an object unique. - * - * static int my_obj_compare(struct nl_object *_a, struct nl_object *_b, - * uint32_t attrs, int flags) - * { - * struct my_obj *a = nl_object_priv(_a): - * struct my_obj *b = nl_object_priv(_b): - * int diff = 0; - * - * // We help ourselves in defining our own DIFF macro which will - * // call ATTR_DIFF() on both objects which will make sure to only - * // compare the attributes if required. - * #define MY_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, MY_ATTR_##ATTR, a, b, EXPR) - * - * // Call our own diff macro for each attribute to build a bitmask - * // representing the attributes which mismatch. - * diff |= MY_DIFF(FOO, a->foo != b->foo) - * diff |= MY_DIFF(BAR, strcmp(a->bar, b->bar)) - * - * return diff; - * } - * - * // In order to identify identical objects with differing attributes - * // you must specify the attributes required to uniquely identify - * // your object. Make sure to not include too many attributes, this - * // list is used when caches look for an old version of an object. - * struct nl_object_ops my_ops = { - * ... - * .oo_id_attrs = MY_ATTR_FOO, - * .oo_compare = my_obj_compare, - * }; - * @endcode - * @{ - */ - -/** - * Common Object Header - * - * This macro must be included as first member in every object - * definition to allow objects to be cached. - */ -#define NLHDR_COMMON \ - int ce_refcnt; \ - struct nl_object_ops * ce_ops; \ - struct nl_cache * ce_cache; \ - struct nl_list_head ce_list; \ - int ce_msgtype; \ - int ce_flags; \ - uint32_t ce_mask; - -struct nl_object -{ - NLHDR_COMMON -}; - - -/** - * Return true if attribute is available in both objects - * @arg A an object - * @arg B another object - * @arg ATTR attribute bit - * - * @return True if the attribute is available, otherwise false is returned. - */ -#define AVAILABLE(A, B, ATTR) (((A)->ce_mask & (B)->ce_mask) & (ATTR)) - -/** - * Return true if attribute is available in only one of both objects - * @arg A an object - * @arg B another object - * @arg ATTR attribute bit - * - * @return True if the attribute is available in only one of both objects, - * otherwise false is returned. - */ -#define AVAILABLE_MISMATCH(A, B, ATTR) (((A)->ce_mask ^ (B)->ce_mask) & (ATTR)) - -/** - * Return true if attributes mismatch - * @arg A an object - * @arg B another object - * @arg ATTR attribute bit - * @arg EXPR Comparison expression - * - * This function will check if the attribute in question is available - * in both objects, if not this will count as a mismatch. - * - * If available the function will execute the expression which must - * return true if the attributes mismatch. - * - * @return True if the attribute mismatch, or false if they match. - */ -#define ATTR_MISMATCH(A, B, ATTR, EXPR) (AVAILABLE_MISMATCH(A, B, ATTR) || \ - (AVAILABLE(A, B, ATTR) && (EXPR))) - -/** - * Return attribute bit if attribute does not match - * @arg LIST list of attributes to be compared - * @arg ATTR attribute bit - * @arg A an object - * @arg B another object - * @arg EXPR Comparison expression - * - * This function will check if the attribute in question is available - * in both objects, if not this will count as a mismatch. - * - * If available the function will execute the expression which must - * return true if the attributes mismatch. - * - * In case the attributes mismatch, the attribute is returned, otherwise - * 0 is returned. - * - * @code - * diff |= ATTR_DIFF(attrs, MY_ATTR_FOO, a, b, a->foo != b->foo); - * @endcode - */ -#define ATTR_DIFF(LIST, ATTR, A, B, EXPR) \ -({ int diff = 0; \ - if (((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR)) \ - diff = ATTR; \ - diff; }) - -/** - * Object Operations - */ -struct nl_object_ops -{ - /** - * Unique name of object type - * - * Must be in the form family/name, e.g. "route/addr" - */ - char * oo_name; - - /** Size of object including its header */ - size_t oo_size; - - /* List of attributes needed to uniquely identify the object */ - uint32_t oo_id_attrs; - - /** - * Constructor function - * - * Will be called when a new object of this type is allocated. - * Can be used to initialize members such as lists etc. - */ - void (*oo_constructor)(struct nl_object *); - - /** - * Destructor function - * - * Will be called when an object is freed. Must free all - * resources which may have been allocated as part of this - * object. - */ - void (*oo_free_data)(struct nl_object *); - - /** - * Cloning function - * - * Will be called when an object needs to be cloned. Please - * note that the generic object code will make an exact - * copy of the object first, therefore you only need to take - * care of members which require reference counting etc. - * - * May return a negative error code to abort cloning. - */ - int (*oo_clone)(struct nl_object *, struct nl_object *); - - /** - * Dumping functions - * - * Will be called when an object is dumped. The implementations - * have to use nl_dump(), nl_dump_line(), and nl_new_line() to - * dump objects. - * - * The functions must return the number of lines printed. - */ - void (*oo_dump[NL_DUMP_MAX+1])(struct nl_object *, - struct nl_dump_params *); - - /** - * Comparison function - * - * Will be called when two objects of the same type are - * compared. It takes the two objects in question, an object - * specific bitmask defining which attributes should be - * compared and flags to control the behaviour. - * - * The function must return a bitmask with the relevant bit - * set for each attribute that mismatches. - */ - int (*oo_compare)(struct nl_object *, struct nl_object *, - uint32_t, int); - - - /** - * update function - * - * Will be called when the object given by first argument - * needs to be updated with the contents of the second object - * - * The function must return 0 for success and error for failure - * to update. In case of failure its assumed that the original - * object is not touched - */ - int (*oo_update)(struct nl_object *, struct nl_object *); - - /** - * Hash Key generator function - * - * When called returns a hash key for the object being - * referenced. This key will be used by higher level hash functions - * to build association lists. Each object type gets to specify - * it's own key formulation - */ - void (*oo_keygen)(struct nl_object *, uint32_t *, uint32_t); - - char *(*oo_attrs2str)(int, char *, size_t); - - /** - * Get key attributes by family function - */ - uint32_t (*oo_id_attrs_get)(struct nl_object *); -}; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/netlink/route/link/api.h b/include/netlink/route/link/api.h deleted file mode 100644 index 28f2464..0000000 --- a/include/netlink/route/link/api.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * netlink/route/link/api.h Link Modules 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-2010 Thomas Graf - */ - -#ifndef NETLINK_LINK_API_H_ -#define NETLINK_LINK_API_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup link_api - * - * Available operations to modules implementing a link info type. - */ -struct rtnl_link_info_ops -{ - /** Name of link info type, must match name on kernel side */ - char * io_name; - - /** Reference count, DO NOT MODIFY */ - int io_refcnt; - - /** Called to assign an info type to a link. - * Has to allocate enough resources to hold attributes. Can - * use link->l_info to store a pointer. */ - int (*io_alloc)(struct rtnl_link *); - - /** Called to parse the link info attribute. - * Must parse the attribute and assign all values to the link. - */ - int (*io_parse)(struct rtnl_link *, - struct nlattr *, - struct nlattr *); - - /** Called when the link object is dumped. - * Must dump the info type specific attributes. */ - void (*io_dump[NL_DUMP_MAX+1])(struct rtnl_link *, - struct nl_dump_params *); - - /** Called when a link object is cloned. - * Must clone all info type specific attributes. */ - int (*io_clone)(struct rtnl_link *, struct rtnl_link *); - - /** Called when construction a link netlink message. - * Must append all info type specific attributes to the message. */ - int (*io_put_attrs)(struct nl_msg *, struct rtnl_link *); - - /** Called to release all resources previously allocated - * in either io_alloc() or io_parse(). */ - void (*io_free)(struct rtnl_link *); - - struct nl_list_head io_list; -}; - -extern struct rtnl_link_info_ops *rtnl_link_info_ops_lookup(const char *); -extern void rtnl_link_info_ops_put(struct rtnl_link_info_ops *); -extern int rtnl_link_register_info(struct rtnl_link_info_ops *); -extern int rtnl_link_unregister_info(struct rtnl_link_info_ops *); - - -/** - * @ingroup link_api - * - * Available operations to modules implementing a link address family. - */ -struct rtnl_link_af_ops -{ - /** The address family this operations set implements */ - const unsigned int ao_family; - - /** Number of users of this operations, DO NOT MODIFY. */ - int ao_refcnt; - - /** Validation policy for IFLA_PROTINFO attribute. This pointer - * can be set to a nla_policy structure describing the minimal - * requirements the attribute must meet. Failure of meeting these - * requirements will result in a parsing error. */ - const struct nla_policy *ao_protinfo_policy; - - /** Called after address family has been assigned to link. Must - * allocate data buffer to hold address family specific data and - * store it in link->l_af_data. */ - void * (*ao_alloc)(struct rtnl_link *); - - /** Called when the link is cloned, must allocate a clone of the - * address family specific buffer and return it. */ - void * (*ao_clone)(struct rtnl_link *, void *); - - /** Called when the link gets freed. Must free all allocated data */ - void (*ao_free)(struct rtnl_link *, void *); - - /** Called if a IFLA_PROTINFO attribute needs to be parsed. Typically - * stores the parsed data in the address family specific buffer. */ - int (*ao_parse_protinfo)(struct rtnl_link *, - struct nlattr *, void *); - - /** Called if a IFLA_AF_SPEC attribute needs to be parsed. Typically - * stores the parsed data in the address family specific buffer. */ - int (*ao_parse_af)(struct rtnl_link *, - struct nlattr *, void *); - - /** Called if a link message is sent to the kernel. Must append the - * link address family specific attributes to the message. */ - int (*ao_fill_af)(struct rtnl_link *, - struct nl_msg *msg, void *); - - /** Dump address family specific link attributes */ - void (*ao_dump[NL_DUMP_MAX+1])(struct rtnl_link *, - struct nl_dump_params *, - void *); - - /** Comparison function - * - * Will be called when two links are compared for their af data. It - * takes two link objects in question, an object specific bitmask - * defining which attributes should be compared and flags to control - * the behaviour - * - * The function must return a bitmask with the relevant bit set for - * each attribute that mismatches - */ - int (*ao_compare)(struct rtnl_link *, - struct rtnl_link *, int, uint32_t, int); -}; - -extern struct rtnl_link_af_ops *rtnl_link_af_ops_lookup(unsigned int); -extern void rtnl_link_af_ops_put(struct rtnl_link_af_ops *); -extern void * rtnl_link_af_alloc(struct rtnl_link *, - const struct rtnl_link_af_ops *); -extern void * rtnl_link_af_data(const struct rtnl_link *, - const struct rtnl_link_af_ops *); -extern int rtnl_link_af_register(struct rtnl_link_af_ops *); -extern int rtnl_link_af_unregister(struct rtnl_link_af_ops *); -extern int rtnl_link_af_data_compare(struct rtnl_link *a, - struct rtnl_link *b, - int family); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/netlink/route/link/info-api.h b/include/netlink/route/link/info-api.h deleted file mode 100644 index 4750e18..0000000 --- a/include/netlink/route/link/info-api.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * netlink/route/link/info-api.h Link Info 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-2010 Thomas Graf - */ - -#ifndef NETLINK_LINK_INFO_API_H_ -#define NETLINK_LINK_INFO_API_H_ - -#warning " is obsolete and may be removed in the future." -#warning "include instead. - -#include - -#endif diff --git a/include/netlink/route/tc-api.h b/include/netlink/route/tc-api.h deleted file mode 100644 index 601a8df..0000000 --- a/include/netlink/route/tc-api.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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 - */ - -#ifndef NETLINK_TC_API_H_ -#define NETLINK_TC_API_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#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 void * rtnl_tc_data_check(struct rtnl_tc *, - struct rtnl_tc_ops *); - -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 caee60c..836f7b1 100644 --- a/include/netlink/route/tc.h +++ b/include/netlink/route/tc.h @@ -30,6 +30,8 @@ enum rtnl_tc_type { __RTNL_TC_TYPE_MAX, }; +#define RTNL_TC_TYPE_MAX (__RTNL_TC_TYPE_MAX - 1) + /** * Compute tc handle based on major and minor parts * @ingroup tc diff --git a/lib/addr.c b/lib/addr.c index 1f1478a..806664b 100644 --- a/lib/addr.c +++ b/lib/addr.c @@ -27,7 +27,7 @@ * ~~~~ */ -#include +#include #include #include #include diff --git a/lib/attr.c b/lib/attr.c index 1601061..10ea682 100644 --- a/lib/attr.c +++ b/lib/attr.c @@ -9,7 +9,7 @@ * Copyright (c) 2003-2008 Thomas Graf */ -#include +#include #include #include #include diff --git a/lib/cache.c b/lib/cache.c index 24ffa31..fafc023 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -49,7 +49,7 @@ * ~~~~ */ -#include +#include #include #include #include diff --git a/lib/cache_mngr.c b/lib/cache_mngr.c index d5dc1f3..f8a65e3 100644 --- a/lib/cache_mngr.c +++ b/lib/cache_mngr.c @@ -32,7 +32,7 @@ * ~~~~ */ -#include +#include #include #include #include diff --git a/lib/cache_mngt.c b/lib/cache_mngt.c index 62cde06..4d3d6ff 100644 --- a/lib/cache_mngt.c +++ b/lib/cache_mngt.c @@ -25,7 +25,7 @@ * ~~~~ */ -#include +#include #include #include #include diff --git a/lib/data.c b/lib/data.c index f019539..1a3a3fb 100644 --- a/lib/data.c +++ b/lib/data.c @@ -27,7 +27,7 @@ * ~~~~ */ -#include +#include #include #include #include diff --git a/lib/error.c b/lib/error.c index e8ee474..f30b9a5 100644 --- a/lib/error.c +++ b/lib/error.c @@ -9,7 +9,7 @@ * Copyright (c) 2008 Thomas Graf */ -#include +#include #include static const char *errmsg[NLE_MAX+1] = { diff --git a/lib/fib_lookup/lookup.c b/lib/fib_lookup/lookup.c index ec82c16..6fe8dae 100644 --- a/lib/fib_lookup/lookup.c +++ b/lib/fib_lookup/lookup.c @@ -16,7 +16,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/fib_lookup/request.c b/lib/fib_lookup/request.c index ffcf8f5..1b021b6 100644 --- a/lib/fib_lookup/request.c +++ b/lib/fib_lookup/request.c @@ -16,7 +16,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/genl/ctrl.c b/lib/genl/ctrl.c index 057a1bf..c6db742 100644 --- a/lib/genl/ctrl.c +++ b/lib/genl/ctrl.c @@ -21,7 +21,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/genl/family.c b/lib/genl/family.c index 05e45ac..897c809 100644 --- a/lib/genl/family.c +++ b/lib/genl/family.c @@ -18,7 +18,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/genl/genl.c b/lib/genl/genl.c index 8d3def3..0c9b11e 100644 --- a/lib/genl/genl.c +++ b/lib/genl/genl.c @@ -15,7 +15,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/genl/mngt.c b/lib/genl/mngt.c index ad25172..a3faaf2 100644 --- a/lib/genl/mngt.c +++ b/lib/genl/mngt.c @@ -18,7 +18,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/handlers.c b/lib/handlers.c index 74276a1..ee1376b 100644 --- a/lib/handlers.c +++ b/lib/handlers.c @@ -25,7 +25,7 @@ * ~~~~ */ -#include +#include #include #include #include diff --git a/lib/hashtable.c b/lib/hashtable.c index ecd5730..8b15925 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -9,7 +9,7 @@ * Copyright (c) 2012 Cumulus Networks, Inc */ #include -#include +#include #include #include #include diff --git a/lib/msg.c b/lib/msg.c index 2613c78..8198ded 100644 --- a/lib/msg.c +++ b/lib/msg.c @@ -26,7 +26,7 @@ * ~~~~ */ -#include +#include #include #include #include diff --git a/lib/netfilter/ct.c b/lib/netfilter/ct.c index 59ee1d9..5dde1d1 100644 --- a/lib/netfilter/ct.c +++ b/lib/netfilter/ct.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/netfilter/ct_obj.c b/lib/netfilter/ct_obj.c index 4686170..bac775b 100644 --- a/lib/netfilter/ct_obj.c +++ b/lib/netfilter/ct_obj.c @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include diff --git a/lib/netfilter/exp.c b/lib/netfilter/exp.c index 5ba2bcb..952ef3a 100644 --- a/lib/netfilter/exp.c +++ b/lib/netfilter/exp.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/netfilter/exp_obj.c b/lib/netfilter/exp_obj.c index 182df23..69b4dd3 100644 --- a/lib/netfilter/exp_obj.c +++ b/lib/netfilter/exp_obj.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include diff --git a/lib/netfilter/log.c b/lib/netfilter/log.c index 96ae6c5..1bab9b6 100644 --- a/lib/netfilter/log.c +++ b/lib/netfilter/log.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/netfilter/log_msg.c b/lib/netfilter/log_msg.c index 65448f9..6e09da2 100644 --- a/lib/netfilter/log_msg.c +++ b/lib/netfilter/log_msg.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/netfilter/log_msg_obj.c b/lib/netfilter/log_msg_obj.c index d2ad0ff..57db9d4 100644 --- a/lib/netfilter/log_msg_obj.c +++ b/lib/netfilter/log_msg_obj.c @@ -11,7 +11,7 @@ * Copyright (c) 2007 Secure Computing Corporation */ -#include +#include #include #include #include diff --git a/lib/netfilter/log_obj.c b/lib/netfilter/log_obj.c index 43c4a06..2b11414 100644 --- a/lib/netfilter/log_obj.c +++ b/lib/netfilter/log_obj.c @@ -12,7 +12,7 @@ * Copyright (c) 2008 Patrick McHardy */ -#include +#include #include #include diff --git a/lib/netfilter/netfilter.c b/lib/netfilter/netfilter.c index addecd7..0062994 100644 --- a/lib/netfilter/netfilter.c +++ b/lib/netfilter/netfilter.c @@ -9,7 +9,7 @@ * Copyright (c) 2008 Patrick McHardy */ -#include +#include #include #include diff --git a/lib/netfilter/nfnl.c b/lib/netfilter/nfnl.c index 6d27c44..f028a85 100644 --- a/lib/netfilter/nfnl.c +++ b/lib/netfilter/nfnl.c @@ -61,7 +61,7 @@ * @{ */ -#include +#include #include #include diff --git a/lib/netfilter/queue.c b/lib/netfilter/queue.c index ff1de0e..5655647 100644 --- a/lib/netfilter/queue.c +++ b/lib/netfilter/queue.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/netfilter/queue_msg.c b/lib/netfilter/queue_msg.c index 30c522f..95d8ad3 100644 --- a/lib/netfilter/queue_msg.c +++ b/lib/netfilter/queue_msg.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/netfilter/queue_msg_obj.c b/lib/netfilter/queue_msg_obj.c index bfaafc5..8085f1b 100644 --- a/lib/netfilter/queue_msg_obj.c +++ b/lib/netfilter/queue_msg_obj.c @@ -9,7 +9,7 @@ * Copyright (c) 2007, 2008 Patrick McHardy */ -#include +#include #include #include #include diff --git a/lib/netfilter/queue_obj.c b/lib/netfilter/queue_obj.c index 05a9cb8..5edcc68 100644 --- a/lib/netfilter/queue_obj.c +++ b/lib/netfilter/queue_obj.c @@ -16,7 +16,7 @@ * @{ */ -#include +#include #include #include diff --git a/lib/nl.c b/lib/nl.c index ec1db01..fa43c56 100644 --- a/lib/nl.c +++ b/lib/nl.c @@ -25,7 +25,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/object.c b/lib/object.c index 7361194..17b98f6 100644 --- a/lib/object.c +++ b/lib/object.c @@ -27,7 +27,7 @@ * ~~~~ */ -#include +#include #include #include #include diff --git a/lib/route/addr.c b/lib/route/addr.c index c5e14bb..95a9447 100644 --- a/lib/route/addr.c +++ b/lib/route/addr.c @@ -106,7 +106,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/route/class.c b/lib/route/class.c index 399e8a2..050f42a 100644 --- a/lib/route/class.c +++ b/lib/route/class.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2011 Thomas Graf + * Copyright (c) 2003-2013 Thomas Graf */ /** @@ -15,10 +15,10 @@ * @{ */ -#include -#include +#include +#include #include -#include +#include #include #include #include diff --git a/lib/route/classid.c b/lib/route/classid.c index 255e075..f2d3a01 100644 --- a/lib/route/classid.c +++ b/lib/route/classid.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf + * Copyright (c) 2010-2013 Thomas Graf */ /** @@ -15,8 +15,8 @@ * @{ */ -#include -#include +#include +#include #include #include #include diff --git a/lib/route/cls.c b/lib/route/cls.c index 35a010a..7a809bb 100644 --- a/lib/route/cls.c +++ b/lib/route/cls.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2011 Thomas Graf + * Copyright (c) 2003-2013 Thomas Graf */ /** @@ -15,11 +15,11 @@ * @{ */ -#include -#include +#include +#include #include #include -#include +#include #include #include diff --git a/lib/route/cls/basic.c b/lib/route/cls/basic.c index 9d7710a..fb1c382 100644 --- a/lib/route/cls/basic.c +++ b/lib/route/cls/basic.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2008-2011 Thomas Graf + * Copyright (c) 2008-2013 Thomas Graf */ /** @@ -22,10 +22,10 @@ * @{ */ -#include -#include +#include +#include #include -#include +#include #include #include #include diff --git a/lib/route/cls/cgroup.c b/lib/route/cls/cgroup.c index 230863b..c5b7561 100644 --- a/lib/route/cls/cgroup.c +++ b/lib/route/cls/cgroup.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2009-2011 Thomas Graf + * Copyright (c) 2009-2013 Thomas Graf */ /** @@ -16,12 +16,12 @@ * @{ */ -#include -#include +#include +#include #include #include #include -#include +#include #include #include #include diff --git a/lib/route/cls/ematch.c b/lib/route/cls/ematch.c index 8c9c3dd..89b5067 100644 --- a/lib/route/cls/ematch.c +++ b/lib/route/cls/ematch.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2008-2010 Thomas Graf + * Copyright (c) 2008-2013 Thomas Graf */ /** @@ -16,8 +16,8 @@ * @{ */ -#include -#include +#include +#include #include #include #include diff --git a/lib/route/cls/ematch/cmp.c b/lib/route/cls/ematch/cmp.c index 2a1070a..2997cdb 100644 --- a/lib/route/cls/ematch/cmp.c +++ b/lib/route/cls/ematch/cmp.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2008-2010 Thomas Graf + * Copyright (c) 2008-2013 Thomas Graf */ /** @@ -16,8 +16,8 @@ * @{ */ -#include -#include +#include +#include #include #include #include diff --git a/lib/route/cls/ematch/container.c b/lib/route/cls/ematch/container.c index 6d73ab6..813391a 100644 --- a/lib/route/cls/ematch/container.c +++ b/lib/route/cls/ematch/container.c @@ -6,11 +6,11 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2008-2010 Thomas Graf + * Copyright (c) 2008-2013 Thomas Graf */ -#include -#include +#include +#include #include #include diff --git a/lib/route/cls/ematch/meta.c b/lib/route/cls/ematch/meta.c index 11f87d6..44f11b9 100644 --- a/lib/route/cls/ematch/meta.c +++ b/lib/route/cls/ematch/meta.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf + * Copyright (c) 2010-2013 Thomas Graf */ /** @@ -16,8 +16,8 @@ * @{ */ -#include -#include +#include +#include #include #include #include diff --git a/lib/route/cls/ematch/nbyte.c b/lib/route/cls/ematch/nbyte.c index 25a9866..8852489 100644 --- a/lib/route/cls/ematch/nbyte.c +++ b/lib/route/cls/ematch/nbyte.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf + * Copyright (c) 2010-2013 Thomas Graf */ /** @@ -16,8 +16,8 @@ * @{ */ -#include -#include +#include +#include #include #include #include diff --git a/lib/route/cls/ematch/text.c b/lib/route/cls/ematch/text.c index 9d0241e..e8cdcae 100644 --- a/lib/route/cls/ematch/text.c +++ b/lib/route/cls/ematch/text.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf + * Copyright (c) 2010-2013 Thomas Graf */ /** @@ -16,8 +16,8 @@ * @{ */ -#include -#include +#include +#include #include #include #include diff --git a/lib/route/cls/ematch_grammar.l b/lib/route/cls/ematch_grammar.l index 07e7e8c..96ef1a0 100644 --- a/lib/route/cls/ematch_grammar.l +++ b/lib/route/cls/ematch_grammar.l @@ -6,12 +6,12 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf + * Copyright (c) 2010-2013 Thomas Graf */ %{ - #include - #include + #include + #include #include #include #include diff --git a/lib/route/cls/ematch_syntax.y b/lib/route/cls/ematch_syntax.y index 39123be..da21039 100644 --- a/lib/route/cls/ematch_syntax.y +++ b/lib/route/cls/ematch_syntax.y @@ -6,12 +6,12 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf + * Copyright (c) 2010-2013 Thomas Graf */ %{ -#include -#include +#include +#include #include #include #include diff --git a/lib/route/cls/fw.c b/lib/route/cls/fw.c index d24779a..b569d4f 100644 --- a/lib/route/cls/fw.c +++ b/lib/route/cls/fw.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2011 Thomas Graf + * Copyright (c) 2003-2013 Thomas Graf * Copyright (c) 2006 Petr Gotthard * Copyright (c) 2006 Siemens AG Oesterreich */ @@ -18,10 +18,10 @@ * @{ */ -#include -#include +#include +#include #include -#include +#include #include #include diff --git a/lib/route/cls/police.c b/lib/route/cls/police.c index d7ab26b..1f5d284 100644 --- a/lib/route/cls/police.c +++ b/lib/route/cls/police.c @@ -6,14 +6,14 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf + * Copyright (c) 2003-2013 Thomas Graf */ -#include -#include +#include +#include #include #include -#include +#include #include #include diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c index aa9eb77..c468ba7 100644 --- a/lib/route/cls/u32.c +++ b/lib/route/cls/u32.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2011 Thomas Graf + * Copyright (c) 2003-2013 Thomas Graf * Copyright (c) 2005-2006 Petr Gotthard * Copyright (c) 2005-2006 Siemens AG Oesterreich */ @@ -18,12 +18,12 @@ * @{ */ -#include -#include +#include +#include #include #include #include -#include +#include #include #include diff --git a/lib/route/link.c b/lib/route/link.c index f817b3a..3171513 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -18,7 +18,7 @@ * @{ */ -#include +#include #include #include #include @@ -26,7 +26,7 @@ #include #include #include -#include +#include /** @cond SKIP */ #define LINK_ATTR_MTU (1 << 0) diff --git a/lib/route/link/api.c b/lib/route/link/api.c index 392ded3..63ff99c 100644 --- a/lib/route/link/api.c +++ b/lib/route/link/api.c @@ -39,11 +39,11 @@ * @{ */ -#include +#include #include #include #include -#include +#include static NL_LIST_HEAD(info_ops); diff --git a/lib/route/link/bonding.c b/lib/route/link/bonding.c index 5e78084..b060ee1 100644 --- a/lib/route/link/bonding.c +++ b/lib/route/link/bonding.c @@ -20,9 +20,9 @@ * @{ */ -#include +#include #include -#include +#include /** * Create a new kernel bonding device diff --git a/lib/route/link/bridge.c b/lib/route/link/bridge.c index cd9f462..52beedd 100644 --- a/lib/route/link/bridge.c +++ b/lib/route/link/bridge.c @@ -9,11 +9,11 @@ * Copyright (c) 2010 Thomas Graf */ -#include +#include #include #include #include -#include +#include #define BRIDGE_ATTR_PORT_STATE 0x0001 diff --git a/lib/route/link/can.c b/lib/route/link/can.c index 4b80d94..76bfa1a 100644 --- a/lib/route/link/can.c +++ b/lib/route/link/can.c @@ -22,13 +22,13 @@ * @{ */ -#include +#include #include #include #include #include #include -#include +#include #include #include diff --git a/lib/route/link/dummy.c b/lib/route/link/dummy.c index c7dabc1..1fd9f5a 100644 --- a/lib/route/link/dummy.c +++ b/lib/route/link/dummy.c @@ -19,9 +19,9 @@ * @{ */ -#include +#include #include -#include +#include static struct rtnl_link_info_ops dummy_info_ops = { .io_name = "dummy", diff --git a/lib/route/link/inet.c b/lib/route/link/inet.c index a0e2318..e2c867d 100644 --- a/lib/route/link/inet.c +++ b/lib/route/link/inet.c @@ -57,11 +57,11 @@ */ -#include +#include #include #include #include -#include +#include /** @cond SKIP */ struct inet_data diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c index 9ee8226..4c627bd 100644 --- a/lib/route/link/inet6.c +++ b/lib/route/link/inet6.c @@ -9,11 +9,11 @@ * Copyright (c) 2010 Thomas Graf */ -#include +#include #include #include #include -#include +#include struct inet6_data { diff --git a/lib/route/link/vlan.c b/lib/route/link/vlan.c index a9bf955..4f44aa5 100644 --- a/lib/route/link/vlan.c +++ b/lib/route/link/vlan.c @@ -22,13 +22,13 @@ * @{ */ -#include +#include #include #include #include #include #include -#include +#include #include #include diff --git a/lib/route/neigh.c b/lib/route/neigh.c index 4a85a85..c0f80a2 100644 --- a/lib/route/neigh.c +++ b/lib/route/neigh.c @@ -148,7 +148,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/route/neightbl.c b/lib/route/neightbl.c index 509617b..f9c9c27 100644 --- a/lib/route/neightbl.c +++ b/lib/route/neightbl.c @@ -16,7 +16,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/route/nexthop.c b/lib/route/nexthop.c index 9990c51..d3ca499 100644 --- a/lib/route/nexthop.c +++ b/lib/route/nexthop.c @@ -15,7 +15,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/route/pktloc.c b/lib/route/pktloc.c index 70d552b..9fcf4a4 100644 --- a/lib/route/pktloc.c +++ b/lib/route/pktloc.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2008-2011 Thomas Graf + * Copyright (c) 2008-2013 Thomas Graf */ /** @@ -31,8 +31,8 @@ * @{ */ -#include -#include +#include +#include #include #include #include diff --git a/lib/route/pktloc_grammar.l b/lib/route/pktloc_grammar.l index 6b7a933..cbb42b3 100644 --- a/lib/route/pktloc_grammar.l +++ b/lib/route/pktloc_grammar.l @@ -1,6 +1,6 @@ %{ - #include - #include + #include + #include #include #include #include diff --git a/lib/route/pktloc_syntax.y b/lib/route/pktloc_syntax.y index 4a2ce48..25d8710 100644 --- a/lib/route/pktloc_syntax.y +++ b/lib/route/pktloc_syntax.y @@ -1,6 +1,6 @@ %{ -#include -#include +#include +#include #include #include #include diff --git a/lib/route/qdisc.c b/lib/route/qdisc.c index 3d618c6..250d191 100644 --- a/lib/route/qdisc.c +++ b/lib/route/qdisc.c @@ -15,12 +15,12 @@ * @{ */ -#include -#include +#include +#include #include #include #include -#include +#include #include #include #include diff --git a/lib/route/qdisc/blackhole.c b/lib/route/qdisc/blackhole.c index 06f5380..339cf78 100644 --- a/lib/route/qdisc/blackhole.c +++ b/lib/route/qdisc/blackhole.c @@ -15,9 +15,9 @@ * @{ */ -#include +#include #include -#include +#include static struct rtnl_tc_ops blackhole_ops = { .to_kind = "blackhole", diff --git a/lib/route/qdisc/cbq.c b/lib/route/qdisc/cbq.c index e791a10..95f1761 100644 --- a/lib/route/qdisc/cbq.c +++ b/lib/route/qdisc/cbq.c @@ -9,11 +9,11 @@ * Copyright (c) 2003-2011 Thomas Graf */ -#include -#include +#include +#include #include #include -#include +#include #include #include #include diff --git a/lib/route/qdisc/dsmark.c b/lib/route/qdisc/dsmark.c index b5fd0d6..fd9553d 100644 --- a/lib/route/qdisc/dsmark.c +++ b/lib/route/qdisc/dsmark.c @@ -16,12 +16,12 @@ * @{ */ -#include -#include +#include +#include #include #include #include -#include +#include #include #include diff --git a/lib/route/qdisc/fifo.c b/lib/route/qdisc/fifo.c index e87c79a..d94c007 100644 --- a/lib/route/qdisc/fifo.c +++ b/lib/route/qdisc/fifo.c @@ -29,10 +29,10 @@ * @{ */ -#include -#include +#include +#include #include -#include +#include #include #include #include diff --git a/lib/route/qdisc/htb.c b/lib/route/qdisc/htb.c index 9fb0bf6..5a61a4e 100644 --- a/lib/route/qdisc/htb.c +++ b/lib/route/qdisc/htb.c @@ -18,12 +18,12 @@ * @{ */ -#include -#include +#include +#include #include #include #include -#include +#include #include #include #include diff --git a/lib/route/qdisc/netem.c b/lib/route/qdisc/netem.c index ddd404d..06d9fe8 100644 --- a/lib/route/qdisc/netem.c +++ b/lib/route/qdisc/netem.c @@ -18,11 +18,11 @@ * @{ */ -#include -#include +#include +#include #include #include -#include +#include #include #include diff --git a/lib/route/qdisc/plug.c b/lib/route/qdisc/plug.c index a99b9be..9f53637 100644 --- a/lib/route/qdisc/plug.c +++ b/lib/route/qdisc/plug.c @@ -60,11 +60,11 @@ * @{ */ -#include -#include +#include +#include #include #include -#include +#include #include static int plug_msg_fill(struct rtnl_tc *tc, void *data, struct nl_msg *msg) diff --git a/lib/route/qdisc/prio.c b/lib/route/qdisc/prio.c index 2433c61..54a46f0 100644 --- a/lib/route/qdisc/prio.c +++ b/lib/route/qdisc/prio.c @@ -26,11 +26,11 @@ * @{ */ -#include -#include +#include +#include #include #include -#include +#include #include #include diff --git a/lib/route/qdisc/red.c b/lib/route/qdisc/red.c index 0480282..f05626e 100644 --- a/lib/route/qdisc/red.c +++ b/lib/route/qdisc/red.c @@ -16,11 +16,11 @@ * @{ */ -#include -#include +#include +#include #include #include -#include +#include #include #include diff --git a/lib/route/qdisc/sfq.c b/lib/route/qdisc/sfq.c index 207140f..acbb4ef 100644 --- a/lib/route/qdisc/sfq.c +++ b/lib/route/qdisc/sfq.c @@ -23,11 +23,11 @@ * @{ */ -#include -#include +#include +#include #include #include -#include +#include #include #include diff --git a/lib/route/qdisc/tbf.c b/lib/route/qdisc/tbf.c index a115548..eb574d9 100644 --- a/lib/route/qdisc/tbf.c +++ b/lib/route/qdisc/tbf.c @@ -15,12 +15,12 @@ * @{ */ -#include -#include +#include +#include #include #include #include -#include +#include #include #include #include diff --git a/lib/route/route.c b/lib/route/route.c index 2218a60..2985187 100644 --- a/lib/route/route.c +++ b/lib/route/route.c @@ -16,7 +16,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c index 0c472b7..8f1e515 100644 --- a/lib/route/route_obj.c +++ b/lib/route/route_obj.c @@ -30,7 +30,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/route/route_utils.c b/lib/route/route_utils.c index 8b73f2b..a5b3966 100644 --- a/lib/route/route_utils.c +++ b/lib/route/route_utils.c @@ -37,7 +37,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/route/rtnl.c b/lib/route/rtnl.c index 12a7e97..82397e9 100644 --- a/lib/route/rtnl.c +++ b/lib/route/rtnl.c @@ -14,7 +14,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/route/rule.c b/lib/route/rule.c index 076ca51..b2161a2 100644 --- a/lib/route/rule.c +++ b/lib/route/rule.c @@ -16,7 +16,7 @@ * @{ */ -#include +#include #include #include #include diff --git a/lib/route/tc.c b/lib/route/tc.c index 5a0b783..29954fd 100644 --- a/lib/route/tc.c +++ b/lib/route/tc.c @@ -15,14 +15,14 @@ * @{ */ -#include -#include +#include +#include #include #include #include #include #include -#include +#include /** @cond SKIP */ diff --git a/lib/socket.c b/lib/socket.c index b30058b..d3e636e 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -29,7 +29,7 @@ #include "defs.h" -#include +#include #include #include #include diff --git a/lib/utils.c b/lib/utils.c index 5511189..3bfa604 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -24,7 +24,7 @@ * ~~~~ */ -#include +#include #include #include #include diff --git a/src/lib/tc.c b/src/lib/tc.c index 26124f1..dde729f 100644 --- a/src/lib/tc.c +++ b/src/lib/tc.c @@ -11,7 +11,7 @@ #include #include -#include +#include /** * @ingroup cli diff --git a/src/nl-list-caches.c b/src/nl-list-caches.c index 14cbab1..853d8a4 100644 --- a/src/nl-list-caches.c +++ b/src/nl-list-caches.c @@ -9,7 +9,7 @@ * Copyright (c) 2003-2009 Thomas Graf */ -#include +#include #include static void print_usage(void) -- cgit v0.12