diff options
Diffstat (limited to 'include/netlink')
59 files changed, 1669 insertions, 694 deletions
diff --git a/include/netlink/.gitignore b/include/netlink/.gitignore new file mode 100644 index 0000000..6702033 --- /dev/null +++ b/include/netlink/.gitignore @@ -0,0 +1 @@ +version.h diff --git a/include/netlink/addr.h b/include/netlink/addr.h index 25fce7e..cc3d201 100644 --- a/include/netlink/addr.h +++ b/include/netlink/addr.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_ADDR_H_ @@ -22,8 +22,9 @@ struct nl_addr; /* Creation */ extern struct nl_addr * nl_addr_alloc(size_t); +extern struct nl_addr * nl_addr_alloc_attr(struct nlattr *, int); extern struct nl_addr * nl_addr_build(int, void *, size_t); -extern struct nl_addr * nl_addr_parse(const char *, int); +extern int nl_addr_parse(const char *, int, struct nl_addr **); extern struct nl_addr * nl_addr_clone(struct nl_addr *); /* Destroyage */ @@ -41,7 +42,7 @@ extern int nl_addr_valid(char *, int); extern int nl_addr_guess_family(struct nl_addr *); extern int nl_addr_fill_sockaddr(struct nl_addr *, struct sockaddr *, socklen_t *); -extern struct addrinfo *nl_addr_info(struct nl_addr *addr); +extern int nl_addr_info(struct nl_addr *, struct addrinfo **); extern int nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen); /* Access Functions */ diff --git a/include/netlink/attr.h b/include/netlink/attr.h index 6160f5f..8479c23 100644 --- a/include/netlink/attr.h +++ b/include/netlink/attr.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_ATTR_H_ @@ -24,228 +24,224 @@ extern "C" { struct nl_msg; /** - * @name Validation Policy Types + * @name Basic Attribute Data Types * @{ */ /** * @ingroup attr - * Standard attribute types to specify validation policy + * Basic attribute data types + * + * See \ref attr_datatypes for more details. */ enum { - NLA_UNSPEC, /**< Unspecified type */ - NLA_U8, /**< 8bit integer */ - NLA_U16, /**< 16bit integer */ - NLA_U32, /**< 32bit integer */ - NLA_U64, /**< 64bit integer */ - NLA_STRING, /**< character string */ - NLA_FLAG, /**< flag */ - NLA_MSECS, /**< micro seconds (64bit) */ - NLA_NESTED, /**< nested attributes */ + NLA_UNSPEC, /**< Unspecified type, binary data chunk */ + NLA_U8, /**< 8 bit integer */ + NLA_U16, /**< 16 bit integer */ + NLA_U32, /**< 32 bit integer */ + NLA_U64, /**< 64 bit integer */ + NLA_STRING, /**< NUL terminated character string */ + NLA_FLAG, /**< Flag */ + NLA_MSECS, /**< Micro seconds (64bit) */ + NLA_NESTED, /**< Nested attributes */ __NLA_TYPE_MAX, }; -/** - * @ingroup attr - * Maximum netlink validation policy type - */ #define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1) /** @} */ /** * @ingroup attr - * attribute validation policy + * Attribute validation policy. * - * Policies are defined as arrays of this struct, the array must - * be accessible by attribute type up to the highest identifier - * to be expected. - * - * Example: - * @code - * static struct nla_policy my_policy[ATTR_MAX+1] __read_mostly = { - * [ATTR_FOO] = { .type = NLA_U16 }, - * [ATTR_BAR] = { .type = NLA_STRING }, - * [ATTR_BAZ] = { .minlen = sizeof(struct mystruct) }, - * }; - * @endcode + * See \ref attr_datatypes for more details. */ struct nla_policy { /** Type of attribute or NLA_UNSPEC */ uint16_t type; - /** Minimal length of payload required to be available */ + /** Minimal length of payload required */ uint16_t minlen; - /** Maximal length of payload required to be available */ + /** Maximal length of payload allowed */ uint16_t maxlen; }; -/* size calculations */ +/* Size calculations */ extern int nla_attr_size(int payload); extern int nla_total_size(int payload); extern int nla_padlen(int payload); -/* payload access */ +/* Attribute parsing */ extern int nla_type(const struct nlattr *); extern void * nla_data(const struct nlattr *); extern int nla_len(const struct nlattr *); - -/* attribute parsing */ extern int nla_ok(const struct nlattr *, int); extern struct nlattr * nla_next(const struct nlattr *, int *); extern int nla_parse(struct nlattr **, int, struct nlattr *, int, struct nla_policy *); -extern int nla_parse_nested(struct nlattr **, int, struct nlattr *, - struct nla_policy *); extern int nla_validate(struct nlattr *, int, int, struct nla_policy *); extern struct nlattr * nla_find(struct nlattr *, int, int); -/* utilities */ +/* Helper Functions */ extern int nla_memcpy(void *, struct nlattr *, int); extern size_t nla_strlcpy(char *, const struct nlattr *, size_t); extern int nla_memcmp(const struct nlattr *, const void *, size_t); extern int nla_strcmp(const struct nlattr *, const char *); -/* attribute construction */ +/* Unspecific attribute */ extern struct nlattr * nla_reserve(struct nl_msg *, int, int); extern int nla_put(struct nl_msg *, int, int, const void *); -extern int nla_put_nested(struct nl_msg *, int, struct nl_msg *); -extern int nla_put_u8(struct nl_msg *, int, uint8_t); -extern int nla_put_u16(struct nl_msg *, int, uint16_t); -extern int nla_put_u32(struct nl_msg *, int, uint32_t); -extern int nla_put_u64(struct nl_msg *, int, uint64_t); -extern int nla_put_string(struct nl_msg *, int, const char *); -extern int nla_put_flag(struct nl_msg *, int); -extern int nla_put_msecs(struct nl_msg *, int, unsigned long); extern int nla_put_data(struct nl_msg *, int, struct nl_data *); extern int nla_put_addr(struct nl_msg *, int, struct nl_addr *); -/* attribute nesting */ -extern struct nlattr * nla_nest_start(struct nl_msg *, int); -extern int nla_nest_end(struct nl_msg *, struct nlattr *); - -/* attribute reading */ +/* Integer attribute */ extern uint8_t nla_get_u8(struct nlattr *); +extern int nla_put_u8(struct nl_msg *, int, uint8_t); extern uint16_t nla_get_u16(struct nlattr *); +extern int nla_put_u16(struct nl_msg *, int, uint16_t); extern uint32_t nla_get_u32(struct nlattr *); +extern int nla_put_u32(struct nl_msg *, int, uint32_t); extern uint64_t nla_get_u64(struct nlattr *); +extern int nla_put_u64(struct nl_msg *, int, uint64_t); + +/* String attribute */ extern char * nla_get_string(struct nlattr *); +extern char * nla_strdup(struct nlattr *); +extern int nla_put_string(struct nl_msg *, int, const char *); + +/* Flag attribute */ extern int nla_get_flag(struct nlattr *); +extern int nla_put_flag(struct nl_msg *, int); + +/* Msec attribute */ extern unsigned long nla_get_msecs(struct nlattr *); -extern struct nl_data * nla_get_data(struct nlattr *); -extern struct nl_addr * nla_get_addr(struct nlattr *, int); +extern int nla_put_msecs(struct nl_msg *, int, unsigned long); + +/* Attribute nesting */ +extern int nla_put_nested(struct nl_msg *, int, struct nl_msg *); +extern struct nlattr * nla_nest_start(struct nl_msg *, int); +extern int nla_nest_end(struct nl_msg *, struct nlattr *); +extern int nla_parse_nested(struct nlattr **, int, struct nlattr *, + struct nla_policy *); /** * @name Attribute Construction (Exception Based) - * - * All these functions jump to nla_put_failure in case of a failure - * instead of returning an error code. - * * @{ */ /** * @ingroup attr - * Add a netlink attribute to a netlink message - * @arg n netlink message - * @arg attrtype attribute type - * @arg attrlen length of attribute payload - * @arg data head of attribute payload + * Add unspecific attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg attrlen Length of attribute payload. + * @arg data Head of attribute payload. */ -#define NLA_PUT(n, attrtype, attrlen, data) \ +#define NLA_PUT(msg, attrtype, attrlen, data) \ do { \ - if (nla_put(n, attrtype, attrlen, data) < 0) \ + if (nla_put(msg, attrtype, attrlen, data) < 0) \ goto nla_put_failure; \ } while(0) /** * @ingroup attr - * Add a basic netlink attribute to a netlink message - * @arg n netlink message - * @arg type atomic type - * @arg attrtype attribute type - * @arg value head of attribute payload + * Add atomic type attribute to netlink message. + * @arg msg Netlink message. + * @arg type Atomic type. + * @arg attrtype Attribute type. + * @arg value Head of attribute payload. */ -#define NLA_PUT_TYPE(n, type, attrtype, value) \ +#define NLA_PUT_TYPE(msg, type, attrtype, value) \ do { \ type __tmp = value; \ - NLA_PUT(n, attrtype, sizeof(type), &__tmp); \ + NLA_PUT(msg, attrtype, sizeof(type), &__tmp); \ } while(0) /** - * Add a u8 netlink attribute to a netlink message - * @arg n netlink message - * @arg attrtype attribute type - * @arg value numeric value + * Add 8 bit integer attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg value Numeric value. */ -#define NLA_PUT_U8(n, attrtype, value) \ - NLA_PUT_TYPE(n, uint8_t, attrtype, value) +#define NLA_PUT_U8(msg, attrtype, value) \ + NLA_PUT_TYPE(msg, uint8_t, attrtype, value) /** - * Add a u16 netlink attribute to a netlink message - * @arg n netlink message - * @arg attrtype attribute type - * @arg value numeric value + * Add 16 bit integer attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg value Numeric value. */ -#define NLA_PUT_U16(n, attrtype, value) \ - NLA_PUT_TYPE(n, uint16_t, attrtype, value) +#define NLA_PUT_U16(msg, attrtype, value) \ + NLA_PUT_TYPE(msg, uint16_t, attrtype, value) /** - * Add a u32 netlink attribute to a netlink message - * @arg n netlink message - * @arg attrtype attribute type - * @arg value numeric value + * Add 32 bit integer attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg value Numeric value. */ -#define NLA_PUT_U32(n, attrtype, value) \ - NLA_PUT_TYPE(n, uint32_t, attrtype, value) +#define NLA_PUT_U32(msg, attrtype, value) \ + NLA_PUT_TYPE(msg, uint32_t, attrtype, value) /** - * Add a u64 netlink attribute to a netlink message - * @arg n netlink message - * @arg attrtype attribute type - * @arg value numeric value + * Add 64 bit integer attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg value Numeric value. */ -#define NLA_PUT_U64(n, attrtype, value) \ - NLA_PUT_TYPE(n, uint64_t, attrtype, value) +#define NLA_PUT_U64(msg, attrtype, value) \ + NLA_PUT_TYPE(msg, uint64_t, attrtype, value) /** - * Add a character string netlink attribute to a netlink message - * @arg n netlink message - * @arg attrtype attribute type - * @arg value character string + * Add string attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg value NUL terminated character string. */ -#define NLA_PUT_STRING(n, attrtype, value) \ - NLA_PUT(n, attrtype, strlen(value) + 1, value) +#define NLA_PUT_STRING(msg, attrtype, value) \ + NLA_PUT(msg, attrtype, strlen(value) + 1, value) /** - * Add a flag netlink attribute to a netlink message - * @arg n netlink message - * @arg attrtype attribute type + * Add flag attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. */ -#define NLA_PUT_FLAG(n, attrtype) \ - NLA_PUT(n, attrtype, 0, NULL) +#define NLA_PUT_FLAG(msg, attrtype) \ + NLA_PUT(msg, attrtype, 0, NULL) /** - * Add a msecs netlink attribute to a netlink message - * @arg n netlink message - * @arg attrtype attribute type - * @arg msecs numeric value in micro seconds + * Add msecs attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg msecs Numeric value in micro seconds. */ -#define NLA_PUT_MSECS(n, attrtype, msecs) \ - NLA_PUT_U64(n, attrtype, msecs) +#define NLA_PUT_MSECS(msg, attrtype, msecs) \ + NLA_PUT_U64(msg, attrtype, msecs) /** - * Add a address attribute to a netlink message - * @arg n netlink message - * @arg attrtype attribute type - * @arg addr abstract address object + * Add address attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg addr Abstract address object. */ -#define NLA_PUT_ADDR(n, attrtype, addr) \ - NLA_PUT(n, attrtype, nl_addr_get_len(addr), \ +#define NLA_PUT_ADDR(msg, attrtype, addr) \ + NLA_PUT(msg, attrtype, nl_addr_get_len(addr), \ nl_addr_get_binary_addr(addr)) +/** + * Add abstract data attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg data Abstract data object. + */ +#define NLA_PUT_DATA(msg, attrtype, data) \ + NLA_PUT(msg, attrtype, nl_data_get_size(data), \ + nl_data_get(data)) + /** @} */ /** @@ -255,7 +251,7 @@ extern struct nl_addr * nla_get_addr(struct nlattr *, int); /** * @ingroup attr - * iterate over a stream of attributes + * Iterate over a stream of attributes * @arg pos loop counter, set to current attribute * @arg head head of attribute stream * @arg len length of attribute stream @@ -268,7 +264,7 @@ extern struct nl_addr * nla_get_addr(struct nlattr *, int); /** * @ingroup attr - * iterate over a stream of nested attributes + * Iterate over a stream of nested attributes * @arg pos loop counter, set to current attribute * @arg nla attribute containing the nested attributes * @arg rem initialized to len, holds bytes currently remaining in stream diff --git a/include/netlink/cache-api.h b/include/netlink/cache-api.h index 96699ed..22fc449 100644 --- a/include/netlink/cache-api.h +++ b/include/netlink/cache-api.h @@ -39,7 +39,7 @@ extern "C" { * // 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_handle *socket) + * 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); @@ -172,7 +172,7 @@ struct nl_cache_ops * 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_handle *); + int (*co_request_update)(struct nl_cache *, struct nl_sock *); /** * Called whenever a message was received that needs to be parsed. diff --git a/include/netlink/cache.h b/include/netlink/cache.h index cb7741b..c752920 100644 --- a/include/netlink/cache.h +++ b/include/netlink/cache.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_CACHE_H_ @@ -24,7 +24,7 @@ extern "C" { struct nl_cache; -typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int); +typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int, void *); /* Access Functions */ extern int nl_cache_nitems(struct nl_cache *); @@ -36,10 +36,12 @@ extern struct nl_object * nl_cache_get_last(struct nl_cache *); extern struct nl_object * nl_cache_get_next(struct nl_object *); extern struct nl_object * nl_cache_get_prev(struct nl_object *); -/* Cache creation/deletion */ -#define nl_cache_alloc_from_ops(ptr) nl_cache_alloc(ptr) extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *); -extern struct nl_cache * nl_cache_alloc_name(const char *); +extern int nl_cache_alloc_and_fill(struct nl_cache_ops *, + struct nl_sock *, + struct nl_cache **); +extern int nl_cache_alloc_name(const char *, + struct nl_cache **); extern struct nl_cache * nl_cache_subset(struct nl_cache *, struct nl_object *); extern void nl_cache_clear(struct nl_cache *); @@ -50,19 +52,19 @@ extern int nl_cache_add(struct nl_cache *, struct nl_object *); extern int nl_cache_parse_and_add(struct nl_cache *, struct nl_msg *); -#define nl_cache_delete(a, b) nl_cache_remove(b) extern void nl_cache_remove(struct nl_object *); -#define nl_cache_update(a, b) nl_cache_refill(a, b) -extern int nl_cache_refill(struct nl_handle *, +extern int nl_cache_refill(struct nl_sock *, struct nl_cache *); -extern int nl_cache_pickup(struct nl_handle *, +extern int nl_cache_pickup(struct nl_sock *, struct nl_cache *); -extern int nl_cache_resync(struct nl_handle *, +extern int nl_cache_resync(struct nl_sock *, struct nl_cache *, - change_func_t); + change_func_t, + void *); extern int nl_cache_include(struct nl_cache *, struct nl_object *, - change_func_t); + change_func_t, + void *); /* General */ extern int nl_cache_is_empty(struct nl_cache *); @@ -106,11 +108,14 @@ struct nl_cache_mngr; #define NL_AUTO_PROVIDE 1 -extern struct nl_cache_mngr * nl_cache_mngr_alloc(struct nl_handle *, - int, int); -extern struct nl_cache * nl_cache_mngr_add(struct nl_cache_mngr *, +extern int nl_cache_mngr_alloc(struct nl_sock *, + int, int, + struct nl_cache_mngr **); +extern int nl_cache_mngr_add(struct nl_cache_mngr *, const char *, - change_func_t); + change_func_t, + void *, + struct nl_cache **); extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *); extern int nl_cache_mngr_poll(struct nl_cache_mngr *, int); diff --git a/include/netlink/cli/addr.h b/include/netlink/cli/addr.h new file mode 100644 index 0000000..d0fd055 --- /dev/null +++ b/include/netlink/cli/addr.h @@ -0,0 +1,32 @@ +/* + * netlink/cli/addr.h CLI Address Helpers + * + * 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) 2008-2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef __NETLINK_CLI_ADDR_H_ +#define __NETLINK_CLI_ADDR_H_ + +#include <netlink/route/addr.h> + +#define nl_cli_addr_alloc_cache(sk) \ + nl_cli_alloc_cache((sk), "address", rtnl_addr_alloc_cache) + +extern struct rtnl_addr *nl_cli_addr_alloc(void); + +extern void nl_cli_addr_parse_family(struct rtnl_addr *, char *); +extern void nl_cli_addr_parse_local(struct rtnl_addr *, char *); +extern void nl_cli_addr_parse_dev(struct rtnl_addr *, struct nl_cache *,char *); +extern void nl_cli_addr_parse_label(struct rtnl_addr *, char *); +extern void nl_cli_addr_parse_peer(struct rtnl_addr *, char *); +extern void nl_cli_addr_parse_scope(struct rtnl_addr *, char *); +extern void nl_cli_addr_parse_broadcast(struct rtnl_addr *, char *); +extern void nl_cli_addr_parse_preferred(struct rtnl_addr *, char *); +extern void nl_cli_addr_parse_valid(struct rtnl_addr *, char *); + +#endif diff --git a/include/netlink/cli/ct.h b/include/netlink/cli/ct.h new file mode 100644 index 0000000..bed776b --- /dev/null +++ b/include/netlink/cli/ct.h @@ -0,0 +1,34 @@ +/* + * netlink/cli/ct.h CLI Conntrack Helper + * + * 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) 2008-2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef __NETLINK_CLI_CT_H_ +#define __NETLINK_CLI_CT_H_ + +#include <netlink/netfilter/ct.h> +#include <linux/netfilter/nf_conntrack_common.h> + +extern struct nfnl_ct *nl_cli_ct_alloc(void); +extern struct nl_cache *nl_cli_ct_alloc_cache(struct nl_sock *); + +extern void nl_cli_ct_parse_family(struct nfnl_ct *, char *); +extern void nl_cli_ct_parse_protocol(struct nfnl_ct *, char *); +extern void nl_cli_ct_parse_mark(struct nfnl_ct *, char *); +extern void nl_cli_ct_parse_timeout(struct nfnl_ct *, char *); +extern void nl_cli_ct_parse_id(struct nfnl_ct *, char *); +extern void nl_cli_ct_parse_use(struct nfnl_ct *, char *); +extern void nl_cli_ct_parse_src(struct nfnl_ct *, int, char *); +extern void nl_cli_ct_parse_dst(struct nfnl_ct *, int, char *); +extern void nl_cli_ct_parse_src_port(struct nfnl_ct *, int, char *); +extern void nl_cli_ct_parse_dst_port(struct nfnl_ct *, int, char *); +extern void nl_cli_ct_parse_tcp_state(struct nfnl_ct *, char *); +extern void nl_cli_ct_parse_status(struct nfnl_ct *, char *); + +#endif diff --git a/include/netlink/cli/link.h b/include/netlink/cli/link.h new file mode 100644 index 0000000..c404019 --- /dev/null +++ b/include/netlink/cli/link.h @@ -0,0 +1,30 @@ +/* + * netlink/cli/link.h CLI Link Helpers + * + * 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) 2008-2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef __NETLINK_CLI_LINK_H_ +#define __NETLINK_CLI_LINK_H_ + +#include <netlink/route/link.h> +#include <netlink/cli/utils.h> + +#define nl_cli_link_alloc_cache(sk) \ + nl_cli_alloc_cache((sk), "link", rtnl_link_alloc_cache) + +extern struct rtnl_link *nl_cli_link_alloc(void); + +extern void nl_cli_link_parse_family(struct rtnl_link *, char *); +extern void nl_cli_link_parse_name(struct rtnl_link *, char *); +extern void nl_cli_link_parse_mtu(struct rtnl_link *, char *); +extern void nl_cli_link_parse_ifindex(struct rtnl_link *, char *); +extern void nl_cli_link_parse_txqlen(struct rtnl_link *, char *); +extern void nl_cli_link_parse_weight(struct rtnl_link *, char *); + +#endif diff --git a/include/netlink/cli/neigh.h b/include/netlink/cli/neigh.h new file mode 100644 index 0000000..5440012 --- /dev/null +++ b/include/netlink/cli/neigh.h @@ -0,0 +1,27 @@ +/* + * netlink/cli/neighbour.h CLI Neighbour Helpers + * + * 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) 2008-2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef __NETLINK_CLI_NEIGH_H_ +#define __NETLINK_CLI_NEIGH_H_ + +#include <netlink/route/neighbour.h> + +#define nl_cli_neigh_alloc_cache(sk) \ + nl_cli_alloc_cache((sk), "neighbour", rtnl_neigh_alloc_cache) + +extern struct rtnl_neigh *nl_cli_neigh_alloc(void); +extern void nl_cli_neigh_parse_dst(struct rtnl_neigh *, char *); +extern void nl_cli_neigh_parse_lladdr(struct rtnl_neigh *, char *); +extern void nl_cli_neigh_parse_dev(struct rtnl_neigh *, struct nl_cache *, char *); +extern void nl_cli_neigh_parse_family(struct rtnl_neigh *, char *); +extern void nl_cli_neigh_parse_state(struct rtnl_neigh *, char *); + +#endif diff --git a/include/netlink/cli/qdisc.h b/include/netlink/cli/qdisc.h new file mode 100644 index 0000000..9fc4506 --- /dev/null +++ b/include/netlink/cli/qdisc.h @@ -0,0 +1,28 @@ +/* + * netlink/cli/qdisc.h CLI QDisc Helpers + * + * 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) 2008-2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef __NETLINK_CLI_QDISC_H_ +#define __NETLINK_CLI_QDISC_H_ + +#include <netlink/route/qdisc.h> + +#define nl_cli_qdisc_alloc_cache(sk) \ + nl_cli_alloc_cache((sk), "queueing disciplines", \ + rtnl_qdisc_alloc_cache) + +extern struct rtnl_qdisc *nl_cli_qdisc_alloc(void); + +extern void nl_cli_qdisc_parse_dev(struct rtnl_qdisc *, struct nl_cache *, char *); +extern void nl_cli_qdisc_parse_parent(struct rtnl_qdisc *, char *); +extern void nl_cli_qdisc_parse_handle(struct rtnl_qdisc *, char *); +extern void nl_cli_qdisc_parse_kind(struct rtnl_qdisc *, char *); + +#endif diff --git a/include/netlink/cli/route.h b/include/netlink/cli/route.h new file mode 100644 index 0000000..089c658 --- /dev/null +++ b/include/netlink/cli/route.h @@ -0,0 +1,34 @@ +/* + * netlink/cli//route.h CLI Route Helpers + * + * 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) 2008-2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef __NETLINK_CLI_ROUTE_H_ +#define __NETLINK_CLI_ROUTE_H_ + +#include <netlink/route/route.h> + +extern struct rtnl_route *nl_cli_route_alloc(void); + +extern struct nl_cache *nl_cli_route_alloc_cache(struct nl_sock *, int); + +extern void nl_cli_route_parse_family(struct rtnl_route *, char *); +extern void nl_cli_route_parse_dst(struct rtnl_route *, char *); +extern void nl_cli_route_parse_src(struct rtnl_route *, char *); +extern void nl_cli_route_parse_pref_src(struct rtnl_route *, char *); +extern void nl_cli_route_parse_metric(struct rtnl_route *, char *); +extern void nl_cli_route_parse_nexthop(struct rtnl_route *, char *, struct nl_cache *); +extern void nl_cli_route_parse_table(struct rtnl_route *, char *); +extern void nl_cli_route_parse_prio(struct rtnl_route *, char *); +extern void nl_cli_route_parse_scope(struct rtnl_route *, char *); +extern void nl_cli_route_parse_protocol(struct rtnl_route *, char *); +extern void nl_cli_route_parse_type(struct rtnl_route *, char *); +extern void nl_cli_route_parse_iif(struct rtnl_route *, char *, struct nl_cache *); + +#endif diff --git a/include/netlink/cli/rule.h b/include/netlink/cli/rule.h new file mode 100644 index 0000000..61cd63e --- /dev/null +++ b/include/netlink/cli/rule.h @@ -0,0 +1,21 @@ +/* + * netlink/cli/rule.h CLI Routing Rule Helpers + * + * 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) 2008-2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef __NETLINK_CLI_RULE_H_ +#define __NETLINK_CLI_RULE_H_ + +#include <netlink/route/rule.h> + +extern struct rtnl_rule *nl_cli_rule_alloc(void); +extern struct nl_cache *nl_cli_rule_alloc_cache(struct nl_sock *); +extern void nl_cli_rule_parse_family(struct rtnl_rule *, char *); + +#endif diff --git a/include/netlink/cli/utils.h b/include/netlink/cli/utils.h new file mode 100644 index 0000000..2a23208 --- /dev/null +++ b/include/netlink/cli/utils.h @@ -0,0 +1,80 @@ +/* + * src/utils.h Utilities + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef __NETLINK_CLI_UTILS_H_ +#define __NETLINK_CLI_UTILS_H_ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdarg.h> +#include <limits.h> +#include <inttypes.h> +#include <errno.h> +#include <stdint.h> +#include <ctype.h> +#include <getopt.h> +#include <dlfcn.h> +#include <sys/types.h> +#include <sys/socket.h> + +#include <netlink/netlink.h> +#include <netlink/utils.h> +#include <netlink/addr.h> +#include <netlink/list.h> +#include <netlink/route/rtnl.h> +#include <netlink/route/link.h> +#include <netlink/route/addr.h> +#include <netlink/route/neighbour.h> +#include <netlink/route/neightbl.h> +#include <netlink/route/route.h> +#include <netlink/route/rule.h> +#include <netlink/route/qdisc.h> +#include <netlink/route/class.h> +#include <netlink/route/classifier.h> +#include <netlink/route/cls/ematch.h> +#include <netlink/fib_lookup/lookup.h> +#include <netlink/fib_lookup/request.h> +#include <netlink/genl/genl.h> +#include <netlink/genl/ctrl.h> +#include <netlink/genl/mngt.h> +#include <netlink/netfilter/ct.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __init +#define __init __attribute__((constructor)) +#endif + +#ifndef __exit +#define __exit __attribute__((destructor)) +#endif + +extern uint32_t nl_cli_parse_u32(const char *); +extern void nl_cli_print_version(void); +extern void nl_cli_fatal(int, const char *, ...); +extern struct nl_addr * nl_cli_addr_parse(const char *, int); +extern int nl_cli_connect(struct nl_sock *, int); +extern struct nl_sock * nl_cli_alloc_socket(void); +extern int nl_cli_parse_dumptype(const char *); +extern int nl_cli_confirm(struct nl_object *, + struct nl_dump_params *, int); + +extern struct nl_cache *nl_cli_alloc_cache(struct nl_sock *, const char *, + int (*ac)(struct nl_sock *, struct nl_cache **)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink/data.h b/include/netlink/data.h index bb28d13..071159e 100644 --- a/include/netlink/data.h +++ b/include/netlink/data.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_DATA_H_ @@ -22,6 +22,7 @@ struct nl_data; /* General */ extern struct nl_data * nl_data_alloc(void *, size_t); +extern struct nl_data * nl_data_alloc_attr(struct nlattr *); extern struct nl_data * nl_data_clone(struct nl_data *); extern int nl_data_append(struct nl_data *, void *, size_t); extern void nl_data_free(struct nl_data *); diff --git a/include/netlink/errno.h b/include/netlink/errno.h new file mode 100644 index 0000000..c8a376e --- /dev/null +++ b/include/netlink/errno.h @@ -0,0 +1,60 @@ +/* + * netlink/errno.h Error Numbers + * + * 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) 2008 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef NETLINK_ERRNO_H_ +#define NETLINK_ERRNO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NLE_SUCCESS 0 +#define NLE_FAILURE 1 +#define NLE_INTR 2 +#define NLE_BAD_SOCK 3 +#define NLE_AGAIN 4 +#define NLE_NOMEM 5 +#define NLE_EXIST 6 +#define NLE_INVAL 7 +#define NLE_RANGE 8 +#define NLE_MSGSIZE 9 +#define NLE_OPNOTSUPP 10 +#define NLE_AF_NOSUPPORT 11 +#define NLE_OBJ_NOTFOUND 12 +#define NLE_NOATTR 13 +#define NLE_MISSING_ATTR 14 +#define NLE_AF_MISMATCH 15 +#define NLE_SEQ_MISMATCH 16 +#define NLE_MSG_OVERFLOW 17 +#define NLE_MSG_TRUNC 18 +#define NLE_NOADDR 19 +#define NLE_SRCRT_NOSUPPORT 20 +#define NLE_MSG_TOOSHORT 21 +#define NLE_MSGTYPE_NOSUPPORT 22 +#define NLE_OBJ_MISMATCH 23 +#define NLE_NOCACHE 24 +#define NLE_BUSY 25 +#define NLE_PROTO_MISMATCH 26 +#define NLE_NOACCESS 27 +#define NLE_PERM 28 +#define NLE_PKTLOC_FILE 29 + +#define NLE_MAX NLE_PKTLOC_FILE + +extern const char * nl_geterror(int); +extern void nl_perror(int, const char *); +extern int nl_syserr2nlerr(int); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink/fib_lookup/lookup.h b/include/netlink/fib_lookup/lookup.h index 29c7ee8..8bf27b8 100644 --- a/include/netlink/fib_lookup/lookup.h +++ b/include/netlink/fib_lookup/lookup.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_FIB_LOOKUP_H_ @@ -28,9 +28,10 @@ extern void flnl_result_put(struct flnl_result *); extern struct nl_cache * flnl_result_alloc_cache(void); -extern struct nl_msg * flnl_lookup_build_request(struct flnl_request *, - int); -extern int flnl_lookup(struct nl_handle *, +extern int flnl_lookup_build_request(struct flnl_request *, + int, + struct nl_msg **); +extern int flnl_lookup(struct nl_sock *, struct flnl_request *, struct nl_cache *); diff --git a/include/netlink/genl/ctrl.h b/include/netlink/genl/ctrl.h index 5d65c68..1ae62f4 100644 --- a/include/netlink/genl/ctrl.h +++ b/include/netlink/genl/ctrl.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_GENL_CTRL_H_ @@ -22,11 +22,12 @@ extern "C" { struct genl_family; -extern struct nl_cache * genl_ctrl_alloc_cache(struct nl_handle *); +extern int genl_ctrl_alloc_cache(struct nl_sock *, + struct nl_cache **); extern struct genl_family * genl_ctrl_search(struct nl_cache *, int); extern struct genl_family * genl_ctrl_search_by_name(struct nl_cache *, const char *); -extern int genl_ctrl_resolve(struct nl_handle *, +extern int genl_ctrl_resolve(struct nl_sock *, const char *); #ifdef __cplusplus diff --git a/include/netlink/genl/genl.h b/include/netlink/genl/genl.h index de142d0..3f3340c 100644 --- a/include/netlink/genl/genl.h +++ b/include/netlink/genl/genl.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_GENL_H_ @@ -20,9 +20,9 @@ extern "C" { #endif -extern int genl_connect(struct nl_handle *); +extern int genl_connect(struct nl_sock *); -extern int genl_send_simple(struct nl_handle *, int, int, +extern int genl_send_simple(struct nl_sock *, int, int, int, int); extern void * genlmsg_put(struct nl_msg *, uint32_t, uint32_t, diff --git a/include/netlink/genl/mngt.h b/include/netlink/genl/mngt.h index 467922a..8b0244f 100644 --- a/include/netlink/genl/mngt.h +++ b/include/netlink/genl/mngt.h @@ -22,6 +22,15 @@ extern "C" { struct nl_cache_ops; +struct genl_info +{ + struct sockaddr_nl * who; + struct nlmsghdr * nlh; + struct genlmsghdr * genlhdr; + void * userhdr; + struct nlattr ** attrs; +}; + /** * @ingroup genl_mngt * Generic Netlink Command diff --git a/include/netlink/handlers.h b/include/netlink/handlers.h index fcd3e48..f373f58 100644 --- a/include/netlink/handlers.h +++ b/include/netlink/handlers.h @@ -23,8 +23,9 @@ extern "C" { #endif struct nl_cb; -struct nl_handle; +struct nl_sock; struct nl_msg; +struct ucred; /** * @name Callback Typedefs @@ -64,10 +65,6 @@ enum nl_cb_action { NL_STOP, }; -/* backwards compatibility */ -#define NL_PROCEED NL_OK -#define NL_EXIT NL_STOP - /** * Callback kinds * @ingroup cb @@ -129,15 +126,15 @@ extern int nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t, void *); extern void nl_cb_overwrite_recvmsgs(struct nl_cb *, - int (*func)(struct nl_handle *, + int (*func)(struct nl_sock *, struct nl_cb *)); extern void nl_cb_overwrite_recv(struct nl_cb *, - int (*func)(struct nl_handle *, + int (*func)(struct nl_sock *, struct sockaddr_nl *, unsigned char **, struct ucred **)); extern void nl_cb_overwrite_send(struct nl_cb *, - int (*func)(struct nl_handle *, + int (*func)(struct nl_sock *, struct nl_msg *)); #ifdef __cplusplus diff --git a/include/netlink/list.h b/include/netlink/list.h index e7a2646..28712ed 100644 --- a/include/netlink/list.h +++ b/include/netlink/list.h @@ -18,6 +18,11 @@ struct nl_list_head struct nl_list_head * prev; }; +static inline void NL_INIT_LIST_HEAD(struct nl_list_head *list) +{ + list->next = list; + list->prev = list; +} static inline void __nl_list_add(struct nl_list_head *obj, struct nl_list_head *prev, @@ -68,6 +73,9 @@ static inline int nl_list_empty(struct nl_list_head *head) #define NL_LIST_HEAD(name) \ struct nl_list_head name = { &(name), &(name) } +#define nl_list_first_entry(head, type, member) \ + nl_list_entry((head)->next, type, member) + #define nl_list_for_each_entry(pos, head, member) \ for (pos = nl_list_entry((head)->next, typeof(*pos), member); \ &(pos)->member != (head); \ diff --git a/include/netlink/msg.h b/include/netlink/msg.h index 732e66f..e331f42 100644 --- a/include/netlink/msg.h +++ b/include/netlink/msg.h @@ -68,11 +68,6 @@ extern struct nlattr * nlmsg_find_attr(struct nlmsghdr *, int, int); extern int nlmsg_validate(struct nlmsghdr *, int, int, struct nla_policy *); -/* Backward compatibility */ -#define nlmsg_new() nlmsg_alloc() -#define nlmsg_build_simple(a, b) nlmsg_alloc_simple(a, b) -#define nlmsg_build(ptr) nlmsg_inherit(ptr) - extern struct nl_msg * nlmsg_alloc(void); extern struct nl_msg * nlmsg_alloc_size(size_t); extern struct nl_msg * nlmsg_alloc_simple(int, int); @@ -86,6 +81,7 @@ extern int nlmsg_expand(struct nl_msg *, size_t); extern struct nlmsghdr * nlmsg_put(struct nl_msg *, uint32_t, uint32_t, int, int, int); extern struct nlmsghdr * nlmsg_hdr(struct nl_msg *); +extern void nlmsg_get(struct nl_msg *); extern void nlmsg_free(struct nl_msg *); /* attribute modification */ diff --git a/include/netlink/netfilter/ct.h b/include/netlink/netfilter/ct.h index 965b869..c4402b3 100644 --- a/include/netlink/netfilter/ct.h +++ b/include/netlink/netfilter/ct.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> * Copyright (c) 2007 Philip Craig <philipc@snapgear.com> * Copyright (c) 2007 Secure Computing Corporation */ @@ -27,86 +27,97 @@ struct nfnl_ct; extern struct nl_object_ops ct_obj_ops; -/* General */ extern struct nfnl_ct * nfnl_ct_alloc(void); -extern struct nl_cache *nfnl_ct_alloc_cache(struct nl_handle *); +extern int nfnl_ct_alloc_cache(struct nl_sock *, struct nl_cache **); -extern int nfnlmsg_ct_group(struct nlmsghdr *); -extern struct nfnl_ct * nfnlmsg_ct_parse(struct nlmsghdr *); +extern int nfnlmsg_ct_group(struct nlmsghdr *); +extern int nfnlmsg_ct_parse(struct nlmsghdr *, struct nfnl_ct **); -extern void nfnl_ct_get(struct nfnl_ct *); -extern void nfnl_ct_put(struct nfnl_ct *); +extern void nfnl_ct_get(struct nfnl_ct *); +extern void nfnl_ct_put(struct nfnl_ct *); -extern int nfnl_ct_dump_request(struct nl_handle *); +extern int nfnl_ct_dump_request(struct nl_sock *); -extern void nfnl_ct_set_family(struct nfnl_ct *, uint8_t); -extern uint8_t nfnl_ct_get_family(const struct nfnl_ct *); +extern int nfnl_ct_build_add_request(const struct nfnl_ct *, int, + struct nl_msg **); +extern int nfnl_ct_add(struct nl_sock *, const struct nfnl_ct *, int); -extern void nfnl_ct_set_proto(struct nfnl_ct *, uint8_t); -extern int nfnl_ct_test_proto(const struct nfnl_ct *); -extern uint8_t nfnl_ct_get_proto(const struct nfnl_ct *); +extern int nfnl_ct_build_delete_request(const struct nfnl_ct *, int, + struct nl_msg **); +extern int nfnl_ct_delete(struct nl_sock *, const struct nfnl_ct *, int); -extern void nfnl_ct_set_tcp_state(struct nfnl_ct *, uint8_t); -extern int nfnl_ct_test_tcp_state(const struct nfnl_ct *); -extern uint8_t nfnl_ct_get_tcp_state(const struct nfnl_ct *); -extern char * nfnl_ct_tcp_state2str(uint8_t, char *, size_t); -extern int nfnl_ct_str2tcp_state(const char *name); +extern int nfnl_ct_build_query_request(const struct nfnl_ct *, int, + struct nl_msg **); +extern int nfnl_ct_query(struct nl_sock *, const struct nfnl_ct *, int); -extern void nfnl_ct_set_status(struct nfnl_ct *, uint32_t); -extern void nfnl_ct_unset_status(struct nfnl_ct *, uint32_t); -extern uint32_t nfnl_ct_get_status(const struct nfnl_ct *); +extern void nfnl_ct_set_family(struct nfnl_ct *, uint8_t); +extern uint8_t nfnl_ct_get_family(const struct nfnl_ct *); -extern void nfnl_ct_set_timeout(struct nfnl_ct *, uint32_t); -extern int nfnl_ct_test_timeout(const struct nfnl_ct *); -extern uint32_t nfnl_ct_get_timeout(const struct nfnl_ct *); +extern void nfnl_ct_set_proto(struct nfnl_ct *, uint8_t); +extern int nfnl_ct_test_proto(const struct nfnl_ct *); +extern uint8_t nfnl_ct_get_proto(const struct nfnl_ct *); -extern void nfnl_ct_set_mark(struct nfnl_ct *, uint32_t); -extern int nfnl_ct_test_mark(const struct nfnl_ct *); -extern uint32_t nfnl_ct_get_mark(const struct nfnl_ct *); +extern void nfnl_ct_set_tcp_state(struct nfnl_ct *, uint8_t); +extern int nfnl_ct_test_tcp_state(const struct nfnl_ct *); +extern uint8_t nfnl_ct_get_tcp_state(const struct nfnl_ct *); +extern char * nfnl_ct_tcp_state2str(uint8_t, char *, size_t); +extern int nfnl_ct_str2tcp_state(const char *name); -extern void nfnl_ct_set_use(struct nfnl_ct *, uint32_t); -extern int nfnl_ct_test_use(const struct nfnl_ct *); -extern uint32_t nfnl_ct_get_use(const struct nfnl_ct *); +extern void nfnl_ct_set_status(struct nfnl_ct *, uint32_t); +extern void nfnl_ct_unset_status(struct nfnl_ct *, uint32_t); +extern uint32_t nfnl_ct_get_status(const struct nfnl_ct *); +extern char * nfnl_ct_status2str(int, char *, size_t); +extern int nfnl_ct_str2status(const char *); -extern void nfnl_ct_set_id(struct nfnl_ct *, uint32_t); -extern int nfnl_ct_test_id(const struct nfnl_ct *); -extern uint32_t nfnl_ct_get_id(const struct nfnl_ct *); +extern void nfnl_ct_set_timeout(struct nfnl_ct *, uint32_t); +extern int nfnl_ct_test_timeout(const struct nfnl_ct *); +extern uint32_t nfnl_ct_get_timeout(const struct nfnl_ct *); -extern int nfnl_ct_set_src(struct nfnl_ct *, int, - struct nl_addr *); +extern void nfnl_ct_set_mark(struct nfnl_ct *, uint32_t); +extern int nfnl_ct_test_mark(const struct nfnl_ct *); +extern uint32_t nfnl_ct_get_mark(const struct nfnl_ct *); + +extern void nfnl_ct_set_use(struct nfnl_ct *, uint32_t); +extern int nfnl_ct_test_use(const struct nfnl_ct *); +extern uint32_t nfnl_ct_get_use(const struct nfnl_ct *); + +extern void nfnl_ct_set_id(struct nfnl_ct *, uint32_t); +extern int nfnl_ct_test_id(const struct nfnl_ct *); +extern uint32_t nfnl_ct_get_id(const struct nfnl_ct *); + +extern int nfnl_ct_set_src(struct nfnl_ct *, int, struct nl_addr *); extern struct nl_addr * nfnl_ct_get_src(const struct nfnl_ct *, int); -extern int nfnl_ct_set_dst(struct nfnl_ct *, int, - struct nl_addr *); +extern int nfnl_ct_set_dst(struct nfnl_ct *, int, struct nl_addr *); extern struct nl_addr * nfnl_ct_get_dst(const struct nfnl_ct *, int); -extern void nfnl_ct_set_src_port(struct nfnl_ct *, int, uint16_t); -extern int nfnl_ct_test_src_port(const struct nfnl_ct *, int); -extern uint16_t nfnl_ct_get_src_port(const struct nfnl_ct *, int); +extern void nfnl_ct_set_src_port(struct nfnl_ct *, int, uint16_t); +extern int nfnl_ct_test_src_port(const struct nfnl_ct *, int); +extern uint16_t nfnl_ct_get_src_port(const struct nfnl_ct *, int); -extern void nfnl_ct_set_dst_port(struct nfnl_ct *, int, uint16_t); -extern int nfnl_ct_test_dst_port(const struct nfnl_ct *, int); -extern uint16_t nfnl_ct_get_dst_port(const struct nfnl_ct *, int); +extern void nfnl_ct_set_dst_port(struct nfnl_ct *, int, uint16_t); +extern int nfnl_ct_test_dst_port(const struct nfnl_ct *, int); +extern uint16_t nfnl_ct_get_dst_port(const struct nfnl_ct *, int); -extern void nfnl_ct_set_icmp_id(struct nfnl_ct *, int, uint16_t); -extern int nfnl_ct_test_icmp_id(const struct nfnl_ct *, int); -extern uint16_t nfnl_ct_get_icmp_id(const struct nfnl_ct *, int); +extern void nfnl_ct_set_icmp_id(struct nfnl_ct *, int, uint16_t); +extern int nfnl_ct_test_icmp_id(const struct nfnl_ct *, int); +extern uint16_t nfnl_ct_get_icmp_id(const struct nfnl_ct *, int); -extern void nfnl_ct_set_icmp_type(struct nfnl_ct *, int, uint8_t); -extern int nfnl_ct_test_icmp_type(const struct nfnl_ct *, int); -extern uint8_t nfnl_ct_get_icmp_type(const struct nfnl_ct *, int); +extern void nfnl_ct_set_icmp_type(struct nfnl_ct *, int, uint8_t); +extern int nfnl_ct_test_icmp_type(const struct nfnl_ct *, int); +extern uint8_t nfnl_ct_get_icmp_type(const struct nfnl_ct *, int); -extern void nfnl_ct_set_icmp_code(struct nfnl_ct *, int, uint8_t); -extern int nfnl_ct_test_icmp_code(const struct nfnl_ct *, int); -extern uint8_t nfnl_ct_get_icmp_code(const struct nfnl_ct *, int); +extern void nfnl_ct_set_icmp_code(struct nfnl_ct *, int, uint8_t); +extern int nfnl_ct_test_icmp_code(const struct nfnl_ct *, int); +extern uint8_t nfnl_ct_get_icmp_code(const struct nfnl_ct *, int); -extern void nfnl_ct_set_packets(struct nfnl_ct *, int, uint64_t); -extern int nfnl_ct_test_packets(const struct nfnl_ct *, int); -extern uint64_t nfnl_ct_get_packets(const struct nfnl_ct *,int); +extern void nfnl_ct_set_packets(struct nfnl_ct *, int, uint64_t); +extern int nfnl_ct_test_packets(const struct nfnl_ct *, int); +extern uint64_t nfnl_ct_get_packets(const struct nfnl_ct *,int); -extern void nfnl_ct_set_bytes(struct nfnl_ct *, int, uint64_t); -extern int nfnl_ct_test_bytes(const struct nfnl_ct *, int); -extern uint64_t nfnl_ct_get_bytes(const struct nfnl_ct *, int); +extern void nfnl_ct_set_bytes(struct nfnl_ct *, int, uint64_t); +extern int nfnl_ct_test_bytes(const struct nfnl_ct *, int); +extern uint64_t nfnl_ct_get_bytes(const struct nfnl_ct *, int); #ifdef __cplusplus } diff --git a/include/netlink/netfilter/log.h b/include/netlink/netfilter/log.h index e65cc58..2002fa8 100644 --- a/include/netlink/netfilter/log.h +++ b/include/netlink/netfilter/log.h @@ -9,6 +9,7 @@ * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> * Copyright (c) 2007 Philip Craig <philipc@snapgear.com> * Copyright (c) 2007 Secure Computing Corporation + * Copyright (c) 2008 Patrick McHardy <kaber@trash.net> */ #ifndef NETLINK_LOG_H_ @@ -20,82 +21,85 @@ extern "C" { #endif -struct nl_handle; +struct nl_sock; struct nlmsghdr; struct nfnl_log; extern struct nl_object_ops log_obj_ops; -/* General */ -extern struct nfnl_log *nfnl_log_alloc(void); -extern struct nfnl_log *nfnlmsg_log_parse(struct nlmsghdr *); +enum nfnl_log_copy_mode { + NFNL_LOG_COPY_NONE, + NFNL_LOG_COPY_META, + NFNL_LOG_COPY_PACKET, +}; -extern void nfnl_log_get(struct nfnl_log *); -extern void nfnl_log_put(struct nfnl_log *); +enum nfnl_log_flags { + NFNL_LOG_FLAG_SEQ = 0x1, + NFNL_LOG_FLAG_SEQ_GLOBAL = 0x2, +}; -extern struct nl_msg * nfnl_log_build_bind(uint16_t);; -extern int nfnl_log_bind(struct nl_handle *, uint16_t); -extern struct nl_msg * nfnl_log_build_unbind(uint16_t); -extern int nfnl_log_unbind(struct nl_handle *, uint16_t); -extern struct nl_msg * nfnl_log_build_pf_bind(uint8_t); -extern int nfnl_log_pf_bind(struct nl_handle *, uint8_t); -extern struct nl_msg * nfnl_log_build_pf_unbind(uint8_t); -extern int nfnl_log_pf_unbind(struct nl_handle *, uint8_t); -extern struct nl_msg * nfnl_log_build_mode(uint16_t, uint8_t, uint32_t); -extern int nfnl_log_set_mode(struct nl_handle *, uint16_t, - uint8_t, uint32_t); +/* General */ +extern struct nfnl_log * nfnl_log_alloc(void); +extern int nfnlmsg_log_parse(struct nlmsghdr *, + struct nfnl_log **); -extern void nfnl_log_set_family(struct nfnl_log *, uint8_t); -extern uint8_t nfnl_log_get_family(const struct nfnl_log *); +extern void nfnl_log_get(struct nfnl_log *); +extern void nfnl_log_put(struct nfnl_log *); -extern void nfnl_log_set_hwproto(struct nfnl_log *, uint16_t); -extern int nfnl_log_test_hwproto(const struct nfnl_log *); -extern uint16_t nfnl_log_get_hwproto(const struct nfnl_log *); +/* Attributes */ +extern void nfnl_log_set_group(struct nfnl_log *, uint16_t); +extern int nfnl_log_test_group(const struct nfnl_log *); +extern uint16_t nfnl_log_get_group(const struct nfnl_log *); -extern void nfnl_log_set_hook(struct nfnl_log *, uint8_t); -extern int nfnl_log_test_hook(const struct nfnl_log *); -extern uint8_t nfnl_log_get_hook(const struct nfnl_log *); +extern void nfnl_log_set_copy_mode(struct nfnl_log *, + enum nfnl_log_copy_mode); +extern int nfnl_log_test_copy_mode(const struct nfnl_log *); +extern enum nfnl_log_copy_mode nfnl_log_get_copy_mode(const struct nfnl_log *); -extern void nfnl_log_set_mark(struct nfnl_log *, uint32_t); -extern int nfnl_log_test_mark(const struct nfnl_log *); -extern uint32_t nfnl_log_get_mark(const struct nfnl_log *); +extern char * nfnl_log_copy_mode2str(enum nfnl_log_copy_mode, + char *, size_t); +extern enum nfnl_log_copy_mode nfnl_log_str2copy_mode(const char *); -extern void nfnl_log_set_timestamp(struct nfnl_log *, - struct timeval *); -extern const struct timeval *nfnl_log_get_timestamp(const struct nfnl_log *); +extern void nfnl_log_set_copy_range(struct nfnl_log *, uint32_t); +extern int nfnl_log_test_copy_range(const struct nfnl_log *); +extern uint32_t nfnl_log_get_copy_range(const struct nfnl_log *); -extern void nfnl_log_set_indev(struct nfnl_log *, uint32_t); -extern uint32_t nfnl_log_get_indev(const struct nfnl_log *); +extern void nfnl_log_set_flush_timeout(struct nfnl_log *, uint32_t); +extern int nfnl_log_test_flush_timeout(const struct nfnl_log *); +extern uint32_t nfnl_log_get_flush_timeout(const struct nfnl_log *); -extern void nfnl_log_set_outdev(struct nfnl_log *, uint32_t); -extern uint32_t nfnl_log_get_outdev(const struct nfnl_log *); +extern void nfnl_log_set_alloc_size(struct nfnl_log *, uint32_t); +extern int nfnl_log_test_alloc_size(const struct nfnl_log *); +extern uint32_t nfnl_log_get_alloc_size(const struct nfnl_log *); -extern void nfnl_log_set_physindev(struct nfnl_log *, uint32_t); -extern uint32_t nfnl_log_get_physindev(const struct nfnl_log *); +extern void nfnl_log_set_queue_threshold(struct nfnl_log *, uint32_t); +extern int nfnl_log_test_queue_threshold(const struct nfnl_log *); +extern uint32_t nfnl_log_get_queue_threshold(const struct nfnl_log *); -extern void nfnl_log_set_physoutdev(struct nfnl_log *, uint32_t); -extern uint32_t nfnl_log_get_physoutdev(const struct nfnl_log *); +extern void nfnl_log_set_flags(struct nfnl_log *, unsigned int); +extern void nfnl_log_unset_flags(struct nfnl_log *, unsigned int); +extern unsigned int nfnl_log_get_flags(const struct nfnl_log *); -extern void nfnl_log_set_hwaddr(struct nfnl_log *, uint8_t *, int); -extern const uint8_t * nfnl_log_get_hwaddr(const struct nfnl_log *, int *); +extern char * nfnl_log_flags2str(unsigned int, char *, size_t); +extern unsigned int nfnl_log_str2flags(const char *); -extern int nfnl_log_set_payload(struct nfnl_log *, uint8_t *, int); -extern const void * nfnl_log_get_payload(const struct nfnl_log *, int *); +extern int nfnl_log_build_pf_bind(uint8_t, struct nl_msg **); +extern int nfnl_log_pf_bind(struct nl_sock *, uint8_t); -extern int nfnl_log_set_prefix(struct nfnl_log *, void *); -extern const char * nfnl_log_get_prefix(const struct nfnl_log *); +extern int nfnl_log_build_pf_unbind(uint8_t, struct nl_msg **); +extern int nfnl_log_pf_unbind(struct nl_sock *, uint8_t); -extern void nfnl_log_set_uid(struct nfnl_log *, uint32_t); -extern int nfnl_log_test_uid(const struct nfnl_log *); -extern uint32_t nfnl_log_get_uid(const struct nfnl_log *); +extern int nfnl_log_build_create_request(const struct nfnl_log *, + struct nl_msg **); +extern int nfnl_log_create(struct nl_sock *, const struct nfnl_log *); -extern void nfnl_log_set_seq(struct nfnl_log *, uint32_t); -extern int nfnl_log_test_seq(const struct nfnl_log *); -extern uint32_t nfnl_log_get_seq(const struct nfnl_log *); +extern int nfnl_log_build_change_request(const struct nfnl_log *, + struct nl_msg **); +extern int nfnl_log_change(struct nl_sock *, const struct nfnl_log *); -extern void nfnl_log_set_seq_global(struct nfnl_log *, uint32_t); -extern int nfnl_log_test_seq_global(const struct nfnl_log *); -extern uint32_t nfnl_log_get_seq_global(const struct nfnl_log *); +extern int nfnl_log_build_delete_request(const struct nfnl_log *, + struct nl_msg **); +extern int nfnl_log_delete(struct nl_sock *, const struct nfnl_log *); #ifdef __cplusplus } diff --git a/include/netlink/netfilter/log_msg.h b/include/netlink/netfilter/log_msg.h new file mode 100644 index 0000000..63b0f64 --- /dev/null +++ b/include/netlink/netfilter/log_msg.h @@ -0,0 +1,98 @@ +/* + * netlink/netfilter/log_msg.h Netfilter Log Message + * + * 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-2008 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2007 Philip Craig <philipc@snapgear.com> + * Copyright (c) 2007 Secure Computing Corporation + * Copyright (c) 2008 Patrick McHardy <kaber@trash.net> + */ + +#ifndef NETLINK_LOG_MSG_H_ +#define NETLINK_LOG_MSG_H_ + +#include <netlink/netlink.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct nlmsghdr; +struct nfnl_log_msg; + +extern struct nl_object_ops log_msg_obj_ops; + +/* General */ +extern struct nfnl_log_msg *nfnl_log_msg_alloc(void); +extern int nfnlmsg_log_msg_parse(struct nlmsghdr *, + struct nfnl_log_msg **); + +extern void nfnl_log_msg_get(struct nfnl_log_msg *); +extern void nfnl_log_msg_put(struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_family(struct nfnl_log_msg *, uint8_t); +extern uint8_t nfnl_log_msg_get_family(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_hwproto(struct nfnl_log_msg *, uint16_t); +extern int nfnl_log_msg_test_hwproto(const struct nfnl_log_msg *); +extern uint16_t nfnl_log_msg_get_hwproto(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_hook(struct nfnl_log_msg *, uint8_t); +extern int nfnl_log_msg_test_hook(const struct nfnl_log_msg *); +extern uint8_t nfnl_log_msg_get_hook(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_mark(struct nfnl_log_msg *, uint32_t); +extern int nfnl_log_msg_test_mark(const struct nfnl_log_msg *); +extern uint32_t nfnl_log_msg_get_mark(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_timestamp(struct nfnl_log_msg *, + struct timeval *); +extern const struct timeval *nfnl_log_msg_get_timestamp(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_indev(struct nfnl_log_msg *, uint32_t); +extern uint32_t nfnl_log_msg_get_indev(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_outdev(struct nfnl_log_msg *, uint32_t); +extern uint32_t nfnl_log_msg_get_outdev(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_physindev(struct nfnl_log_msg *, uint32_t); +extern uint32_t nfnl_log_msg_get_physindev(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_physoutdev(struct nfnl_log_msg *, uint32_t); +extern uint32_t nfnl_log_msg_get_physoutdev(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_hwaddr(struct nfnl_log_msg *, uint8_t *, int); +extern const uint8_t * nfnl_log_msg_get_hwaddr(const struct nfnl_log_msg *, int *); + +extern int nfnl_log_msg_set_payload(struct nfnl_log_msg *, uint8_t *, int); +extern const void * nfnl_log_msg_get_payload(const struct nfnl_log_msg *, int *); + +extern int nfnl_log_msg_set_prefix(struct nfnl_log_msg *, void *); +extern const char * nfnl_log_msg_get_prefix(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_uid(struct nfnl_log_msg *, uint32_t); +extern int nfnl_log_msg_test_uid(const struct nfnl_log_msg *); +extern uint32_t nfnl_log_msg_get_uid(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_gid(struct nfnl_log_msg *, uint32_t); +extern int nfnl_log_msg_test_gid(const struct nfnl_log_msg *); +extern uint32_t nfnl_log_msg_get_gid(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_seq(struct nfnl_log_msg *, uint32_t); +extern int nfnl_log_msg_test_seq(const struct nfnl_log_msg *); +extern uint32_t nfnl_log_msg_get_seq(const struct nfnl_log_msg *); + +extern void nfnl_log_msg_set_seq_global(struct nfnl_log_msg *, uint32_t); +extern int nfnl_log_msg_test_seq_global(const struct nfnl_log_msg *); +extern uint32_t nfnl_log_msg_get_seq_global(const struct nfnl_log_msg *); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/netlink/netfilter/netfilter.h b/include/netlink/netfilter/netfilter.h new file mode 100644 index 0000000..dd3589c --- /dev/null +++ b/include/netlink/netfilter/netfilter.h @@ -0,0 +1,31 @@ +/* + * netlink/netfilter/netfilter.h Netfilter generic functions + * + * 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) 2008 Patrick McHardy <kaber@trash.net> + */ + +#ifndef NETLINK_NETFILTER_H_ +#define NETLINK_NETFILTER_H_ + +#include <netlink/netlink.h> + +#ifdef __cplusplus +extern "C" { +#endif + +extern char * nfnl_verdict2str(unsigned int, char *, size_t); +extern unsigned int nfnl_str2verdict(const char *); + +extern char * nfnl_inet_hook2str(unsigned int, char *, size_t); +extern unsigned int nfnl_str2inet_hook(const char *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink/netfilter/nfnl.h b/include/netlink/netfilter/nfnl.h index 123d93e..8da4ba1 100644 --- a/include/netlink/netfilter/nfnl.h +++ b/include/netlink/netfilter/nfnl.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> * Copyright (c) 2007 Philip Craig <philipc@snapgear.com> * Copyright (c) 2007 Secure Computing Corporation */ @@ -23,14 +23,14 @@ extern "C" { #define NFNL_HDRLEN NLMSG_ALIGN(sizeof(struct nfgenmsg)) #define NFNLMSG_TYPE(subsys, subtype) (((subsys) << 8) | (subtype)) -extern int nfnl_connect(struct nl_handle *); +extern int nfnl_connect(struct nl_sock *); extern uint8_t nfnlmsg_subsys(struct nlmsghdr *); extern uint8_t nfnlmsg_subtype(struct nlmsghdr *); extern uint8_t nfnlmsg_family(struct nlmsghdr *); extern uint16_t nfnlmsg_res_id(struct nlmsghdr *); -extern int nfnl_send_simple(struct nl_handle *, uint8_t, uint8_t, +extern int nfnl_send_simple(struct nl_sock *, uint8_t, uint8_t, int, uint8_t, uint16_t); extern struct nl_msg * nfnlmsg_alloc_simple(uint8_t, uint8_t, int, uint8_t, uint16_t); diff --git a/include/netlink/netfilter/queue.h b/include/netlink/netfilter/queue.h new file mode 100644 index 0000000..664610d --- /dev/null +++ b/include/netlink/netfilter/queue.h @@ -0,0 +1,90 @@ +/* + * netlink/netfilter/queue.h Netfilter Queue + * + * 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) 2007, 2008 Patrick McHardy <kaber@trash.net> + */ + +#ifndef NETLINK_QUEUE_H_ +#define NETLINK_QUEUE_H_ + +#include <netlink/netlink.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct nl_sock; +struct nlmsghdr; +struct nfnl_queue; + +extern struct nl_object_ops queue_obj_ops; + +enum nfnl_queue_copy_mode { + NFNL_QUEUE_COPY_NONE, + NFNL_QUEUE_COPY_META, + NFNL_QUEUE_COPY_PACKET, +}; + +/* General */ +extern struct nl_sock * nfnl_queue_socket_alloc(void); + +extern struct nfnl_queue * nfnl_queue_alloc(void); + +extern void nfnl_queue_get(struct nfnl_queue *); +extern void nfnl_queue_put(struct nfnl_queue *); + +/* Attributes */ +extern void nfnl_queue_set_group(struct nfnl_queue *, uint16_t); +extern int nfnl_queue_test_group(const struct nfnl_queue *); +extern uint16_t nfnl_queue_get_group(const struct nfnl_queue *); + +extern void nfnl_queue_set_maxlen(struct nfnl_queue *, uint32_t); +extern int nfnl_queue_test_maxlen(const struct nfnl_queue *); +extern uint32_t nfnl_queue_get_maxlen(const struct nfnl_queue *); + +extern void nfnl_queue_set_copy_mode(struct nfnl_queue *, + enum nfnl_queue_copy_mode); +extern int nfnl_queue_test_copy_mode(const struct nfnl_queue *); +extern enum nfnl_queue_copy_mode nfnl_queue_get_copy_mode(const struct nfnl_queue *); + +extern char * nfnl_queue_copy_mode2str(enum nfnl_queue_copy_mode, + char *, size_t); +extern enum nfnl_queue_copy_mode nfnl_queue_str2copy_mode(const char *); + +extern void nfnl_queue_set_copy_range(struct nfnl_queue *, + uint32_t); +extern int nfnl_queue_test_copy_range(const struct nfnl_queue *); +extern uint32_t nfnl_queue_get_copy_range(const struct nfnl_queue *); + +extern int nfnl_queue_build_pf_bind(uint8_t, struct nl_msg **); +extern int nfnl_queue_pf_bind(struct nl_sock *, uint8_t); + +extern int nfnl_queue_build_pf_unbind(uint8_t, struct nl_msg **); +extern int nfnl_queue_pf_unbind(struct nl_sock *, uint8_t); + +extern int nfnl_queue_build_create_request(const struct nfnl_queue *, + struct nl_msg **); +extern int nfnl_queue_create(struct nl_sock *, + const struct nfnl_queue *); + +extern int nfnl_queue_build_change_request(const struct nfnl_queue *, + struct nl_msg **); +extern int nfnl_queue_change(struct nl_sock *, + const struct nfnl_queue *); + +extern int nfnl_queue_build_delete_request(const struct nfnl_queue *, + struct nl_msg **); +extern int nfnl_queue_delete(struct nl_sock *, + const struct nfnl_queue *); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/netlink/netfilter/queue_msg.h b/include/netlink/netfilter/queue_msg.h new file mode 100644 index 0000000..24ed081 --- /dev/null +++ b/include/netlink/netfilter/queue_msg.h @@ -0,0 +1,104 @@ +/* + * netlink/netfilter/queue_msg.h Netfilter Queue Messages + * + * 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) 2007, 2008 Patrick McHardy <kaber@trash.net> + */ + +#ifndef NETLINK_QUEUE_MSG_H_ +#define NETLINK_QUEUE_MSG_H_ + +#include <netlink/netlink.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct nl_sock; +struct nlmsghdr; +struct nfnl_queue_msg; + +extern struct nl_object_ops queue_msg_obj_ops; + +/* General */ +extern struct nfnl_queue_msg * nfnl_queue_msg_alloc(void); +extern int nfnlmsg_queue_msg_parse(struct nlmsghdr *, + struct nfnl_queue_msg **); + +extern void nfnl_queue_msg_get(struct nfnl_queue_msg *); +extern void nfnl_queue_msg_put(struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_group(struct nfnl_queue_msg *, uint16_t); +extern int nfnl_queue_msg_test_group(const struct nfnl_queue_msg *); +extern uint16_t nfnl_queue_msg_get_group(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_family(struct nfnl_queue_msg *, uint8_t); +extern int nfnl_queue_msg_test_family(const struct nfnl_queue_msg *); +extern uint8_t nfnl_queue_msg_get_family(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_packetid(struct nfnl_queue_msg *, uint32_t); +extern int nfnl_queue_msg_test_packetid(const struct nfnl_queue_msg *); +extern uint32_t nfnl_queue_msg_get_packetid(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_hwproto(struct nfnl_queue_msg *, uint16_t); +extern int nfnl_queue_msg_test_hwproto(const struct nfnl_queue_msg *); +extern uint16_t nfnl_queue_msg_get_hwproto(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_hook(struct nfnl_queue_msg *, uint8_t); +extern int nfnl_queue_msg_test_hook(const struct nfnl_queue_msg *); +extern uint8_t nfnl_queue_msg_get_hook(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_mark(struct nfnl_queue_msg *, uint32_t); +extern int nfnl_queue_msg_test_mark(const struct nfnl_queue_msg *); +extern uint32_t nfnl_queue_msg_get_mark(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_timestamp(struct nfnl_queue_msg *, + struct timeval *); +extern int nfnl_queue_msg_test_timestamp(const struct nfnl_queue_msg *); +extern const struct timeval * nfnl_queue_msg_get_timestamp(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_indev(struct nfnl_queue_msg *, uint32_t); +extern int nfnl_queue_msg_test_indev(const struct nfnl_queue_msg *); +extern uint32_t nfnl_queue_msg_get_indev(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_outdev(struct nfnl_queue_msg *, uint32_t); +extern int nfnl_queue_msg_test_outdev(const struct nfnl_queue_msg *); +extern uint32_t nfnl_queue_msg_get_outdev(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_physindev(struct nfnl_queue_msg *, uint32_t); +extern int nfnl_queue_msg_test_physindev(const struct nfnl_queue_msg *); +extern uint32_t nfnl_queue_msg_get_physindev(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_physoutdev(struct nfnl_queue_msg *, uint32_t); +extern int nfnl_queue_msg_test_physoutdev(const struct nfnl_queue_msg *); +extern uint32_t nfnl_queue_msg_get_physoutdev(const struct nfnl_queue_msg *); + +extern void nfnl_queue_msg_set_hwaddr(struct nfnl_queue_msg *, uint8_t *, int); +extern int nfnl_queue_msg_test_hwaddr(const struct nfnl_queue_msg *); +extern const uint8_t * nfnl_queue_msg_get_hwaddr(const struct nfnl_queue_msg *, int *); + +extern int nfnl_queue_msg_set_payload(struct nfnl_queue_msg *, uint8_t *, int); +extern int nfnl_queue_msg_test_payload(const struct nfnl_queue_msg *); +extern const void * nfnl_queue_msg_get_payload(const struct nfnl_queue_msg *, int *); + +extern void nfnl_queue_msg_set_verdict(struct nfnl_queue_msg *, + unsigned int); +extern int nfnl_queue_msg_test_verdict(const struct nfnl_queue_msg *); +extern unsigned int nfnl_queue_msg_get_verdict(const struct nfnl_queue_msg *); + +extern struct nl_msg * nfnl_queue_msg_build_verdict(const struct nfnl_queue_msg *); +extern int nfnl_queue_msg_send_verdict(struct nl_sock *, + const struct nfnl_queue_msg *); +extern int nfnl_queue_msg_send_verdict_payload(struct nl_sock *, + const struct nfnl_queue_msg *, + const void *, unsigned ); +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/netlink/netlink.h b/include/netlink/netlink.h index 2cdf345..1cfe220 100644 --- a/include/netlink/netlink.h +++ b/include/netlink/netlink.h @@ -20,11 +20,14 @@ #include <sys/socket.h> #include <sys/types.h> #include <sys/time.h> +#include <netdb.h> #include <netlink/netlink-compat.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <linux/genetlink.h> #include <linux/netfilter/nfnetlink.h> +#include <netlink/version.h> +#include <netlink/errno.h> #include <netlink/types.h> #include <netlink/handlers.h> #include <netlink/socket.h> @@ -33,34 +36,39 @@ extern "C" { #endif +struct ucred; + extern int nl_debug; extern struct nl_dump_params nl_debug_dp; /* Connection Management */ -extern int nl_connect(struct nl_handle *, int); -extern void nl_close(struct nl_handle *); +extern int nl_connect(struct nl_sock *, int); +extern void nl_close(struct nl_sock *); /* Send */ -extern int nl_sendto(struct nl_handle *, void *, size_t); -extern int nl_sendmsg(struct nl_handle *, struct nl_msg *, +extern int nl_sendto(struct nl_sock *, void *, size_t); +extern int nl_sendmsg(struct nl_sock *, struct nl_msg *, struct msghdr *); -extern int nl_send(struct nl_handle *, struct nl_msg *); -extern int nl_send_auto_complete(struct nl_handle *, +extern int nl_send(struct nl_sock *, struct nl_msg *); +extern int nl_send_iovec(struct nl_sock *, struct nl_msg *, + struct iovec *, unsigned); +extern void nl_auto_complete(struct nl_sock *, + struct nl_msg *); +extern int nl_send_auto_complete(struct nl_sock *, struct nl_msg *); -extern int nl_send_simple(struct nl_handle *, int, int, +extern int nl_send_simple(struct nl_sock *, int, int, void *, size_t); /* Receive */ -extern int nl_recv(struct nl_handle *, +extern int nl_recv(struct nl_sock *, struct sockaddr_nl *, unsigned char **, struct ucred **); -extern int nl_recvmsgs(struct nl_handle *, struct nl_cb *); +extern int nl_recvmsgs(struct nl_sock *, struct nl_cb *); -#define nl_recvmsgs_def(handle) nl_recvmsgs_default(handle) -extern int nl_recvmsgs_default(struct nl_handle *); +extern int nl_recvmsgs_default(struct nl_sock *); -extern int nl_wait_for_ack(struct nl_handle *); +extern int nl_wait_for_ack(struct nl_sock *); /* Netlink Family Translations */ extern char * nl_nlfamily2str(int, char *, size_t); diff --git a/include/netlink/object-api.h b/include/netlink/object-api.h index 2a32f2c..b3337f0 100644 --- a/include/netlink/object-api.h +++ b/include/netlink/object-api.h @@ -94,7 +94,6 @@ extern "C" { * struct nl_dump_params *params) * { * struct my_obj *my_obj = nl_object_priv(obj); - * int line = 1; // We will print at least one line for sure * * // It is absolutely essential to use nl_dump() when printing * // any text to make sure the dumping parameters are respected. @@ -102,14 +101,11 @@ extern "C" { * * // Before we can dump the next line, make sure to prefix * // this line correctly. - * nl_new_line(params, line++); + * 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); - * - * // Return the number of lines dumped - * return line; * } * * struct nl_object_ops my_ops = { @@ -202,7 +198,18 @@ extern "C" { * * @return True if the attribute is available, otherwise false is returned. */ -#define AVAILABLE(A, B, ATTR) (((A)->ce_mask & (B)->ce_mask) & (ATTR)) +#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 @@ -219,7 +226,8 @@ extern "C" { * * @return True if the attribute mismatch, or false if they match. */ -#define ATTR_MISMATCH(A, B, ATTR, EXPR) (!AVAILABLE(A, B, ATTR) || (EXPR)) +#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 @@ -304,8 +312,8 @@ struct nl_object_ops * * The functions must return the number of lines printed. */ - int (*oo_dump[NL_DUMP_MAX+1])(struct nl_object *, - struct nl_dump_params *); + void (*oo_dump[NL_DUMP_MAX+1])(struct nl_object *, + struct nl_dump_params *); /** * Comparison function diff --git a/include/netlink/object.h b/include/netlink/object.h index 751a1b3..ef1ed9f 100644 --- a/include/netlink/object.h +++ b/include/netlink/object.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_OBJECT_H_ @@ -27,7 +27,8 @@ struct nl_object_ops; /* General */ extern struct nl_object * nl_object_alloc(struct nl_object_ops *); -extern struct nl_object * nl_object_alloc_name(const char *); +extern int nl_object_alloc_name(const char *, + struct nl_object **); extern void nl_object_free(struct nl_object *); extern struct nl_object * nl_object_clone(struct nl_object *obj); extern void nl_object_get(struct nl_object *); @@ -55,7 +56,11 @@ extern int nl_object_is_marked(struct nl_object *); /* Access Functions */ extern int nl_object_get_refcnt(struct nl_object *); extern struct nl_cache * nl_object_get_cache(struct nl_object *); -extern inline void * nl_object_priv(struct nl_object *); +static inline void * nl_object_priv(struct nl_object *obj) +{ + return obj; +} + #ifdef __cplusplus } diff --git a/include/netlink/route/addr.h b/include/netlink/route/addr.h index 71a90e0..1381486 100644 --- a/include/netlink/route/addr.h +++ b/include/netlink/route/addr.h @@ -6,8 +6,8 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> - * Baruch Even <baruch@ev-en.org>, + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2006 Baruch Even <baruch@ev-en.org>, * Mediatrix Telecom, inc. <ericb@mediatrix.com> */ @@ -26,63 +26,63 @@ struct rtnl_addr; /* General */ extern struct rtnl_addr *rtnl_addr_alloc(void); -extern void rtnl_addr_put(struct rtnl_addr *); +extern void rtnl_addr_put(struct rtnl_addr *); -extern struct nl_cache *rtnl_addr_alloc_cache(struct nl_handle *); +extern int rtnl_addr_alloc_cache(struct nl_sock *, struct nl_cache **); -/* Address Addition */ -extern struct nl_msg * rtnl_addr_build_add_request(struct rtnl_addr *, int); -extern int rtnl_addr_add(struct nl_handle *, struct rtnl_addr *, - int); +extern int rtnl_addr_build_add_request(struct rtnl_addr *, int, + struct nl_msg **); +extern int rtnl_addr_add(struct nl_sock *, struct rtnl_addr *, int); -/* Address Deletion */ -extern struct nl_msg * rtnl_addr_build_delete_request(struct rtnl_addr *, int); -extern int rtnl_addr_delete(struct nl_handle *, - struct rtnl_addr *, int); +extern int rtnl_addr_build_delete_request(struct rtnl_addr *, int, + struct nl_msg **); +extern int rtnl_addr_delete(struct nl_sock *, + struct rtnl_addr *, int); -/* Address Flags Translations */ -extern char * rtnl_addr_flags2str(int, char *, size_t); -extern int rtnl_addr_str2flags(const char *); +extern char * rtnl_addr_flags2str(int, char *, size_t); +extern int rtnl_addr_str2flags(const char *); -/* Attribute Access */ -extern void rtnl_addr_set_label(struct rtnl_addr *, const char *); -extern char * rtnl_addr_get_label(struct rtnl_addr *); +extern int rtnl_addr_set_label(struct rtnl_addr *, const char *); +extern char * rtnl_addr_get_label(struct rtnl_addr *); -extern void rtnl_addr_set_ifindex(struct rtnl_addr *, int); -extern int rtnl_addr_get_ifindex(struct rtnl_addr *); +extern void rtnl_addr_set_ifindex(struct rtnl_addr *, int); +extern int rtnl_addr_get_ifindex(struct rtnl_addr *); -extern void rtnl_addr_set_family(struct rtnl_addr *, int); -extern int rtnl_addr_get_family(struct rtnl_addr *); +extern void rtnl_addr_set_family(struct rtnl_addr *, int); +extern int rtnl_addr_get_family(struct rtnl_addr *); -extern void rtnl_addr_set_prefixlen(struct rtnl_addr *, int); -extern int rtnl_addr_get_prefixlen(struct rtnl_addr *); +extern void rtnl_addr_set_prefixlen(struct rtnl_addr *, int); +extern int rtnl_addr_get_prefixlen(struct rtnl_addr *); -extern void rtnl_addr_set_scope(struct rtnl_addr *, int); -extern int rtnl_addr_get_scope(struct rtnl_addr *); +extern void rtnl_addr_set_scope(struct rtnl_addr *, int); +extern int rtnl_addr_get_scope(struct rtnl_addr *); -extern void rtnl_addr_set_flags(struct rtnl_addr *, unsigned int); -extern void rtnl_addr_unset_flags(struct rtnl_addr *, unsigned int); -extern unsigned int rtnl_addr_get_flags(struct rtnl_addr *); +extern void rtnl_addr_set_flags(struct rtnl_addr *, unsigned int); +extern void rtnl_addr_unset_flags(struct rtnl_addr *, unsigned int); +extern unsigned int rtnl_addr_get_flags(struct rtnl_addr *); -extern int rtnl_addr_set_local(struct rtnl_addr *, +extern int rtnl_addr_set_local(struct rtnl_addr *, struct nl_addr *); -extern struct nl_addr * rtnl_addr_get_local(struct rtnl_addr *); +extern struct nl_addr *rtnl_addr_get_local(struct rtnl_addr *); -extern int rtnl_addr_set_peer(struct rtnl_addr *, - struct nl_addr *); -extern struct nl_addr * rtnl_addr_get_peer(struct rtnl_addr *); +extern int rtnl_addr_set_peer(struct rtnl_addr *, struct nl_addr *); +extern struct nl_addr *rtnl_addr_get_peer(struct rtnl_addr *); -extern int rtnl_addr_set_broadcast(struct rtnl_addr *, - struct nl_addr *); -extern struct nl_addr * rtnl_addr_get_broadcast(struct rtnl_addr *); +extern int rtnl_addr_set_broadcast(struct rtnl_addr *, struct nl_addr *); +extern struct nl_addr *rtnl_addr_get_broadcast(struct rtnl_addr *); -extern int rtnl_addr_set_anycast(struct rtnl_addr *, - struct nl_addr *); -extern struct nl_addr * rtnl_addr_get_anycast(struct rtnl_addr *); +extern int rtnl_addr_set_multicast(struct rtnl_addr *, struct nl_addr *); +extern struct nl_addr *rtnl_addr_get_multicast(struct rtnl_addr *); -extern int rtnl_addr_set_multicast(struct rtnl_addr *, - struct nl_addr *); -extern struct nl_addr * rtnl_addr_get_multicast(struct rtnl_addr *); +extern int rtnl_addr_set_anycast(struct rtnl_addr *, struct nl_addr *); +extern struct nl_addr *rtnl_addr_get_anycast(struct rtnl_addr *); + +extern uint32_t rtnl_addr_get_valid_lifetime(struct rtnl_addr *); +extern void rtnl_addr_set_valid_lifetime(struct rtnl_addr *, uint32_t); +extern uint32_t rtnl_addr_get_preferred_lifetime(struct rtnl_addr *); +extern void rtnl_addr_set_preferred_lifetime(struct rtnl_addr *, uint32_t); +extern uint32_t rtnl_addr_get_create_time(struct rtnl_addr *); +extern uint32_t rtnl_addr_get_last_update_time(struct rtnl_addr *); #ifdef __cplusplus } diff --git a/include/netlink/route/class-modules.h b/include/netlink/route/class-modules.h index 2400a60..74a25c9 100644 --- a/include/netlink/route/class-modules.h +++ b/include/netlink/route/class-modules.h @@ -32,8 +32,8 @@ struct rtnl_class_ops /** * Dump callbacks */ - int (*co_dump[NL_DUMP_MAX+1])(struct rtnl_class *, - struct nl_dump_params *, int); + void (*co_dump[NL_DUMP_MAX+1])(struct rtnl_class *, + struct nl_dump_params *); /** * Must return the contents supposed to be in TCA_OPTIONS diff --git a/include/netlink/route/class.h b/include/netlink/route/class.h index a624ef6..480095e 100644 --- a/include/netlink/route/class.h +++ b/include/netlink/route/class.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_CLASS_H_ @@ -24,20 +24,25 @@ struct rtnl_class; extern struct nl_object_ops class_obj_ops; -/* General */ extern struct rtnl_class * rtnl_class_alloc(void); -extern void rtnl_class_put(struct rtnl_class *); -extern struct nl_cache * rtnl_class_alloc_cache(struct nl_handle *, int); +extern void rtnl_class_put(struct rtnl_class *); +extern int rtnl_class_alloc_cache(struct nl_sock *, int, + struct nl_cache **); +extern struct rtnl_class *rtnl_class_get(struct nl_cache *, int, uint32_t); /* leaf qdisc access */ extern struct rtnl_qdisc * rtnl_class_leaf_qdisc(struct rtnl_class *, struct nl_cache *); -/* class addition */ -extern struct nl_msg * rtnl_class_build_add_request(struct rtnl_class *, int); -extern int rtnl_class_add(struct nl_handle *, struct rtnl_class *, int); +extern int rtnl_class_build_add_request(struct rtnl_class *, int, + struct nl_msg **); +extern int rtnl_class_add(struct nl_sock *, struct rtnl_class *, + int); + +extern int rtnl_class_build_delete_request(struct rtnl_class *, + struct nl_msg **); +extern int rtnl_class_delete(struct nl_sock *, struct rtnl_class *); -/* attribute modification */ extern void rtnl_class_set_ifindex(struct rtnl_class *, int); extern int rtnl_class_get_ifindex(struct rtnl_class *); extern void rtnl_class_set_handle(struct rtnl_class *, uint32_t); diff --git a/include/netlink/route/classifier-modules.h b/include/netlink/route/classifier-modules.h index 8c31e67..35cb06e 100644 --- a/include/netlink/route/classifier-modules.h +++ b/include/netlink/route/classifier-modules.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_CLASS_MODULES_H_ @@ -25,19 +25,25 @@ extern "C" { struct rtnl_cls_ops { /** - * Kind/Name of classifier + * Name of classifier module */ char co_kind[32]; + + /** + * Size of private classifier data + */ + size_t co_size; + /** * Dump callbacks */ - int (*co_dump[NL_DUMP_MAX+1])(struct rtnl_cls *, - struct nl_dump_params *, int); + void (*co_dump[NL_DUMP_MAX+1])(struct rtnl_cls *, + struct nl_dump_params *); /** * Must return the contents supposed to be in TCA_OPTIONS */ - struct nl_msg *(*co_get_opts)(struct rtnl_cls *); + int (*co_get_opts)(struct rtnl_cls *, struct nl_msg *); /** * TCA_OPTIONS message parser diff --git a/include/netlink/route/classifier.h b/include/netlink/route/classifier.h index 7ef0da4..d9c3d21 100644 --- a/include/netlink/route/classifier.h +++ b/include/netlink/route/classifier.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_CLASSIFIER_H_ @@ -23,31 +23,37 @@ extern "C" { extern struct nl_object_ops cls_obj_ops; -extern struct rtnl_cls *rtnl_cls_alloc(void); -extern void rtnl_cls_put(struct rtnl_cls *); +extern struct rtnl_cls *rtnl_cls_alloc(void); +extern void rtnl_cls_put(struct rtnl_cls *); -extern struct nl_cache *rtnl_cls_alloc_cache(struct nl_handle *, int, uint32_t); +extern int rtnl_cls_alloc_cache(struct nl_sock *, int, uint32_t, + struct nl_cache **); -/* classifier addition */ -extern int rtnl_cls_add(struct nl_handle *, struct rtnl_cls *, - int); -extern struct nl_msg * rtnl_cls_build_add_request(struct rtnl_cls *, int); +extern int rtnl_cls_build_add_request(struct rtnl_cls *, int, + struct nl_msg **); +extern int rtnl_cls_add(struct nl_sock *, struct rtnl_cls *, int); -extern struct nl_msg *rtnl_cls_build_change_request(struct rtnl_cls *, int); -extern struct nl_msg *rtnl_cls_build_delete_request(struct rtnl_cls *, int); -extern int rtnl_cls_delete(struct nl_handle *, struct rtnl_cls *, int); +extern int rtnl_cls_build_change_request(struct rtnl_cls *, int, + struct nl_msg **); +extern int rtnl_cls_build_delete_request(struct rtnl_cls *, int, + struct nl_msg **); +extern int rtnl_cls_delete(struct nl_sock *, struct rtnl_cls *, int); -/* attribute modification */ extern void rtnl_cls_set_ifindex(struct rtnl_cls *, int); +extern int rtnl_cls_get_ifindex(struct rtnl_cls *); extern void rtnl_cls_set_handle(struct rtnl_cls *, uint32_t); extern void rtnl_cls_set_parent(struct rtnl_cls *, uint32_t); -extern void rtnl_cls_set_kind(struct rtnl_cls *, const char *); +extern uint32_t rtnl_cls_get_parent(struct rtnl_cls *); +extern int rtnl_cls_set_kind(struct rtnl_cls *, const char *); +extern struct rtnl_cls_ops *rtnl_cls_get_ops(struct rtnl_cls *); -extern void rtnl_cls_set_prio(struct rtnl_cls *, int); -extern int rtnl_cls_get_prio(struct rtnl_cls *); +extern void rtnl_cls_set_prio(struct rtnl_cls *, uint16_t); +extern uint16_t rtnl_cls_get_prio(struct rtnl_cls *); -extern void rtnl_cls_set_protocol(struct rtnl_cls *, int); -extern int rtnl_cls_get_protocol(struct rtnl_cls *); +extern void rtnl_cls_set_protocol(struct rtnl_cls *, uint16_t); +extern uint16_t rtnl_cls_get_protocol(struct rtnl_cls *); + +extern void *rtnl_cls_data(struct rtnl_cls *); #ifdef __cplusplus } diff --git a/include/netlink/route/cls/basic.h b/include/netlink/route/cls/basic.h new file mode 100644 index 0000000..7003124 --- /dev/null +++ b/include/netlink/route/cls/basic.h @@ -0,0 +1,33 @@ +/* + * netlink/route/cls/basic.h Basic Classifier + * + * 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) 2008-2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef NETLINK_BASIC_H_ +#define NETLINK_BASIC_H_ + +#include <netlink/netlink.h> + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct rtnl_cls_ops *rtnl_basic_get_ops(void); +extern int rtnl_basic_set_classid(struct rtnl_cls *, uint32_t); +extern uint32_t rtnl_basic_get_classid(struct rtnl_cls *); +extern int rtnl_basic_set_ematch(struct rtnl_cls *, + struct rtnl_ematch_tree *); +extern struct rtnl_ematch_tree * + rtnl_basic_get_ematch(struct rtnl_cls *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink/route/cls/cgroup.h b/include/netlink/route/cls/cgroup.h new file mode 100644 index 0000000..7b0e3d3 --- /dev/null +++ b/include/netlink/route/cls/cgroup.h @@ -0,0 +1,31 @@ +/* + * netlink/route/cls/cgroup.h Control Groups Classifier + * + * 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) 2009 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef NETLINK_CLS_CGROUP_H_ +#define NETLINK_CLS_CGROUP_H_ + +#include <netlink/netlink.h> +#include <netlink/cache.h> + +#ifdef __cplusplus +extern "C" { +#endif + +extern int rtnl_cgroup_set_ematch(struct rtnl_cls *, + struct rtnl_ematch_tree *); +extern struct rtnl_ematch_tree * + rtnl_cgroup_get_ematch(struct rtnl_cls *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink/route/cls/ematch.h b/include/netlink/route/cls/ematch.h new file mode 100644 index 0000000..c4292bf --- /dev/null +++ b/include/netlink/route/cls/ematch.h @@ -0,0 +1,73 @@ +/* + * netlink/route/cls/ematch.h Extended Matches + * + * 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) 2008 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef NETLINK_CLS_EMATCH_H_ +#define NETLINK_CLS_EMATCH_H_ + +#include <netlink/netlink.h> +#include <netlink/route/classifier.h> +#include <linux/pkt_cls.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct rtnl_ematch; +struct rtnl_ematch_tree; + +struct rtnl_ematch_ops +{ + int eo_kind; + const char * eo_name; + size_t eo_datalen; + + int (*eo_parse)(struct rtnl_ematch *, + void *, size_t); + void (*eo_dump)(struct rtnl_ematch *, + struct nl_dump_params *); + struct nl_list_head eo_list; +}; + +extern int rtnl_ematch_register(struct rtnl_ematch_ops *); +extern int rtnl_ematch_unregister(struct rtnl_ematch_ops *); + +extern struct rtnl_ematch_ops * + rtnl_ematch_lookup_ops(int); +extern struct rtnl_ematch_ops * + rtnl_ematch_lookup_ops_name(const char *); + +extern struct rtnl_ematch * + rtnl_ematch_alloc(struct rtnl_ematch_ops *); +extern void rtnl_ematch_add_child(struct rtnl_ematch *, + struct rtnl_ematch *); +extern void rtnl_ematch_unlink(struct rtnl_ematch *); +extern void rtnl_ematch_free(struct rtnl_ematch *); + +extern void * rtnl_ematch_data(struct rtnl_ematch *); +extern void rtnl_ematch_set_flags(struct rtnl_ematch *, uint16_t); +extern void rtnl_ematch_unset_flags(struct rtnl_ematch *, uint16_t); +extern uint16_t rtnl_ematch_get_flags(struct rtnl_ematch *); + +extern struct rtnl_ematch_tree * + rtnl_ematch_tree_alloc(uint16_t); +extern void rtnl_ematch_tree_free(struct rtnl_ematch_tree *); + +extern int rtnl_ematch_parse(struct nlattr *, struct rtnl_ematch_tree **); +extern void rtnl_ematch_tree_add_tail(struct rtnl_ematch_tree *, + struct rtnl_ematch *); +extern void rtnl_ematch_tree_dump(struct rtnl_ematch_tree *, + struct nl_dump_params *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink/route/cls/ematch/cmp.h b/include/netlink/route/cls/ematch/cmp.h new file mode 100644 index 0000000..b4ad03a --- /dev/null +++ b/include/netlink/route/cls/ematch/cmp.h @@ -0,0 +1,31 @@ +/* + * netlink/route/cls/ematch/cmp.h Simple Comparison + * + * 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) 2008 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef NETLINK_CLS_EMATCH_CMP_H_ +#define NETLINK_CLS_EMATCH_CMP_H_ + +#include <netlink/netlink.h> +#include <netlink/route/cls/ematch.h> + +#ifdef __cplusplus +extern "C" { +#endif + +extern void rtnl_ematch_cmp_set(struct rtnl_ematch *, + struct tcf_em_cmp *); +extern struct tcf_em_cmp * + rtnl_ematch_cmp_get(struct rtnl_ematch *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink/route/link.h b/include/netlink/route/link.h index caaa792..4b630f7 100644 --- a/include/netlink/route/link.h +++ b/include/netlink/route/link.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_LINK_H_ @@ -51,116 +51,92 @@ enum rtnl_link_st { #define RTNL_LINK_STATS_MAX (__RTNL_LINK_STATS_MAX - 1) -/** - * Special interface index stating the link was not found. - * @ingroup link - */ -#define RTNL_LINK_NOT_FOUND -1 - /* link object allocation/freeage */ -extern struct rtnl_link * rtnl_link_alloc(void); -extern void rtnl_link_put(struct rtnl_link *); -extern void rtnl_link_free(struct rtnl_link *); +extern struct rtnl_link *rtnl_link_alloc(void); +extern void rtnl_link_put(struct rtnl_link *); +extern void rtnl_link_free(struct rtnl_link *); /* link cache management */ -extern struct nl_cache * rtnl_link_alloc_cache(struct nl_handle *); -extern struct rtnl_link * rtnl_link_get(struct nl_cache *, int); -extern struct rtnl_link * rtnl_link_get_by_name(struct nl_cache *, - const char *); +extern int rtnl_link_alloc_cache(struct nl_sock *, struct nl_cache **); +extern struct rtnl_link *rtnl_link_get(struct nl_cache *, int); +extern struct rtnl_link *rtnl_link_get_by_name(struct nl_cache *, const char *); -/* Link Modifications */ -extern struct nl_msg * rtnl_link_build_change_request(struct rtnl_link *, - struct rtnl_link *, - int); -extern int rtnl_link_change(struct nl_handle *, - struct rtnl_link *, - struct rtnl_link *, int); +extern int rtnl_link_build_change_request(struct rtnl_link *, + struct rtnl_link *, int, + struct nl_msg **); +extern int rtnl_link_change(struct nl_sock *, struct rtnl_link *, + struct rtnl_link *, int); /* Name <-> Index Translations */ -extern char * rtnl_link_i2name(struct nl_cache *, int, - char *, size_t); -extern int rtnl_link_name2i(struct nl_cache *, - const char *); +extern char * rtnl_link_i2name(struct nl_cache *, int, char *, size_t); +extern int rtnl_link_name2i(struct nl_cache *, const char *); /* Name <-> Statistic Translations */ -extern char * rtnl_link_stat2str(int, char *, size_t); -extern int rtnl_link_str2stat(const char *); +extern char * rtnl_link_stat2str(int, char *, size_t); +extern int rtnl_link_str2stat(const char *); /* Link Flags Translations */ -extern char * rtnl_link_flags2str(int, char *, size_t); -extern int rtnl_link_str2flags(const char *); +extern char * rtnl_link_flags2str(int, char *, size_t); +extern int rtnl_link_str2flags(const char *); -extern char * rtnl_link_operstate2str(int, char *, size_t); -extern int rtnl_link_str2operstate(const char *); +extern char * rtnl_link_operstate2str(int, char *, size_t); +extern int rtnl_link_str2operstate(const char *); -extern char * rtnl_link_mode2str(int, char *, size_t); -extern int rtnl_link_str2mode(const char *); +extern char * rtnl_link_mode2str(int, char *, size_t); +extern int rtnl_link_str2mode(const char *); /* Access Functions */ -extern void rtnl_link_set_qdisc(struct rtnl_link *, - const char *); -extern char * rtnl_link_get_qdisc(struct rtnl_link *); +extern void rtnl_link_set_qdisc(struct rtnl_link *, const char *); +extern char * rtnl_link_get_qdisc(struct rtnl_link *); -extern void rtnl_link_set_name(struct rtnl_link *, - const char *); -extern char * rtnl_link_get_name(struct rtnl_link *); +extern void rtnl_link_set_name(struct rtnl_link *, const char *); +extern char * rtnl_link_get_name(struct rtnl_link *); -extern void rtnl_link_set_flags(struct rtnl_link *, - unsigned int); -extern void rtnl_link_unset_flags(struct rtnl_link *, - unsigned int); -extern unsigned int rtnl_link_get_flags(struct rtnl_link *); +extern void rtnl_link_set_flags(struct rtnl_link *, unsigned int); +extern void rtnl_link_unset_flags(struct rtnl_link *, unsigned int); +extern unsigned int rtnl_link_get_flags(struct rtnl_link *); -extern void rtnl_link_set_mtu(struct rtnl_link *, - unsigned int); -extern unsigned int rtnl_link_get_mtu(struct rtnl_link *); +extern void rtnl_link_set_mtu(struct rtnl_link *, unsigned int); +extern unsigned int rtnl_link_get_mtu(struct rtnl_link *); -extern void rtnl_link_set_txqlen(struct rtnl_link *, - unsigned int); -extern unsigned int rtnl_link_get_txqlen(struct rtnl_link *); +extern void rtnl_link_set_txqlen(struct rtnl_link *, unsigned int); +extern unsigned int rtnl_link_get_txqlen(struct rtnl_link *); -extern void rtnl_link_set_weight(struct rtnl_link *, - unsigned int); -extern unsigned int rtnl_link_get_weight(struct rtnl_link *); +extern void rtnl_link_set_weight(struct rtnl_link *, unsigned int); +extern unsigned int rtnl_link_get_weight(struct rtnl_link *); -extern void rtnl_link_set_ifindex(struct rtnl_link *, int); -extern int rtnl_link_get_ifindex(struct rtnl_link *); +extern void rtnl_link_set_ifindex(struct rtnl_link *, int); +extern int rtnl_link_get_ifindex(struct rtnl_link *); -extern void rtnl_link_set_family(struct rtnl_link *, int); -extern int rtnl_link_get_family(struct rtnl_link *); +extern void rtnl_link_set_family(struct rtnl_link *, int); +extern int rtnl_link_get_family(struct rtnl_link *); -extern void rtnl_link_set_arptype(struct rtnl_link *, - unsigned int); -extern unsigned int rtnl_link_get_arptype(struct rtnl_link *); +extern void rtnl_link_set_arptype(struct rtnl_link *, unsigned int); +extern unsigned int rtnl_link_get_arptype(struct rtnl_link *); -extern void rtnl_link_set_addr(struct rtnl_link *, - struct nl_addr *); -extern struct nl_addr * rtnl_link_get_addr(struct rtnl_link *); +extern void rtnl_link_set_addr(struct rtnl_link *, struct nl_addr *); +extern struct nl_addr *rtnl_link_get_addr(struct rtnl_link *); -extern void rtnl_link_set_broadcast(struct rtnl_link *, - struct nl_addr *); -extern struct nl_addr * rtnl_link_get_broadcast(struct rtnl_link *); +extern void rtnl_link_set_broadcast(struct rtnl_link *, struct nl_addr *); +extern struct nl_addr *rtnl_link_get_broadcast(struct rtnl_link *); -extern void rtnl_link_set_link(struct rtnl_link *, int); -extern int rtnl_link_get_link(struct rtnl_link *); +extern void rtnl_link_set_link(struct rtnl_link *, int); +extern int rtnl_link_get_link(struct rtnl_link *); -extern void rtnl_link_set_master(struct rtnl_link *, int); -extern int rtnl_link_get_master(struct rtnl_link *); +extern void rtnl_link_set_master(struct rtnl_link *, int); +extern int rtnl_link_get_master(struct rtnl_link *); -extern void rtnl_link_set_operstate(struct rtnl_link *, - uint8_t); -extern uint8_t rtnl_link_get_operstate(struct rtnl_link *); +extern void rtnl_link_set_operstate(struct rtnl_link *, uint8_t); +extern uint8_t rtnl_link_get_operstate(struct rtnl_link *); -extern void rtnl_link_set_linkmode(struct rtnl_link *, - uint8_t); -extern uint8_t rtnl_link_get_linkmode(struct rtnl_link *); +extern void rtnl_link_set_linkmode(struct rtnl_link *, uint8_t); +extern uint8_t rtnl_link_get_linkmode(struct rtnl_link *); -extern uint64_t rtnl_link_get_stat(struct rtnl_link *, int); +extern uint64_t rtnl_link_get_stat(struct rtnl_link *, int); -extern int rtnl_link_set_info_type(struct rtnl_link *, - const char *); -extern char * rtnl_link_get_info_type(struct rtnl_link *); +extern int rtnl_link_set_info_type(struct rtnl_link *, const char *); +extern char * rtnl_link_get_info_type(struct rtnl_link *); #ifdef __cplusplus } diff --git a/include/netlink/route/link/info-api.h b/include/netlink/route/link/info-api.h index 2ccce9d..7e18e31 100644 --- a/include/netlink/route/link/info-api.h +++ b/include/netlink/route/link/info-api.h @@ -45,8 +45,8 @@ struct rtnl_link_info_ops /** Called when the link object is dumped. * Must dump the info type specific attributes. */ - int (*io_dump[NL_DUMP_MAX+1])(struct rtnl_link *, - struct nl_dump_params *, int); + 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. */ diff --git a/include/netlink/route/neighbour.h b/include/netlink/route/neighbour.h index 078c3f4..698539a 100644 --- a/include/netlink/route/neighbour.h +++ b/include/netlink/route/neighbour.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_NEIGHBOUR_H_ @@ -22,39 +22,27 @@ extern "C" { struct rtnl_neigh; -/* neighbour object allocation/freeage */ -extern struct rtnl_neigh * rtnl_neigh_alloc(void); -extern void rtnl_neigh_put(struct rtnl_neigh *); +extern struct rtnl_neigh *rtnl_neigh_alloc(void); +extern void rtnl_neigh_put(struct rtnl_neigh *); -/* neighbour cache management */ -extern struct nl_cache * rtnl_neigh_alloc_cache(struct nl_handle *); -extern struct rtnl_neigh * rtnl_neigh_get(struct nl_cache *, int, +extern int rtnl_neigh_alloc_cache(struct nl_sock *, struct nl_cache **); +extern struct rtnl_neigh *rtnl_neigh_get(struct nl_cache *, int, struct nl_addr *); -/* Neigbour state translations */ -extern char * rtnl_neigh_state2str(int, char *, size_t); -extern int rtnl_neigh_str2state(const char *); +extern char * rtnl_neigh_state2str(int, char *, size_t); +extern int rtnl_neigh_str2state(const char *); -/* Neighbour flags translations */ -extern char * rtnl_neigh_flags2str(int, char *, size_t); -extern int rtnl_neigh_str2flag(const char *); +extern char * rtnl_neigh_flags2str(int, char *, size_t); +extern int rtnl_neigh_str2flag(const char *); -/* Neighbour Addition */ -extern int rtnl_neigh_add(struct nl_handle *, - struct rtnl_neigh *, int); -extern struct nl_msg * rtnl_neigh_build_add_request(struct rtnl_neigh *, int); +extern int rtnl_neigh_add(struct nl_sock *, struct rtnl_neigh *, int); +extern int rtnl_neigh_build_add_request(struct rtnl_neigh *, int, + struct nl_msg **); -/* Neighbour Modification */ -extern int rtnl_neigh_change(struct nl_handle *, - struct rtnl_neigh *, int); -extern struct nl_msg * rtnl_neigh_build_change_request(struct rtnl_neigh *, int); +extern int rtnl_neigh_delete(struct nl_sock *, struct rtnl_neigh *, int); +extern int rtnl_neigh_build_delete_request(struct rtnl_neigh *, int, + struct nl_msg **); -/* Neighbour Deletion */ -extern int rtnl_neigh_delete(struct nl_handle *, - struct rtnl_neigh *, int); -extern struct nl_msg * rtnl_neigh_build_delete_request(struct rtnl_neigh *, int); - -/* Access functions */ extern void rtnl_neigh_set_state(struct rtnl_neigh *, int); extern int rtnl_neigh_get_state(struct rtnl_neigh *); extern void rtnl_neigh_unset_state(struct rtnl_neigh *, diff --git a/include/netlink/route/neightbl.h b/include/netlink/route/neightbl.h index 20285ee..412c3e9 100644 --- a/include/netlink/route/neightbl.h +++ b/include/netlink/route/neightbl.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_NEIGHTBL_H_ @@ -25,15 +25,16 @@ struct rtnl_neightbl; extern struct rtnl_neightbl *rtnl_neightbl_alloc(void); extern void rtnl_neightbl_put(struct rtnl_neightbl *); extern void rtnl_neightbl_free(struct rtnl_neightbl *); -extern struct nl_cache *rtnl_neightbl_alloc_cache(struct nl_handle *); +extern int rtnl_neightbl_alloc_cache(struct nl_sock *, struct nl_cache **); extern struct rtnl_neightbl *rtnl_neightbl_get(struct nl_cache *, const char *, int); extern void rtnl_neightbl_dump(struct rtnl_neightbl *, FILE *, struct nl_dump_params *); -extern struct nl_msg *rtnl_neightbl_build_change_request(struct rtnl_neightbl *, - struct rtnl_neightbl *); -extern int rtnl_neightbl_change(struct nl_handle *, struct rtnl_neightbl *, +extern int rtnl_neightbl_build_change_request(struct rtnl_neightbl *, + struct rtnl_neightbl *, + struct nl_msg **); +extern int rtnl_neightbl_change(struct nl_sock *, struct rtnl_neightbl *, struct rtnl_neightbl *); extern void rtnl_neightbl_set_family(struct rtnl_neightbl *, int); diff --git a/include/netlink/route/nexthop.h b/include/netlink/route/nexthop.h index 984f4b5..2aa44dc 100644 --- a/include/netlink/route/nexthop.h +++ b/include/netlink/route/nexthop.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_ROUTE_NEXTHOP_H_ @@ -21,18 +21,42 @@ extern "C" { struct rtnl_nexthop; -extern struct rtnl_nexthop * rtnl_route_nh_alloc(void); -extern struct rtnl_nexthop * rtnl_route_nh_clone(struct rtnl_nexthop *); +enum { + NH_DUMP_FROM_ONELINE = -2, + NH_DUMP_FROM_DETAILS = -1, + NH_DUMP_FROM_ENV = 0, + /* > 0 reserved for nexthop index */ +}; + +extern struct rtnl_nexthop * rtnl_route_nh_alloc(void); +extern struct rtnl_nexthop * rtnl_route_nh_clone(struct rtnl_nexthop *); extern void rtnl_route_nh_free(struct rtnl_nexthop *); -extern void rtnl_route_nh_set_weight(struct rtnl_nexthop *, int); + +extern int rtnl_route_nh_compare(struct rtnl_nexthop *, + struct rtnl_nexthop *, + uint32_t, int); + +extern void rtnl_route_nh_dump(struct rtnl_nexthop *, + struct nl_dump_params *); + +extern void rtnl_route_nh_set_weight(struct rtnl_nexthop *, uint8_t); +extern uint8_t rtnl_route_nh_get_weight(struct rtnl_nexthop *); extern void rtnl_route_nh_set_ifindex(struct rtnl_nexthop *, int); +extern int rtnl_route_nh_get_ifindex(struct rtnl_nexthop *); extern void rtnl_route_nh_set_gateway(struct rtnl_nexthop *, struct nl_addr *); +extern struct nl_addr * rtnl_route_nh_get_gateway(struct rtnl_nexthop *); extern void rtnl_route_nh_set_flags(struct rtnl_nexthop *, unsigned int); extern void rtnl_route_nh_unset_flags(struct rtnl_nexthop *, unsigned int); extern unsigned int rtnl_route_nh_get_flags(struct rtnl_nexthop *); +extern void rtnl_route_nh_set_realms(struct rtnl_nexthop *, + uint32_t); +extern uint32_t rtnl_route_nh_get_realms(struct rtnl_nexthop *); + +extern char * rtnl_route_nh_flags2str(int, char *, size_t); +extern int rtnl_route_nh_str2flags(const char *); #ifdef __cplusplus } diff --git a/include/netlink/route/pktloc.h b/include/netlink/route/pktloc.h new file mode 100644 index 0000000..28e1dc2 --- /dev/null +++ b/include/netlink/route/pktloc.h @@ -0,0 +1,44 @@ +/* + * netlink/route/pktloc.h Packet Location Aliasing + * + * 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) 2010 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef NETLINK_PKTLOC_H_ +#define NETLINK_PKTLOC_H_ + +#include <netlink/netlink.h> +#include <netlink/cache.h> +#include <netlink/route/tc.h> + +#include <linux/tc_ematch/tc_em_cmp.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct rtnl_pktloc +{ + char * name; + uint8_t align:4; + uint8_t layer:4; + uint8_t flags; + uint16_t offset; + uint32_t mask; + + struct nl_list_head list; +}; + +extern int rtnl_pktloc_lookup(const char *, struct rtnl_pktloc **); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/netlink/route/qdisc-modules.h b/include/netlink/route/qdisc-modules.h index 802eac4..769625e 100644 --- a/include/netlink/route/qdisc-modules.h +++ b/include/netlink/route/qdisc-modules.h @@ -32,14 +32,16 @@ struct rtnl_qdisc_ops /** * Dump callbacks */ - int (*qo_dump[NL_DUMP_MAX+1])(struct rtnl_qdisc *, - struct nl_dump_params *, int); + void (*qo_dump[NL_DUMP_MAX+1])(struct rtnl_qdisc *, + struct nl_dump_params *); /** * Must return the contents supposed to be in TCA_OPTIONS */ struct nl_msg *(*qo_get_opts)(struct rtnl_qdisc *); + int (*qo_build_msg)(struct rtnl_qdisc *, struct nl_msg *); + /** * TCA_OPTIONS message parser */ diff --git a/include/netlink/route/qdisc.h b/include/netlink/route/qdisc.h index ee71304..5acd6e1 100644 --- a/include/netlink/route/qdisc.h +++ b/include/netlink/route/qdisc.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_QDISC_H_ @@ -24,60 +24,46 @@ struct rtnl_qdisc; extern struct nl_object_ops qdisc_obj_ops; -/* General */ -extern struct rtnl_qdisc * rtnl_qdisc_alloc(void); -extern void rtnl_qdisc_put(struct rtnl_qdisc *); - -/* Cache Management */ -extern struct nl_cache * rtnl_qdisc_alloc_cache(struct nl_handle *); -extern struct rtnl_qdisc * rtnl_qdisc_get(struct nl_cache *, - int, uint32_t); -extern struct rtnl_qdisc * rtnl_qdisc_get_by_parent(struct nl_cache *, - int, uint32_t); - -/* qdisc addition */ -extern struct nl_msg * rtnl_qdisc_build_add_request(struct rtnl_qdisc *, int); -extern int rtnl_qdisc_add(struct nl_handle *, struct rtnl_qdisc *, - int); - -/* qdisc modification */ -extern struct nl_msg * rtnl_qdisc_build_change_request(struct rtnl_qdisc *, - struct rtnl_qdisc *); -extern int rtnl_qdisc_change(struct nl_handle *, - struct rtnl_qdisc *, - struct rtnl_qdisc *); - -/* qdisc deletion */ -extern struct nl_msg * rtnl_qdisc_build_delete_request(struct rtnl_qdisc *); -extern int rtnl_qdisc_delete(struct nl_handle *, - struct rtnl_qdisc *); - -/* attribute modifications */ -extern void rtnl_qdisc_set_ifindex(struct rtnl_qdisc *, int); -extern int rtnl_qdisc_get_ifindex(struct rtnl_qdisc *); -extern void rtnl_qdisc_set_handle(struct rtnl_qdisc *, uint32_t); -extern uint32_t rtnl_qdisc_get_handle(struct rtnl_qdisc *); -extern void rtnl_qdisc_set_parent(struct rtnl_qdisc *, uint32_t); -extern uint32_t rtnl_qdisc_get_parent(struct rtnl_qdisc *); -extern void rtnl_qdisc_set_kind(struct rtnl_qdisc *, const char *); -extern char * rtnl_qdisc_get_kind(struct rtnl_qdisc *); -extern uint64_t rtnl_qdisc_get_stat(struct rtnl_qdisc *, - enum rtnl_tc_stats_id); - -/* iterators */ -extern void rtnl_qdisc_foreach_child(struct rtnl_qdisc *, - struct nl_cache *, - void (*cb)(struct nl_object *, - void *), - void *); - -extern void rtnl_qdisc_foreach_cls(struct rtnl_qdisc *, - struct nl_cache *, - void (*cb)(struct nl_object *, - void *), - void *); - -/* qdisc specific options */ +extern struct rtnl_qdisc *rtnl_qdisc_alloc(void); +extern void rtnl_qdisc_put(struct rtnl_qdisc *); + +extern int rtnl_qdisc_alloc_cache(struct nl_sock *, struct nl_cache **); +extern struct rtnl_qdisc *rtnl_qdisc_get(struct nl_cache *, int, uint32_t); +extern struct rtnl_qdisc *rtnl_qdisc_get_by_parent(struct nl_cache *, + int, uint32_t); + +extern int rtnl_qdisc_build_add_request(struct rtnl_qdisc *, int, + struct nl_msg **); +extern int rtnl_qdisc_add(struct nl_sock *, struct rtnl_qdisc *, int); + +extern int rtnl_qdisc_build_change_request(struct rtnl_qdisc *, + struct rtnl_qdisc *, + struct nl_msg **); +extern int rtnl_qdisc_change(struct nl_sock *, struct rtnl_qdisc *, + struct rtnl_qdisc *); + +extern int rtnl_qdisc_build_delete_request(struct rtnl_qdisc *, + struct nl_msg **); +extern int rtnl_qdisc_delete(struct nl_sock *, struct rtnl_qdisc *); + +extern void rtnl_qdisc_set_ifindex(struct rtnl_qdisc *, int); +extern int rtnl_qdisc_get_ifindex(struct rtnl_qdisc *); +extern void rtnl_qdisc_set_handle(struct rtnl_qdisc *, uint32_t); +extern uint32_t rtnl_qdisc_get_handle(struct rtnl_qdisc *); +extern void rtnl_qdisc_set_parent(struct rtnl_qdisc *, uint32_t); +extern uint32_t rtnl_qdisc_get_parent(struct rtnl_qdisc *); +extern void rtnl_qdisc_set_kind(struct rtnl_qdisc *, const char *); +extern char * rtnl_qdisc_get_kind(struct rtnl_qdisc *); +extern uint64_t rtnl_qdisc_get_stat(struct rtnl_qdisc *, enum rtnl_tc_stats_id); + +extern void rtnl_qdisc_foreach_child(struct rtnl_qdisc *, struct nl_cache *, + void (*cb)(struct nl_object *, void *), + void *); + +extern void rtnl_qdisc_foreach_cls(struct rtnl_qdisc *, struct nl_cache *, + void (*cb)(struct nl_object *, void *), + void *); + extern struct nl_msg * rtnl_qdisc_get_opts(struct rtnl_qdisc *); #ifdef __cplusplus diff --git a/include/netlink/route/route.h b/include/netlink/route/route.h index f59f36b..5729cd7 100644 --- a/include/netlink/route/route.h +++ b/include/netlink/route/route.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_ROUTE_H_ @@ -17,11 +17,16 @@ #include <netlink/addr.h> #include <netlink/data.h> #include <netlink/route/nexthop.h> +#include <netlink/route/rtnl.h> +#include <linux/in_route.h> #ifdef __cplusplus extern "C" { #endif +/* flags */ +#define ROUTE_CACHE_CONTENT 1 + struct rtnl_route; struct rtnl_rtcacheinfo @@ -38,85 +43,79 @@ struct rtnl_rtcacheinfo extern struct nl_object_ops route_obj_ops; -/* General */ extern struct rtnl_route * rtnl_route_alloc(void); -extern void rtnl_route_put(struct rtnl_route *); -extern struct nl_cache * rtnl_route_alloc_cache(struct nl_handle *); - -extern void rtnl_route_get(struct rtnl_route *); -extern void rtnl_route_put(struct rtnl_route *); - -extern struct nl_msg *rtnl_route_build_add_request(struct rtnl_route *, int); -extern int rtnl_route_add(struct nl_handle *, struct rtnl_route *, int); -extern struct nl_msg *rtnl_route_build_del_request(struct rtnl_route *, int); -extern int rtnl_route_del(struct nl_handle *, struct rtnl_route *, int); - -extern void rtnl_route_set_table(struct rtnl_route *, int); -extern int rtnl_route_get_table(struct rtnl_route *); -extern void rtnl_route_set_scope(struct rtnl_route *, int); -extern int rtnl_route_get_scope(struct rtnl_route *); -extern void rtnl_route_set_tos(struct rtnl_route *, int); -extern int rtnl_route_get_tos(struct rtnl_route *); -extern void rtnl_route_set_realms(struct rtnl_route *, realm_t); -extern realm_t rtnl_route_get_realms(struct rtnl_route *); -extern void rtnl_route_set_protocol(struct rtnl_route *, int); -extern int rtnl_route_get_protocol(struct rtnl_route *); -extern void rtnl_route_set_prio(struct rtnl_route *, int); -extern int rtnl_route_get_prio(struct rtnl_route *); -extern void rtnl_route_set_family(struct rtnl_route *, int); -extern int rtnl_route_get_family(struct rtnl_route *); -extern void rtnl_route_set_type(struct rtnl_route *, int); -extern int rtnl_route_get_type(struct rtnl_route *); -extern void rtnl_route_set_flags(struct rtnl_route *, - unsigned int); -extern void rtnl_route_unset_flags(struct rtnl_route *, - unsigned int); -extern unsigned int rtnl_route_get_flags(struct rtnl_route *); -extern int rtnl_route_set_metric(struct rtnl_route *, int, - unsigned int); -extern int rtnl_route_unset_metric(struct rtnl_route *, int); -extern unsigned int rtnl_route_get_metric(struct rtnl_route *, int); -extern int rtnl_route_set_dst(struct rtnl_route *, - struct nl_addr *); -extern struct nl_addr * rtnl_route_get_dst(struct rtnl_route *); -extern int rtnl_route_set_src(struct rtnl_route *, - struct nl_addr *); -extern struct nl_addr * rtnl_route_get_src(struct rtnl_route *); -extern int rtnl_route_set_gateway(struct rtnl_route *, - struct nl_addr *); -extern struct nl_addr * rtnl_route_get_gateway(struct rtnl_route *); -extern int rtnl_route_set_pref_src(struct rtnl_route *, - struct nl_addr *); -extern struct nl_addr * rtnl_route_get_pref_src(struct rtnl_route *); -extern void rtnl_route_set_oif(struct rtnl_route *, int); -extern int rtnl_route_get_oif(struct rtnl_route *); -extern void rtnl_route_set_iif(struct rtnl_route *, const char *); -extern char * rtnl_route_get_iif(struct rtnl_route *); -extern int rtnl_route_get_dst_len(struct rtnl_route *); -extern int rtnl_route_get_src_len(struct rtnl_route *); - -extern void rtnl_route_add_nexthop(struct rtnl_route *, - struct rtnl_nexthop *); -extern void rtnl_route_remove_nexthop(struct rtnl_nexthop *); -extern struct nl_list_head * rtnl_route_get_nexthops(struct rtnl_route *); -extern void rtnl_route_set_cacheinfo(struct rtnl_route *, - struct rtnl_rtcacheinfo *); -extern uint32_t rtnl_route_get_mp_algo(struct rtnl_route *); -extern void rtnl_route_set_mp_algo(struct rtnl_route *, uint32_t); - -extern char * rtnl_route_table2str(int, char *, size_t); -extern int rtnl_route_str2table(const char *); -extern int rtnl_route_read_table_names(const char *); - -extern char * rtnl_route_proto2str(int, char *, size_t); -extern int rtnl_route_str2proto(const char *); -extern int rtnl_route_read_protocol_names(const char *); - -extern char * rtnl_route_metric2str(int, char *, size_t); -extern int rtnl_route_str2metric(const char *); - -extern char * rtnl_route_nh_flags2str(int, char *, size_t); -extern int rtnl_route_nh_str2flags(const char *); +extern void rtnl_route_put(struct rtnl_route *); +extern int rtnl_route_alloc_cache(struct nl_sock *, int, int, + struct nl_cache **); + +extern void rtnl_route_get(struct rtnl_route *); +extern void rtnl_route_put(struct rtnl_route *); + +extern int rtnl_route_parse(struct nlmsghdr *, struct rtnl_route **); +extern int rtnl_route_build_msg(struct nl_msg *, struct rtnl_route *); + +extern int rtnl_route_build_add_request(struct rtnl_route *, int, + struct nl_msg **); +extern int rtnl_route_add(struct nl_sock *, struct rtnl_route *, int); +extern int rtnl_route_build_del_request(struct rtnl_route *, int, + struct nl_msg **); +extern int rtnl_route_delete(struct nl_sock *, struct rtnl_route *, int); + +extern void rtnl_route_set_table(struct rtnl_route *, uint32_t); +extern uint32_t rtnl_route_get_table(struct rtnl_route *); +extern void rtnl_route_set_scope(struct rtnl_route *, uint8_t); +extern uint8_t rtnl_route_get_scope(struct rtnl_route *); +extern void rtnl_route_set_tos(struct rtnl_route *, uint8_t); +extern uint8_t rtnl_route_get_tos(struct rtnl_route *); +extern void rtnl_route_set_protocol(struct rtnl_route *, uint8_t); +extern uint8_t rtnl_route_get_protocol(struct rtnl_route *); +extern void rtnl_route_set_priority(struct rtnl_route *, uint32_t); +extern uint32_t rtnl_route_get_priority(struct rtnl_route *); +extern int rtnl_route_set_family(struct rtnl_route *, uint8_t); +extern uint8_t rtnl_route_get_family(struct rtnl_route *); +extern int rtnl_route_set_type(struct rtnl_route *, uint8_t); +extern uint8_t rtnl_route_get_type(struct rtnl_route *); +extern void rtnl_route_set_flags(struct rtnl_route *, uint32_t); +extern void rtnl_route_unset_flags(struct rtnl_route *, uint32_t); +extern uint32_t rtnl_route_get_flags(struct rtnl_route *); +extern int rtnl_route_set_metric(struct rtnl_route *, int, unsigned int); +extern int rtnl_route_unset_metric(struct rtnl_route *, int); +extern int rtnl_route_get_metric(struct rtnl_route *, int, uint32_t *); +extern int rtnl_route_set_dst(struct rtnl_route *, struct nl_addr *); +extern struct nl_addr *rtnl_route_get_dst(struct rtnl_route *); +extern int rtnl_route_set_src(struct rtnl_route *, struct nl_addr *); +extern struct nl_addr *rtnl_route_get_src(struct rtnl_route *); +extern int rtnl_route_set_pref_src(struct rtnl_route *, struct nl_addr *); +extern struct nl_addr *rtnl_route_get_pref_src(struct rtnl_route *); +extern void rtnl_route_set_iif(struct rtnl_route *, int); +extern int rtnl_route_get_iif(struct rtnl_route *); +extern int rtnl_route_get_src_len(struct rtnl_route *); + +extern void rtnl_route_add_nexthop(struct rtnl_route *, + struct rtnl_nexthop *); +extern void rtnl_route_remove_nexthop(struct rtnl_route *, + struct rtnl_nexthop *); +extern struct nl_list_head *rtnl_route_get_nexthops(struct rtnl_route *); +extern int rtnl_route_get_nnexthops(struct rtnl_route *); + +extern void rtnl_route_foreach_nexthop(struct rtnl_route *r, + void (*cb)(struct rtnl_nexthop *, void *), + void *arg); + +extern struct rtnl_nexthop * rtnl_route_nexthop_n(struct rtnl_route *r, int n); + +extern int rtnl_route_guess_scope(struct rtnl_route *); + +extern char * rtnl_route_table2str(int, char *, size_t); +extern int rtnl_route_str2table(const char *); +extern int rtnl_route_read_table_names(const char *); + +extern char * rtnl_route_proto2str(int, char *, size_t); +extern int rtnl_route_str2proto(const char *); +extern int rtnl_route_read_protocol_names(const char *); + +extern char * rtnl_route_metric2str(int, char *, size_t); +extern int rtnl_route_str2metric(const char *); #ifdef __cplusplus } diff --git a/include/netlink/route/rtnl.h b/include/netlink/route/rtnl.h index 9d116cd..f551a5d 100644 --- a/include/netlink/route/rtnl.h +++ b/include/netlink/route/rtnl.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_RTNL_H_ @@ -23,8 +23,6 @@ extern "C" { * @{ */ -typedef uint32_t realm_t; - /** * Mask specying the size of each realm part * @ingroup rtnl @@ -51,7 +49,7 @@ typedef uint32_t realm_t; /* General */ -extern int nl_rtgen_request(struct nl_handle *, int, int, int); +extern int nl_rtgen_request(struct nl_sock *, int, int, int); /* Routing Type Translations */ extern char * nl_rtntype2str(int, char *, size_t); diff --git a/include/netlink/route/rule.h b/include/netlink/route/rule.h index d295b0d..928dc0f 100644 --- a/include/netlink/route/rule.h +++ b/include/netlink/route/rule.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_RULE_H_ @@ -27,15 +27,16 @@ struct rtnl_rule; extern struct rtnl_rule * rtnl_rule_alloc(void); extern void rtnl_rule_put(struct rtnl_rule *); -extern struct nl_cache * rtnl_rule_alloc_cache(struct nl_handle *); -extern struct nl_cache * rtnl_rule_alloc_cache_by_family(struct nl_handle *, - int); +extern int rtnl_rule_alloc_cache(struct nl_sock *, int, + struct nl_cache **); extern void rtnl_rule_dump(struct rtnl_rule *, FILE *, struct nl_dump_params *); -extern struct nl_msg * rtnl_rule_build_add_request(struct rtnl_rule *, int); -extern int rtnl_rule_add(struct nl_handle *, struct rtnl_rule *, int); -extern struct nl_msg * rtnl_rule_build_delete_request(struct rtnl_rule *, int); -extern int rtnl_rule_delete(struct nl_handle *, struct rtnl_rule *, int); +extern int rtnl_rule_build_add_request(struct rtnl_rule *, int, + struct nl_msg **); +extern int rtnl_rule_add(struct nl_sock *, struct rtnl_rule *, int); +extern int rtnl_rule_build_delete_request(struct rtnl_rule *, int, + struct nl_msg **); +extern int rtnl_rule_delete(struct nl_sock *, struct rtnl_rule *, int); /* attribute modification */ @@ -43,9 +44,7 @@ extern void rtnl_rule_set_family(struct rtnl_rule *, int); extern int rtnl_rule_get_family(struct rtnl_rule *); extern void rtnl_rule_set_prio(struct rtnl_rule *, int); extern int rtnl_rule_get_prio(struct rtnl_rule *); -#define rtnl_rule_set_fwmark(ptr, n) rtnl_rule_set_mark(ptr, n) extern void rtnl_rule_set_mark(struct rtnl_rule *, uint64_t); -#define rtnl_rule_get_fwmark(ptr) rtnl_rule_get_mark(ptr) extern uint64_t rtnl_rule_get_mark(struct rtnl_rule *); extern void rtnl_rule_set_table(struct rtnl_rule *, int); extern int rtnl_rule_get_table(struct rtnl_rule *); @@ -69,8 +68,8 @@ extern char * rtnl_rule_get_iif(struct rtnl_rule *); extern void rtnl_rule_set_classid(struct rtnl_rule *, uint32_t); extern uint32_t rtnl_rule_get_classid(struct rtnl_rule *); -extern void rtnl_rule_set_realms(struct rtnl_rule *, realm_t); -extern realm_t rtnl_rule_get_realms(struct rtnl_rule *); +extern void rtnl_rule_set_realms(struct rtnl_rule *, uint32_t); +extern uint32_t rtnl_rule_get_realms(struct rtnl_rule *); #ifdef __cplusplus } diff --git a/include/netlink/route/sch/htb.h b/include/netlink/route/sch/htb.h index 5d4d681..d44f039 100644 --- a/include/netlink/route/sch/htb.h +++ b/include/netlink/route/sch/htb.h @@ -30,9 +30,9 @@ extern void rtnl_htb_set_rate(struct rtnl_class *, uint32_t); extern void rtnl_htb_set_ceil(struct rtnl_class *, uint32_t); extern void rtnl_htb_set_rbuffer(struct rtnl_class *, uint32_t); extern void rtnl_htb_set_cbuffer(struct rtnl_class *, uint32_t); -extern void rtnl_htb_set_quantum(struct rtnl_class *class, uint32_t quantum); -extern void rtnl_htb_set_overhead(struct rtnl_class *class, uint8_t overhead); -extern void rtnl_htb_set_mpu(struct rtnl_class *class, uint8_t mpu); +extern void rtnl_htb_set_quantum(struct rtnl_class *, uint32_t quantum); +extern void rtnl_htb_set_overhead(struct rtnl_class *, uint8_t overhead); +extern void rtnl_htb_set_mpu(struct rtnl_class *, uint8_t mpu); #ifdef __cplusplus } diff --git a/include/netlink/route/sch/netem.h b/include/netlink/route/sch/netem.h index b100741..c293777 100644 --- a/include/netlink/route/sch/netem.h +++ b/include/netlink/route/sch/netem.h @@ -31,6 +31,13 @@ extern int rtnl_netem_get_reorder_probability(struct rtnl_qdisc *); extern int rtnl_netem_set_reorder_correlation(struct rtnl_qdisc *, int); extern int rtnl_netem_get_reorder_correlation(struct rtnl_qdisc *); +/* Corruption */ +extern int rtnl_netem_set_corruption_probability(struct rtnl_qdisc *, int); +extern int rtnl_netem_get_corruption_probability(struct rtnl_qdisc *); + +extern int rtnl_netem_set_corruption_correlation(struct rtnl_qdisc *, int); +extern int rtnl_netem_get_corruption_correlation(struct rtnl_qdisc *); + /* Packet Loss */ extern int rtnl_netem_set_loss(struct rtnl_qdisc *, int); extern int rtnl_netem_get_loss(struct rtnl_qdisc *); @@ -55,6 +62,12 @@ extern int rtnl_netem_get_jitter(struct rtnl_qdisc *); extern int rtnl_netem_set_delay_correlation(struct rtnl_qdisc *, int); extern int rtnl_netem_get_delay_correlation(struct rtnl_qdisc *); +/* Delay Distribution */ +#define MAXDIST 65536 +extern int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *, const char *); +extern int rtnl_netem_get_delay_distribution_size(struct rtnl_qdisc *); +extern int rtnl_netem_get_delay_distribution(struct rtnl_qdisc *, int16_t **); + #ifdef __cplusplus } #endif diff --git a/include/netlink/socket.h b/include/netlink/socket.h index 038df7a..7e71aed 100644 --- a/include/netlink/socket.h +++ b/include/netlink/socket.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_SOCKET_H_ @@ -19,45 +19,45 @@ extern "C" { #endif -extern struct nl_handle * nl_handle_alloc(void); -extern struct nl_handle * nl_handle_alloc_cb(struct nl_cb *); -extern void nl_handle_destroy(struct nl_handle *); +extern struct nl_sock * nl_socket_alloc(void); +extern struct nl_sock * nl_socket_alloc_cb(struct nl_cb *); +extern void nl_socket_free(struct nl_sock *); -extern uint32_t nl_socket_get_local_port(struct nl_handle *); -extern void nl_socket_set_local_port(struct nl_handle *, - uint32_t); +extern uint32_t nl_socket_get_local_port(struct nl_sock *); +extern void nl_socket_set_local_port(struct nl_sock *, uint32_t); -extern int nl_socket_add_membership(struct nl_handle *, - int); -extern int nl_socket_drop_membership(struct nl_handle *, +extern int nl_socket_add_memberships(struct nl_sock *, int, ...); +extern int nl_socket_add_membership(struct nl_sock *, int); +extern int nl_socket_drop_memberships(struct nl_sock *, int, ...); +extern int nl_socket_drop_membership(struct nl_sock *, int); -extern void nl_join_groups(struct nl_handle *, int); +extern void nl_join_groups(struct nl_sock *, int); -extern uint32_t nl_socket_get_peer_port(struct nl_handle *); -extern void nl_socket_set_peer_port(struct nl_handle *, + +extern uint32_t nl_socket_get_peer_port(struct nl_sock *); +extern void nl_socket_set_peer_port(struct nl_sock *, uint32_t); -extern struct nl_cb * nl_socket_get_cb(struct nl_handle *); -extern void nl_socket_set_cb(struct nl_handle *, +extern struct nl_cb * nl_socket_get_cb(struct nl_sock *); +extern void nl_socket_set_cb(struct nl_sock *, struct nl_cb *); -extern int nl_socket_modify_cb(struct nl_handle *, - enum nl_cb_type, - enum nl_cb_kind, - nl_recvmsg_msg_cb_t, - void *); +extern int nl_socket_modify_cb(struct nl_sock *, enum nl_cb_type, + enum nl_cb_kind, + nl_recvmsg_msg_cb_t, void *); -extern int nl_set_buffer_size(struct nl_handle *, - int, int); -extern int nl_set_passcred(struct nl_handle *, int); -extern int nl_socket_recv_pktinfo(struct nl_handle *, int); +extern int nl_socket_set_buffer_size(struct nl_sock *, int, int); +extern int nl_socket_set_passcred(struct nl_sock *, int); +extern int nl_socket_recv_pktinfo(struct nl_sock *, int); -extern void nl_disable_sequence_check(struct nl_handle *); -extern unsigned int nl_socket_use_seq(struct nl_handle *); +extern void nl_socket_disable_seq_check(struct nl_sock *); +extern unsigned int nl_socket_use_seq(struct nl_sock *); +extern void nl_socket_disable_auto_ack(struct nl_sock *); +extern void nl_socket_enable_auto_ack(struct nl_sock *); -extern int nl_socket_get_fd(struct nl_handle *); -extern int nl_socket_set_nonblocking(struct nl_handle *); -extern void nl_socket_enable_msg_peek(struct nl_handle *); -extern void nl_socket_disable_msg_peek(struct nl_handle *); +extern int nl_socket_get_fd(struct nl_sock *); +extern int nl_socket_set_nonblocking(struct nl_sock *); +extern void nl_socket_enable_msg_peek(struct nl_sock *); +extern void nl_socket_disable_msg_peek(struct nl_sock *); #ifdef __cplusplus } diff --git a/include/netlink/types.h b/include/netlink/types.h index 903028e..2e0b9c3 100644 --- a/include/netlink/types.h +++ b/include/netlink/types.h @@ -19,12 +19,10 @@ * @ingroup utils */ enum nl_dump_type { - NL_DUMP_BRIEF, /**< Dump object in a brief one-liner */ - NL_DUMP_FULL, /**< Dump all attributes but no statistics */ + NL_DUMP_LINE, /**< Dump object briefly on one line */ + NL_DUMP_DETAILS, /**< Dump all attributes but no statistics */ NL_DUMP_STATS, /**< Dump all attributes including statistics */ - NL_DUMP_XML, /**< Dump all attribtes in XML format */ NL_DUMP_ENV, /**< Dump all attribtues as env variables */ - NL_DUMP_EVENTS, /**< Dump event */ __NL_DUMP_MAX, }; #define NL_DUMP_MAX (__NL_DUMP_MAX - 1) @@ -100,6 +98,14 @@ struct nl_dump_params * Set if a dump was performed prior to the actual dump handler. */ int dp_pre_dump; + + /** + * PRIVATE + * Owned by the current caller + */ + int dp_ivar; + + unsigned int dp_line; }; #endif diff --git a/include/netlink/utils.h b/include/netlink/utils.h index 0351d38..480bab6 100644 --- a/include/netlink/utils.h +++ b/include/netlink/utils.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_UTILS_H_ @@ -38,10 +38,6 @@ extern "C" { /** @} */ -extern char * nl_geterror(void); -extern int nl_get_errno(void); -extern void nl_perror(const char *); - /* unit pretty-printing */ extern double nl_cancel_down_bytes(unsigned long long, char **); extern double nl_cancel_down_bits(unsigned long long, char **); @@ -55,6 +51,7 @@ extern long nl_prob2int(const char *); extern int nl_get_hz(void); extern uint32_t nl_us2ticks(uint32_t); extern uint32_t nl_ticks2us(uint32_t); +extern int nl_str2msec(const char *, uint64_t *); extern char * nl_msec2str(uint64_t, char *, size_t); /* link layer protocol translations */ @@ -70,9 +67,9 @@ extern char * nl_ip_proto2str(int, char *, size_t); extern int nl_str2ip_proto(const char *); /* Dumping helpers */ -extern void nl_new_line(struct nl_dump_params *, int); +extern void nl_new_line(struct nl_dump_params *); extern void nl_dump(struct nl_dump_params *, const char *, ...); -extern void nl_dump_line(struct nl_dump_params *, int, const char *, ...); +extern void nl_dump_line(struct nl_dump_params *, const char *, ...); #ifdef __cplusplus } diff --git a/include/netlink/version.h b/include/netlink/version.h new file mode 100644 index 0000000..84af8f3 --- /dev/null +++ b/include/netlink/version.h @@ -0,0 +1,18 @@ +/* + * netlink/version.h Compile Time Versioning Information + * + * 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) 2008 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef NETLINK_VERSION_H_ +#define NETLINK_VERSION_H_ + +#define LIBNL_STRING "libnl 2.0" +#define LIBNL_VERSION "2.0" + +#endif diff --git a/include/netlink/version.h.in b/include/netlink/version.h.in new file mode 100644 index 0000000..7bd38cc --- /dev/null +++ b/include/netlink/version.h.in @@ -0,0 +1,18 @@ +/* + * netlink/version.h Compile Time Versioning Information + * + * 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) 2008 Thomas Graf <tgraf@suug.ch> + */ + +#ifndef NETLINK_VERSION_H_ +#define NETLINK_VERSION_H_ + +#define LIBNL_STRING "@PACKAGE_STRING@" +#define LIBNL_VERSION "@PACKAGE_VERSION@" + +#endif |