Skip to content
Snippets Groups Projects
Commit 6ccf7349 authored by Jean-Baptiste Queru's avatar Jean-Baptiste Queru
Browse files

Move libnl headers to their own project

Change-Id: I322663ef963df79ef7016f3e8f9480358ce9b0c3
parent 589786e4
Branches aosp-new/aosp-new/ics-aah-release aosp-new/aosp-new/ics-factoryrom-2-release aosp-new/aosp-new/ics-mr0 aosp-new/aosp-new/ics-mr0-release aosp-new/aosp-new/ics-mr1 aosp-new/aosp-new/ics-mr1-release aosp-new/aosp-new/ics-plus-aosp aosp-new/aosp-new/jb-dev aosp-new/aosp-new/jb-mr0-release aosp-new/aosp-new/jb-mr1-dev aosp-new/aosp-new/jb-mr1-dev-plus-aosp aosp-new/aosp-new/jb-mr1-factory-release aosp-new/aosp-new/jb-mr1-release aosp-new/aosp-new/jb-mr1.1-dev aosp-new/aosp-new/jb-mr1.1-dev-plus-aosp aosp-new/aosp-new/jb-mr1.1-release aosp-new/aosp-new/jb-mr2-dev aosp-new/aosp-new/jb-mr2-release aosp-new/aosp-new/jb-mr2.0-release aosp-new/aosp-new/jb-mr2.0.0-release aosp-new/aosp-new/jb-release aosp-new/aosp-new/kitkat-cts-dev aosp-new/aosp-new/kitkat-cts-release aosp-new/aosp-new/kitkat-mr1-release aosp-new/aosp-new/kitkat-mr1.1-release aosp-new/aosp-new/kitkat-release aosp-new/aosp-new/tools_r20 aosp-new/aosp-new/tools_r21 aosp-new/aosp-new/tools_r22 aosp-new/aosp-new/tools_r22.2 aosp-new/ics-aah-release aosp-new/ics-factoryrom-2-release aosp-new/ics-mr0 aosp-new/ics-mr0-release aosp-new/ics-mr1 aosp-new/ics-mr1-release aosp-new/ics-plus-aosp aosp-new/jb-dev aosp-new/jb-mr0-release aosp-new/jb-mr1-dev aosp-new/jb-mr1-dev-plus-aosp aosp-new/jb-mr1-factory-release aosp-new/jb-mr1-release aosp-new/jb-mr1.1-dev aosp-new/jb-mr1.1-dev-plus-aosp aosp-new/jb-mr1.1-release aosp-new/jb-mr2-dev aosp-new/jb-mr2-release aosp-new/jb-mr2.0-release aosp-new/jb-mr2.0.0-release aosp-new/jb-release aosp-new/kitkat-cts-dev aosp-new/kitkat-cts-release aosp-new/kitkat-mr1-release aosp-new/kitkat-mr1.1-release aosp-new/kitkat-release aosp-new/tools_r20 aosp-new/tools_r21 aosp-new/tools_r22 aosp-new/tools_r22.2 caf_migration/LNX.LA.2.7.4 caf_migration/LNX.LA.3.2.1.5 caf_migration/LNX.LA.3.2.1.5.c1 caf_migration/LNX.LA.3.2.5.1 caf_migration/LNX.LA.3.2.7 caf_migration/LNX.LA.3.2.7_rb1 caf_migration/LNX.LA.3.5.1.1 caf_migration/LNX.LA.3.5.1.1.1 caf_migration/LNX.LA.3.5.1.5 caf_migration/LNX.LA.3.5.1_RB1.1 caf_migration/LNX.LA.3.5.2.1.1 caf_migration/LNX.LA.3.5.2.1.2 caf_migration/LNX.LA.3.5.2.1.5 caf_migration/LNX.LA.3.5.2.1_RB1.1 caf_migration/LNX.LA.3.5.2_RB1 caf_migration/LNX.LA.3.5.3 caf_migration/LNX.LA.3.5.3.1 caf_migration/LNX.LA.3.5.3.2 caf_migration/LNX.LA.3.5.3_RB1.1 caf_migration/LNX.LA.3.5.3_RB1.2 caf_migration/LNX.LA.3.5.3_RB1.3 caf_migration/LNX.LA.3.5.3_RB1.4 caf_migration/LNX.LA.3.5.3_RB2.2 caf_migration/LNX.LA.3.5.3_RB2.3 caf_migration/LNX.LA.3.5.3_RB2.4 caf_migration/LNX.LA.3.5.3_RB2.5 caf_migration/LNX.LA.3.6.1.c2 caf_migration/LNX.LA.3.6_rb1.1 caf_migration/LNX.LA.3.6_rb1.11 caf_migration/LNX.LA.3.6_rb1.13 caf_migration/LNX.LA.3.6_rb1.16 caf_migration/LNX.LA.3.6_rb1.3 caf_migration/LNX.LA.3.6_rb1.7 caf_migration/LNX.LA.3.6_rb1.9 caf_migration/LNX.LA.3.6_rb2.2 caf_migration/LNX.LA.3.6_rb2.3 caf_migration/LNX.LA.3.6_rb2.4 caf_migration/LNX.LA.3.7.1.c2 caf_migration/LNX.LA.3.7.1_CTA caf_migration/LNX.LA.3.7.1_HW
Tags android-4.0.1_r1 android-4.0.1_r1.1 android-4.0.1_r1.2 android-4.0.2_r1 android-4.0.3_r1 android-4.0.3_r1.1 android-4.0.4-aah_r1 android-4.0.4_r1 android-4.0.4_r1.1 android-4.0.4_r1.2 android-4.0.4_r2 android-4.0.4_r2.1 android-4.1-sdk_pre1 android-4.1.1_r1 android-4.1.1_r1.1 android-4.1.1_r2 android-4.1.1_r3 android-4.1.1_r4 android-4.1.1_r5 android-4.1.1_r6 android-4.1.1_r6.1 android-4.1.2_r1 android-4.1.2_r2 android-4.1.2_r2.1 android-4.1_pre1 android-4.1_pre2 android-4.2.1_r1 android-4.2.1_r1.1 android-4.2.1_r1.2 android-4.2.2_r1 android-4.2.2_r1.1 android-4.2.2_r1.2 android-4.2_pre1 android-4.2_pre1.1 android-4.2_pre2 android-4.2_pre2.1 android-4.2_pre2.2 android-4.2_pre3 android-4.2_r1 android-4.3.1_r1 android-4.3_r0.9 android-4.3_r0.9.1 android-4.3_r1 android-4.3_r1.1 android-4.3_r2 android-4.3_r2.1 android-4.3_r2.2 android-4.3_r2.3 android-4.3_r3 android-4.3_r3.1 android-4.4.1_r1 android-4.4.1_r1.0.1 android-4.4.2_r1 android-4.4.2_r1.0.1 android-4.4.2_r2 android-4.4.2_r2.0.1 android-4.4_r0.7 android-4.4_r0.8 android-4.4_r0.9 android-4.4_r1 android-4.4_r1.0.1 android-4.4_r1.1 android-4.4_r1.1.0.1 android-4.4_r1.2 android-4.4_r1.2.0.1 android-cts-4.0.3_r1 android-cts-4.0.3_r2 android-cts-4.0_r1 android-cts-4.1_r1 android-cts-4.1_r2 android-cts-4.1_r4 android-cts-4.2_r1 android-cts-4.2_r2 android-cts-4.4_r1 android-cts-4.4_r4 android-cts-verifier-4.0.3_r1 android-cts-verifier-4.0_r1 android-sdk-4.0.3-tools_r1 android-sdk-4.0.3_r1 android-sdk-4.4.2_r1 android-sdk-4.4.2_r1.0.1 android-sdk-adt_r16.0.1 android-sdk-adt_r20 android-sdk-support_r11
No related merge requests found
# Copyright (C) 2007 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# If you don't need to do a full clean build but would like to touch
# a file or delete some intermediate files, add a clean step to the end
# of the list. These steps will only be run once, if they haven't been
# run before.
#
# E.g.:
# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
#
# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
# files that are missing or have been moved.
#
# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
# Use $(OUT_DIR) to refer to the "out" directory.
#
# If you need to re-do something that's already mentioned, just copy
# the command and add it to the bottom of the list. E.g., if a change
# that you made last week required touching a file and a change you
# made today requires touching the same file, just copy the old
# touch step and add it to the end of the list.
#
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
# For example:
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
NOTICE 0 → 100644
This diff is collapsed.
/*
* netlink-generic.h Local Generic Netlink Interface
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_GENL_PRIV_H_
#define NETLINK_GENL_PRIV_H_
#include <netlink-local.h>
#include <netlink/netlink.h>
#define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen))
#endif
/*
* netlink-local.h Local Netlink Interface
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_LOCAL_H_
#define NETLINK_LOCAL_H_
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <inttypes.h>
#include <assert.h>
#include <limits.h>
#include <arpa/inet.h>
#include <netdb.h>
#ifndef SOL_NETLINK
#define SOL_NETLINK 270
#endif
#include <linux/types.h>
/* local header copies */
#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/pkt_sched.h>
#include <linux/pkt_cls.h>
#include <linux/gen_stats.h>
#include <linux/ip_mp_alg.h>
#include <netlink/netlink.h>
#include <netlink/handlers.h>
#include <netlink/cache.h>
#include <netlink/route/tc.h>
#include <netlink/object-api.h>
#include <netlink/cache-api.h>
#include <netlink-types.h>
struct trans_tbl {
int i;
const char *a;
};
#define __ADD(id, name) { .i = id, .a = #name },
struct trans_list {
int i;
char *a;
struct nl_list_head list;
};
#define NL_DEBUG 1
#define NL_DBG(LVL,FMT,ARG...) \
do { \
if (LVL <= nl_debug) \
fprintf(stderr, "DBG<" #LVL ">: " FMT, ##ARG); \
} while (0)
#define BUG() \
do { \
fprintf(stderr, "BUG: %s:%d\n", \
__FILE__, __LINE__); \
assert(0); \
} while (0)
extern int __nl_read_num_str_file(const char *path,
int (*cb)(long, const char *));
extern int __trans_list_add(int, const char *, struct nl_list_head *);
extern void __trans_list_clear(struct nl_list_head *);
extern char *__type2str(int, char *, size_t, struct trans_tbl *, size_t);
extern int __str2type(const char *, struct trans_tbl *, size_t);
extern char *__list_type2str(int, char *, size_t, struct nl_list_head *);
extern int __list_str2type(const char *, struct nl_list_head *);
extern char *__flags2str(int, char *, size_t, struct trans_tbl *, size_t);
extern int __str2flags(const char *, struct trans_tbl *, size_t);
extern void dump_from_ops(struct nl_object *, struct nl_dump_params *);
static inline struct nl_cache *dp_cache(struct nl_object *obj)
{
if (obj->ce_cache == NULL)
return nl_cache_mngt_require(obj->ce_ops->oo_name);
return obj->ce_cache;
}
static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg)
{
return cb->cb_set[type](msg, cb->cb_args[type]);
}
#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
#define __init __attribute__ ((constructor))
#define __exit __attribute__ ((destructor))
#undef __deprecated
#define __deprecated __attribute__ ((deprecated))
#define min(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })
#define max(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x > _y ? _x : _y; })
#define min_t(type,x,y) \
({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
#define max_t(type,x,y) \
({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *,
struct nlmsghdr *, struct nl_parser_param *);
static inline void rtnl_copy_ratespec(struct rtnl_ratespec *dst,
struct tc_ratespec *src)
{
dst->rs_cell_log = src->cell_log;
dst->rs_feature = src->feature;
dst->rs_addend = src->addend;
dst->rs_mpu = src->mpu;
dst->rs_rate = src->rate;
}
static inline void rtnl_rcopy_ratespec(struct tc_ratespec *dst,
struct rtnl_ratespec *src)
{
dst->cell_log = src->rs_cell_log;
dst->feature = src->rs_feature;
dst->addend = src->rs_addend;
dst->mpu = src->rs_mpu;
dst->rate = src->rs_rate;
}
static inline char *nl_cache_name(struct nl_cache *cache)
{
return cache->c_ops ? cache->c_ops->co_name : "unknown";
}
#define GENL_FAMILY(id, name) \
{ \
{ id, NL_ACT_UNSPEC, name }, \
END_OF_MSGTYPES_LIST, \
}
static inline int wait_for_ack(struct nl_sock *sk)
{
if (sk->s_flags & NL_NO_AUTO_ACK)
return 0;
else
return nl_wait_for_ack(sk);
}
#endif
/*
* netlink-types.h Netlink Types (Private)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_LOCAL_TYPES_H_
#define NETLINK_LOCAL_TYPES_H_
#include <netlink/list.h>
#include <netlink/route/link.h>
#include <netlink/route/qdisc.h>
#include <netlink/route/rtnl.h>
#include <netlink/route/route.h>
#include <netlink/object-api.h>
#include <linux/socket.h>
#include <linux/pkt_sched.h>
#define NL_SOCK_BUFSIZE_SET (1<<0)
#define NL_SOCK_PASSCRED (1<<1)
#define NL_OWN_PORT (1<<2)
#define NL_MSG_PEEK (1<<3)
#define NL_NO_AUTO_ACK (1<<4)
#define NL_MSG_CRED_PRESENT 1
struct nl_cache_ops;
struct nl_sock;
struct nl_object;
struct nl_cb
{
nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1];
void * cb_args[NL_CB_TYPE_MAX+1];
nl_recvmsg_err_cb_t cb_err;
void * cb_err_arg;
/** May be used to replace nl_recvmsgs with your own implementation
* in all internal calls to nl_recvmsgs. */
int (*cb_recvmsgs_ow)(struct nl_sock *,
struct nl_cb *);
/** Overwrite internal calls to nl_recv, must return the number of
* octets read and allocate a buffer for the received data. */
int (*cb_recv_ow)(struct nl_sock *,
struct sockaddr_nl *,
unsigned char **,
struct ucred **);
/** Overwrites internal calls to nl_send, must send the netlink
* message. */
int (*cb_send_ow)(struct nl_sock *,
struct nl_msg *);
int cb_refcnt;
};
struct nl_sock
{
struct sockaddr_nl s_local;
struct sockaddr_nl s_peer;
int s_fd;
int s_proto;
unsigned int s_seq_next;
unsigned int s_seq_expect;
int s_flags;
struct nl_cb * s_cb;
};
struct nl_cache
{
struct nl_list_head c_items;
int c_nitems;
int c_iarg1;
int c_iarg2;
struct nl_cache_ops * c_ops;
};
struct nl_cache_assoc
{
struct nl_cache * ca_cache;
change_func_t ca_change;
void * ca_change_data;
};
struct nl_cache_mngr
{
int cm_protocol;
int cm_flags;
int cm_nassocs;
struct nl_sock * cm_handle;
struct nl_cache_assoc * cm_assocs;
};
struct nl_parser_param;
#define LOOSE_COMPARISON 1
#define NL_OBJ_MARK 1
struct nl_object
{
NLHDR_COMMON
};
struct nl_data
{
size_t d_size;
void * d_data;
};
struct nl_addr
{
int a_family;
unsigned int a_maxsize;
unsigned int a_len;
int a_prefixlen;
int a_refcnt;
char a_addr[0];
};
struct nl_msg
{
int nm_protocol;
int nm_flags;
struct sockaddr_nl nm_src;
struct sockaddr_nl nm_dst;
struct ucred nm_creds;
struct nlmsghdr * nm_nlh;
size_t nm_size;
int nm_refcnt;
};
struct rtnl_link_map
{
uint64_t lm_mem_start;
uint64_t lm_mem_end;
uint64_t lm_base_addr;
uint16_t lm_irq;
uint8_t lm_dma;
uint8_t lm_port;
};
#define IFQDISCSIZ 32
struct rtnl_link
{
NLHDR_COMMON
char l_name[IFNAMSIZ];
uint32_t l_family;
uint32_t l_arptype;
uint32_t l_index;
uint32_t l_flags;
uint32_t l_change;
uint32_t l_mtu;
uint32_t l_link;
uint32_t l_txqlen;
uint32_t l_weight;
uint32_t l_master;
struct nl_addr *l_addr;
struct nl_addr *l_bcast;
char l_qdisc[IFQDISCSIZ];
struct rtnl_link_map l_map;
uint64_t l_stats[RTNL_LINK_STATS_MAX+1];
uint32_t l_flag_mask;
uint8_t l_operstate;
uint8_t l_linkmode;
/* 2 byte hole */
struct rtnl_link_info_ops *l_info_ops;
void * l_info;
};
struct rtnl_ncacheinfo
{
uint32_t nci_confirmed; /**< Time since neighbour validty was last confirmed */
uint32_t nci_used; /**< Time since neighbour entry was last ued */
uint32_t nci_updated; /**< Time since last update */
uint32_t nci_refcnt; /**< Reference counter */
};
struct rtnl_neigh
{
NLHDR_COMMON
uint32_t n_family;
uint32_t n_ifindex;
uint16_t n_state;
uint8_t n_flags;
uint8_t n_type;
struct nl_addr *n_lladdr;
struct nl_addr *n_dst;
uint32_t n_probes;
struct rtnl_ncacheinfo n_cacheinfo;
uint32_t n_state_mask;
uint32_t n_flag_mask;
};
struct rtnl_addr_cacheinfo
{
/* Preferred lifetime in seconds */
uint32_t aci_prefered;
/* Valid lifetime in seconds */
uint32_t aci_valid;
/* Timestamp of creation in 1/100s seince boottime */
uint32_t aci_cstamp;
/* Timestamp of last update in 1/100s since boottime */
uint32_t aci_tstamp;
};
struct rtnl_addr
{
NLHDR_COMMON
uint8_t a_family;
uint8_t a_prefixlen;
uint8_t a_flags;
uint8_t a_scope;
uint32_t a_ifindex;
struct nl_addr *a_peer;
struct nl_addr *a_local;
struct nl_addr *a_bcast;
struct nl_addr *a_anycast;
struct nl_addr *a_multicast;
struct rtnl_addr_cacheinfo a_cacheinfo;
char a_label[IFNAMSIZ];
uint32_t a_flag_mask;
};
struct rtnl_nexthop
{
uint8_t rtnh_flags;
uint8_t rtnh_flag_mask;
uint8_t rtnh_weight;
/* 1 byte spare */
uint32_t rtnh_ifindex;
struct nl_addr * rtnh_gateway;
uint32_t ce_mask; /* HACK to support attr macros */
struct nl_list_head rtnh_list;
uint32_t rtnh_realms;
};
struct rtnl_route
{
NLHDR_COMMON
uint8_t rt_family;
uint8_t rt_dst_len;
uint8_t rt_src_len;
uint8_t rt_tos;
uint8_t rt_protocol;
uint8_t rt_scope;
uint8_t rt_type;
uint8_t rt_nmetrics;
uint32_t rt_flags;
struct nl_addr * rt_dst;
struct nl_addr * rt_src;
uint32_t rt_table;
uint32_t rt_iif;
uint32_t rt_prio;
uint32_t rt_metrics[RTAX_MAX];
uint32_t rt_metrics_mask;
uint32_t rt_nr_nh;
struct nl_addr * rt_pref_src;
struct nl_list_head rt_nexthops;
struct rtnl_rtcacheinfo rt_cacheinfo;
uint32_t rt_flag_mask;
};
struct rtnl_rule
{
NLHDR_COMMON
uint64_t r_mark;
uint32_t r_prio;
uint32_t r_realms;
uint32_t r_table;
uint8_t r_dsfield;
uint8_t r_type;
uint8_t r_family;
uint8_t r_src_len;
uint8_t r_dst_len;
char r_iif[IFNAMSIZ];
struct nl_addr *r_src;
struct nl_addr *r_dst;
struct nl_addr *r_srcmap;
};
struct rtnl_neightbl_parms
{
/**
* Interface index of the device this parameter set is assigned
* to or 0 for the default set.
*/
uint32_t ntp_ifindex;
/**
* Number of references to this parameter set.
*/
uint32_t ntp_refcnt;
/**
* Queue length for pending arp requests, i.e. the number of
* packets which are accepted from other layers while the
* neighbour address is still being resolved
*/
uint32_t ntp_queue_len;
/**
* Number of requests to send to the user level ARP daemon.
* Specify 0 to disable.
*/
uint32_t ntp_app_probes;
/**
* Maximum number of retries for unicast solicitation.
*/
uint32_t ntp_ucast_probes;
/**
* Maximum number of retries for multicast solicitation.
*/
uint32_t ntp_mcast_probes;
/**
* Base value in milliseconds to ompute reachable time, see RFC2461.
*/
uint64_t ntp_base_reachable_time;
/**
* Actual reachable time (read-only)
*/
uint64_t ntp_reachable_time; /* secs */
/**
* The time in milliseconds between retransmitted Neighbor
* Solicitation messages.
*/
uint64_t ntp_retrans_time;
/**
* Interval in milliseconds to check for stale neighbour
* entries.
*/
uint64_t ntp_gc_stale_time; /* secs */
/**
* Delay in milliseconds for the first time probe if
* the neighbour is reachable.
*/
uint64_t ntp_probe_delay; /* secs */
/**
* Maximum delay in milliseconds of an answer to a neighbour
* solicitation message.
*/
uint64_t ntp_anycast_delay;
/**
* Minimum age in milliseconds before a neighbour entry
* may be replaced.
*/
uint64_t ntp_locktime;
/**
* Delay in milliseconds before answering to an ARP request
* for which a proxy ARP entry exists.
*/
uint64_t ntp_proxy_delay;
/**
* Queue length for the delayed proxy arp requests.
*/
uint32_t ntp_proxy_qlen;
/**
* Mask of available parameter attributes
*/
uint32_t ntp_mask;
};
#define NTBLNAMSIZ 32
/**
* Neighbour table
* @ingroup neightbl
*/
struct rtnl_neightbl
{
NLHDR_COMMON
char nt_name[NTBLNAMSIZ];
uint32_t nt_family;
uint32_t nt_gc_thresh1;
uint32_t nt_gc_thresh2;
uint32_t nt_gc_thresh3;
uint64_t nt_gc_interval;
struct ndt_config nt_config;
struct rtnl_neightbl_parms nt_parms;
struct ndt_stats nt_stats;
};
struct rtnl_ratespec
{
uint8_t rs_cell_log;
uint16_t rs_feature;
uint16_t rs_addend;
uint16_t rs_mpu;
uint32_t rs_rate;
};
struct rtnl_tstats
{
struct {
uint64_t bytes;
uint64_t packets;
} tcs_basic;
struct {
uint32_t bps;
uint32_t pps;
} tcs_rate_est;
struct {
uint32_t qlen;
uint32_t backlog;
uint32_t drops;
uint32_t requeues;
uint32_t overlimits;
} tcs_queue;
};
#define TCKINDSIZ 32
#define NL_TCA_GENERIC(pre) \
NLHDR_COMMON \
uint32_t pre ##_family; \
uint32_t pre ##_ifindex; \
uint32_t pre ##_handle; \
uint32_t pre ##_parent; \
uint32_t pre ##_info; \
char pre ##_kind[TCKINDSIZ]; \
struct nl_data * pre ##_opts; \
uint64_t pre ##_stats[RTNL_TC_STATS_MAX+1]; \
struct nl_data * pre ##_xstats; \
struct nl_data * pre ##_subdata; \
struct rtnl_tca
{
NL_TCA_GENERIC(tc);
};
struct rtnl_qdisc
{
NL_TCA_GENERIC(q);
struct rtnl_qdisc_ops *q_ops;
};
struct rtnl_class
{
NL_TCA_GENERIC(c);
struct rtnl_class_ops *c_ops;
};
struct rtnl_cls
{
NL_TCA_GENERIC(c);
uint16_t c_prio;
uint16_t c_protocol;
struct rtnl_cls_ops *c_ops;
};
struct rtnl_u32
{
uint32_t cu_divisor;
uint32_t cu_hash;
uint32_t cu_classid;
uint32_t cu_link;
struct nl_data * cu_pcnt;
struct nl_data * cu_selector;
struct nl_data * cu_act;
struct nl_data * cu_police;
char cu_indev[IFNAMSIZ];
int cu_mask;
};
struct rtnl_cgroup
{
struct rtnl_ematch_tree *cg_ematch;
int cg_mask;
};
struct rtnl_fw
{
uint32_t cf_classid;
struct nl_data * cf_act;
struct nl_data * cf_police;
char cf_indev[IFNAMSIZ];
int cf_mask;
};
struct rtnl_ematch
{
uint16_t e_id;
uint16_t e_kind;
uint16_t e_flags;
struct nl_list_head e_childs;
struct nl_list_head e_list;
struct rtnl_ematch_ops *e_ops;
char e_data[0];
};
struct rtnl_ematch_tree
{
uint16_t et_progid;
struct nl_list_head et_list;
};
struct rtnl_dsmark_qdisc
{
uint16_t qdm_indices;
uint16_t qdm_default_index;
uint32_t qdm_set_tc_index;
uint32_t qdm_mask;
};
struct rtnl_dsmark_class
{
uint8_t cdm_bmask;
uint8_t cdm_value;
uint32_t cdm_mask;
};
struct rtnl_fifo
{
uint32_t qf_limit;
uint32_t qf_mask;
};
struct rtnl_prio
{
uint32_t qp_bands;
uint8_t qp_priomap[TC_PRIO_MAX+1];
uint32_t qp_mask;
};
struct rtnl_tbf
{
uint32_t qt_limit;
uint32_t qt_mpu;
struct rtnl_ratespec qt_rate;
uint32_t qt_rate_bucket;
uint32_t qt_rate_txtime;
struct rtnl_ratespec qt_peakrate;
uint32_t qt_peakrate_bucket;
uint32_t qt_peakrate_txtime;
uint32_t qt_mask;
};
struct rtnl_sfq
{
uint32_t qs_quantum;
uint32_t qs_perturb;
uint32_t qs_limit;
uint32_t qs_divisor;
uint32_t qs_flows;
uint32_t qs_mask;
};
struct rtnl_netem_corr
{
uint32_t nmc_delay;
uint32_t nmc_loss;
uint32_t nmc_duplicate;
};
struct rtnl_netem_reo
{
uint32_t nmro_probability;
uint32_t nmro_correlation;
};
struct rtnl_netem_crpt
{
uint32_t nmcr_probability;
uint32_t nmcr_correlation;
};
struct rtnl_netem_dist
{
int16_t * dist_data;
size_t dist_size;
};
struct rtnl_netem
{
uint32_t qnm_latency;
uint32_t qnm_limit;
uint32_t qnm_loss;
uint32_t qnm_gap;
uint32_t qnm_duplicate;
uint32_t qnm_jitter;
uint32_t qnm_mask;
struct rtnl_netem_corr qnm_corr;
struct rtnl_netem_reo qnm_ro;
struct rtnl_netem_crpt qnm_crpt;
struct rtnl_netem_dist qnm_dist;
};
struct rtnl_htb_qdisc
{
uint32_t qh_rate2quantum;
uint32_t qh_defcls;
uint32_t qh_mask;
};
struct rtnl_htb_class
{
uint32_t ch_prio;
uint32_t ch_mtu;
struct rtnl_ratespec ch_rate;
struct rtnl_ratespec ch_ceil;
uint32_t ch_rbuffer;
uint32_t ch_cbuffer;
uint32_t ch_quantum;
uint8_t ch_overhead;
uint8_t ch_mpu;
uint32_t ch_mask;
};
struct rtnl_cbq
{
struct tc_cbq_lssopt cbq_lss;
struct tc_ratespec cbq_rate;
struct tc_cbq_wrropt cbq_wrr;
struct tc_cbq_ovl cbq_ovl;
struct tc_cbq_fopt cbq_fopt;
struct tc_cbq_police cbq_police;
};
struct rtnl_red
{
uint32_t qr_limit;
uint32_t qr_qth_min;
uint32_t qr_qth_max;
uint8_t qr_flags;
uint8_t qr_wlog;
uint8_t qr_plog;
uint8_t qr_scell_log;
uint32_t qr_mask;
};
struct flnl_request
{
NLHDR_COMMON
struct nl_addr * lr_addr;
uint32_t lr_fwmark;
uint8_t lr_tos;
uint8_t lr_scope;
uint8_t lr_table;
};
struct flnl_result
{
NLHDR_COMMON
struct flnl_request * fr_req;
uint8_t fr_table_id;
uint8_t fr_prefixlen;
uint8_t fr_nh_sel;
uint8_t fr_type;
uint8_t fr_scope;
uint32_t fr_error;
};
#define GENL_OP_HAS_POLICY 1
#define GENL_OP_HAS_DOIT 2
#define GENL_OP_HAS_DUMPIT 4
struct genl_family_op
{
uint32_t o_id;
uint32_t o_flags;
struct nl_list_head o_list;
};
struct genl_family
{
NLHDR_COMMON
uint16_t gf_id;
char gf_name[GENL_NAMSIZ];
uint32_t gf_version;
uint32_t gf_hdrsize;
uint32_t gf_maxattr;
struct nl_list_head gf_ops;
};
union nfnl_ct_proto
{
struct {
uint16_t src;
uint16_t dst;
} port;
struct {
uint16_t id;
uint8_t type;
uint8_t code;
} icmp;
};
struct nfnl_ct_dir {
struct nl_addr * src;
struct nl_addr * dst;
union nfnl_ct_proto proto;
uint64_t packets;
uint64_t bytes;
};
union nfnl_ct_protoinfo {
struct {
uint8_t state;
} tcp;
};
struct nfnl_ct {
NLHDR_COMMON
uint8_t ct_family;
uint8_t ct_proto;
union nfnl_ct_protoinfo ct_protoinfo;
uint32_t ct_status;
uint32_t ct_status_mask;
uint32_t ct_timeout;
uint32_t ct_mark;
uint32_t ct_use;
uint32_t ct_id;
struct nfnl_ct_dir ct_orig;
struct nfnl_ct_dir ct_repl;
};
struct nfnl_log {
NLHDR_COMMON
uint16_t log_group;
uint8_t log_copy_mode;
uint32_t log_copy_range;
uint32_t log_flush_timeout;
uint32_t log_alloc_size;
uint32_t log_queue_threshold;
uint32_t log_flags;
uint32_t log_flag_mask;
};
struct nfnl_log_msg {
NLHDR_COMMON
uint8_t log_msg_family;
uint8_t log_msg_hook;
uint16_t log_msg_hwproto;
uint32_t log_msg_mark;
struct timeval log_msg_timestamp;
uint32_t log_msg_indev;
uint32_t log_msg_outdev;
uint32_t log_msg_physindev;
uint32_t log_msg_physoutdev;
uint8_t log_msg_hwaddr[8];
int log_msg_hwaddr_len;
void * log_msg_payload;
int log_msg_payload_len;
char * log_msg_prefix;
uint32_t log_msg_uid;
uint32_t log_msg_gid;
uint32_t log_msg_seq;
uint32_t log_msg_seq_global;
};
struct nfnl_queue {
NLHDR_COMMON
uint16_t queue_group;
uint32_t queue_maxlen;
uint32_t queue_copy_range;
uint8_t queue_copy_mode;
};
struct nfnl_queue_msg {
NLHDR_COMMON
uint16_t queue_msg_group;
uint8_t queue_msg_family;
uint8_t queue_msg_hook;
uint16_t queue_msg_hwproto;
uint32_t queue_msg_packetid;
uint32_t queue_msg_mark;
struct timeval queue_msg_timestamp;
uint32_t queue_msg_indev;
uint32_t queue_msg_outdev;
uint32_t queue_msg_physindev;
uint32_t queue_msg_physoutdev;
uint8_t queue_msg_hwaddr[8];
int queue_msg_hwaddr_len;
void * queue_msg_payload;
int queue_msg_payload_len;
uint32_t queue_msg_verdict;
};
#endif
/*
* netlink/addr.h Abstract Address
*
* 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>
*/
#ifndef NETLINK_ADDR_H_
#define NETLINK_ADDR_H_
#include <netlink/netlink.h>
#ifdef __cplusplus
extern "C" {
#endif
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 int nl_addr_parse(const char *, int, struct nl_addr **);
extern struct nl_addr * nl_addr_clone(struct nl_addr *);
/* Destroyage */
extern void nl_addr_destroy(struct nl_addr *);
/* Usage Management */
extern struct nl_addr * nl_addr_get(struct nl_addr *);
extern void nl_addr_put(struct nl_addr *);
extern int nl_addr_shared(struct nl_addr *);
extern int nl_addr_cmp(struct nl_addr *, struct nl_addr *);
extern int nl_addr_cmp_prefix(struct nl_addr *, struct nl_addr *);
extern int nl_addr_iszero(struct nl_addr *);
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 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 */
extern void nl_addr_set_family(struct nl_addr *, int);
extern int nl_addr_get_family(struct nl_addr *);
extern int nl_addr_set_binary_addr(struct nl_addr *, void *,
size_t);
extern void * nl_addr_get_binary_addr(struct nl_addr *);
extern unsigned int nl_addr_get_len(struct nl_addr *);
extern void nl_addr_set_prefixlen(struct nl_addr *, int);
extern unsigned int nl_addr_get_prefixlen(struct nl_addr *);
/* Address Family Translations */
extern char * nl_af2str(int, char *, size_t);
extern int nl_str2af(const char *);
/* Translations to Strings */
extern char * nl_addr2str(struct nl_addr *, char *, size_t);
#ifdef __cplusplus
}
#endif
#endif
/*
* netlink/attr.h Netlink Attributes
*
* 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>
*/
#ifndef NETLINK_ATTR_H_
#define NETLINK_ATTR_H_
#include <netlink/netlink.h>
#include <netlink/object.h>
#include <netlink/addr.h>
#include <netlink/data.h>
#ifdef __cplusplus
extern "C" {
#endif
struct nl_msg;
/**
* @name Basic Attribute Data Types
* @{
*/
/**
* @ingroup attr
* Basic attribute data types
*
* See \ref attr_datatypes for more details.
*/
enum {
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,
};
#define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
/** @} */
/**
* @ingroup attr
* Attribute validation policy.
*
* See \ref attr_datatypes for more details.
*/
struct nla_policy {
/** Type of attribute or NLA_UNSPEC */
uint16_t type;
/** Minimal length of payload required */
uint16_t minlen;
/** Maximal length of payload allowed */
uint16_t maxlen;
};
/* Size calculations */
extern int nla_attr_size(int payload);
extern int nla_total_size(int payload);
extern int nla_padlen(int payload);
/* Attribute parsing */
extern int nla_type(const struct nlattr *);
extern void * nla_data(const struct nlattr *);
extern int nla_len(const struct nlattr *);
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_validate(struct nlattr *, int, int,
struct nla_policy *);
extern struct nlattr * nla_find(struct nlattr *, int, int);
/* 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 *);
/* 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_data(struct nl_msg *, int, struct nl_data *);
extern int nla_put_addr(struct nl_msg *, int, struct nl_addr *);
/* 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 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)
* @{
*/
/**
* @ingroup attr
* 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(msg, attrtype, attrlen, data) \
do { \
if (nla_put(msg, attrtype, attrlen, data) < 0) \
goto nla_put_failure; \
} while(0)
/**
* @ingroup attr
* 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(msg, type, attrtype, value) \
do { \
type __tmp = value; \
NLA_PUT(msg, attrtype, sizeof(type), &__tmp); \
} while(0)
/**
* Add 8 bit integer attribute to netlink message.
* @arg msg Netlink message.
* @arg attrtype Attribute type.
* @arg value Numeric value.
*/
#define NLA_PUT_U8(msg, attrtype, value) \
NLA_PUT_TYPE(msg, uint8_t, attrtype, 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(msg, attrtype, value) \
NLA_PUT_TYPE(msg, uint16_t, attrtype, 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(msg, attrtype, value) \
NLA_PUT_TYPE(msg, uint32_t, attrtype, 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(msg, attrtype, value) \
NLA_PUT_TYPE(msg, uint64_t, attrtype, value)
/**
* Add string attribute to netlink message.
* @arg msg Netlink message.
* @arg attrtype Attribute type.
* @arg value NUL terminated character string.
*/
#define NLA_PUT_STRING(msg, attrtype, value) \
NLA_PUT(msg, attrtype, strlen(value) + 1, value)
/**
* Add flag attribute to netlink message.
* @arg msg Netlink message.
* @arg attrtype Attribute type.
*/
#define NLA_PUT_FLAG(msg, attrtype) \
NLA_PUT(msg, attrtype, 0, NULL)
/**
* 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(msg, attrtype, msecs) \
NLA_PUT_U64(msg, attrtype, msecs)
/**
* Add address attribute to netlink message.
* @arg msg Netlink message.
* @arg attrtype Attribute type.
* @arg addr Abstract address object.
*/
#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))
/** @} */
/**
* @name Iterators
* @{
*/
/**
* @ingroup attr
* 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
* @arg rem initialized to len, holds bytes currently remaining in stream
*/
#define nla_for_each_attr(pos, head, len, rem) \
for (pos = head, rem = len; \
nla_ok(pos, rem); \
pos = nla_next(pos, &(rem)))
/**
* @ingroup attr
* 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
*/
#define nla_for_each_nested(pos, nla, rem) \
for (pos = nla_data(nla), rem = nla_len(nla); \
nla_ok(pos, rem); \
pos = nla_next(pos, &(rem)))
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/*
* netlink/cache-api.h Caching API
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_CACHE_API_H_
#define NETLINK_CACHE_API_H_
#include <netlink/netlink.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @ingroup cache
* @defgroup cache_api Cache Implementation
* @brief
*
* @par 1) Cache Definition
* @code
* struct nl_cache_ops my_cache_ops = {
* .co_name = "route/link",
* .co_protocol = NETLINK_ROUTE,
* .co_hdrsize = sizeof(struct ifinfomsg),
* .co_obj_ops = &my_obj_ops,
* };
* @endcode
*
* @par 2)
* @code
* // The simplest way to fill a cache is by providing a request-update
* // function which must trigger a complete dump on the kernel-side of
* // whatever the cache covers.
* static int my_request_update(struct nl_cache *cache,
* struct nl_sock *socket)
* {
* // In this example, we request a full dump of the interface table
* return nl_rtgen_request(socket, RTM_GETLINK, AF_UNSPEC, NLM_F_DUMP);
* }
*
* // The resulting netlink messages sent back will be fed into a message
* // parser one at a time. The message parser has to extract all relevant
* // information from the message and create an object reflecting the
* // contents of the message and pass it on to the parser callback function
* // provide which will add the object to the cache.
* static int my_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
* struct nlmsghdr *nlh, struct nl_parser_param *pp)
* {
* struct my_obj *obj;
*
* obj = my_obj_alloc();
* obj->ce_msgtype = nlh->nlmsg_type;
*
* // Parse the netlink message and continue creating the object.
*
* err = pp->pp_cb((struct nl_object *) obj, pp);
* if (err < 0)
* goto errout;
* }
*
* struct nl_cache_ops my_cache_ops = {
* ...
* .co_request_update = my_request_update,
* .co_msg_parser = my_msg_parser,
* };
* @endcode
*
* @par 3) Notification based Updates
* @code
* // Caches can be kept up-to-date based on notifications if the kernel
* // sends out notifications whenever an object is added/removed/changed.
* //
* // It is trivial to support this, first a list of groups needs to be
* // defined which are required to join in order to receive all necessary
* // notifications. The groups are separated by address family to support
* // the common situation where a separate group is used for each address
* // family. If there is only one group, simply specify AF_UNSPEC.
* static struct nl_af_group addr_groups[] = {
* { AF_INET, RTNLGRP_IPV4_IFADDR },
* { AF_INET6, RTNLGRP_IPV6_IFADDR },
* { END_OF_GROUP_LIST },
* };
*
* // In order for the caching system to know the meaning of each message
* // type it requires a table which maps each supported message type to
* // a cache action, e.g. RTM_NEWADDR means address has been added or
* // updated, RTM_DELADDR means address has been removed.
* static struct nl_cache_ops rtnl_addr_ops = {
* ...
* .co_msgtypes = {
* { RTM_NEWADDR, NL_ACT_NEW, "new" },
* { RTM_DELADDR, NL_ACT_DEL, "del" },
* { RTM_GETADDR, NL_ACT_GET, "get" },
* END_OF_MSGTYPES_LIST,
* },
* .co_groups = addr_groups,
* };
*
* // It is now possible to keep the cache up-to-date using the cache manager.
* @endcode
* @{
*/
enum {
NL_ACT_UNSPEC,
NL_ACT_NEW,
NL_ACT_DEL,
NL_ACT_GET,
NL_ACT_SET,
NL_ACT_CHANGE,
__NL_ACT_MAX,
};
#define NL_ACT_MAX (__NL_ACT_MAX - 1)
#define END_OF_MSGTYPES_LIST { -1, -1, NULL }
/**
* Message type to cache action association
*/
struct nl_msgtype
{
/** Netlink message type */
int mt_id;
/** Cache action to take */
int mt_act;
/** Name of operation for human-readable printing */
char * mt_name;
};
/**
* Address family to netlink group association
*/
struct nl_af_group
{
/** Address family */
int ag_family;
/** Netlink group identifier */
int ag_group;
};
#define END_OF_GROUP_LIST AF_UNSPEC, 0
struct nl_parser_param
{
int (*pp_cb)(struct nl_object *, struct nl_parser_param *);
void * pp_arg;
};
/**
* Cache Operations
*/
struct nl_cache_ops
{
char * co_name;
int co_hdrsize;
int co_protocol;
struct nl_af_group * co_groups;
/**
* Called whenever an update of the cache is required. Must send
* a request message to the kernel requesting a complete dump.
*/
int (*co_request_update)(struct nl_cache *, struct nl_sock *);
/**
* Called whenever a message was received that needs to be parsed.
* Must parse the message and call the paser callback function
* (nl_parser_param) provided via the argument.
*/
int (*co_msg_parser)(struct nl_cache_ops *, struct sockaddr_nl *,
struct nlmsghdr *, struct nl_parser_param *);
struct nl_object_ops * co_obj_ops;
struct nl_cache_ops *co_next;
struct nl_cache *co_major_cache;
struct genl_ops * co_genl;
struct nl_msgtype co_msgtypes[];
};
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/*
* netlink/cache.h Caching Module
*
* 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>
*/
#ifndef NETLINK_CACHE_H_
#define NETLINK_CACHE_H_
#include <netlink/netlink.h>
#include <netlink/msg.h>
#include <netlink/utils.h>
#include <netlink/object.h>
#include <netlink/cache-api.h>
#ifdef __cplusplus
extern "C" {
#endif
struct nl_cache;
typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int, void *);
/* Access Functions */
extern int nl_cache_nitems(struct nl_cache *);
extern int nl_cache_nitems_filter(struct nl_cache *,
struct nl_object *);
extern struct nl_cache_ops * nl_cache_get_ops(struct nl_cache *);
extern struct nl_object * nl_cache_get_first(struct nl_cache *);
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 *);
extern struct nl_cache * nl_cache_alloc(struct nl_cache_ops *);
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 *);
extern void nl_cache_free(struct nl_cache *);
/* Cache modification */
extern int nl_cache_add(struct nl_cache *,
struct nl_object *);
extern int nl_cache_parse_and_add(struct nl_cache *,
struct nl_msg *);
extern void nl_cache_remove(struct nl_object *);
extern int nl_cache_refill(struct nl_sock *,
struct nl_cache *);
extern int nl_cache_pickup(struct nl_sock *,
struct nl_cache *);
extern int nl_cache_resync(struct nl_sock *,
struct nl_cache *,
change_func_t,
void *);
extern int nl_cache_include(struct nl_cache *,
struct nl_object *,
change_func_t,
void *);
/* General */
extern int nl_cache_is_empty(struct nl_cache *);
extern void nl_cache_mark_all(struct nl_cache *);
/* Dumping */
extern void nl_cache_dump(struct nl_cache *,
struct nl_dump_params *);
extern void nl_cache_dump_filter(struct nl_cache *,
struct nl_dump_params *,
struct nl_object *);
/* Iterators */
extern void nl_cache_foreach(struct nl_cache *,
void (*cb)(struct nl_object *,
void *),
void *arg);
extern void nl_cache_foreach_filter(struct nl_cache *,
struct nl_object *,
void (*cb)(struct
nl_object *,
void *),
void *arg);
/* --- cache management --- */
/* Cache type management */
extern struct nl_cache_ops * nl_cache_ops_lookup(const char *);
extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
extern struct nl_msgtype * nl_msgtype_lookup(struct nl_cache_ops *, int);
extern void nl_cache_ops_foreach(void (*cb)(struct nl_cache_ops *, void *), void *);
extern int nl_cache_mngt_register(struct nl_cache_ops *);
extern int nl_cache_mngt_unregister(struct nl_cache_ops *);
/* Global cache provisioning/requiring */
extern void nl_cache_mngt_provide(struct nl_cache *);
extern void nl_cache_mngt_unprovide(struct nl_cache *);
extern struct nl_cache * nl_cache_mngt_require(const char *);
struct nl_cache_mngr;
#define NL_AUTO_PROVIDE 1
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,
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);
extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *);
extern void nl_cache_mngr_free(struct nl_cache_mngr *);
#ifdef __cplusplus
}
#endif
#endif
/*
* 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
/*
* netlink/data.h Abstract Data
*
* 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>
*/
#ifndef NETLINK_DATA_H_
#define NETLINK_DATA_H_
#include <netlink/netlink.h>
#ifdef __cplusplus
extern "C" {
#endif
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 *);
/* Access Functions */
extern void * nl_data_get(struct nl_data *);
extern size_t nl_data_get_size(struct nl_data *);
/* Misc */
extern int nl_data_cmp(struct nl_data *, struct nl_data *);
#ifdef __cplusplus
}
#endif
#endif
/*
* 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
/*
* netlink/fib_lookup/fib_lookup.h FIB Lookup
*
* 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>
*/
#ifndef NETLINK_FIB_LOOKUP_H_
#define NETLINK_FIB_LOOKUP_H_
#include <netlink/netlink.h>
#include <netlink/cache.h>
#include <netlink/addr.h>
#include <netlink/fib_lookup/request.h>
#ifdef __cplusplus
extern "C" {
#endif
struct flnl_result;
extern struct flnl_result * flnl_result_alloc(void);
extern void flnl_result_put(struct flnl_result *);
extern struct nl_cache * flnl_result_alloc_cache(void);
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 *);
#ifdef __cplusplus
}
#endif
#endif
/*
* netlink/fib_lookup/request.h FIB Lookup Request
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_FIB_LOOKUP_REQUEST_H_
#define NETLINK_FIB_LOOKUP_REQUEST_H_
#include <netlink/netlink.h>
#include <netlink/addr.h>
#ifdef __cplusplus
extern "C" {
#endif
struct flnl_request;
#define REQUEST_CAST(ptr) ((struct flnl_request *) (ptr))
extern struct flnl_request * flnl_request_alloc(void);
extern void flnl_request_set_fwmark(struct flnl_request *,
uint64_t);
extern uint64_t flnl_request_get_fwmark(struct flnl_request *);
extern void flnl_request_set_tos(struct flnl_request *,
int);
extern int flnl_request_get_tos(struct flnl_request *);
extern void flnl_request_set_scope(struct flnl_request *,
int);
extern int flnl_request_get_scope(struct flnl_request *);
extern void flnl_request_set_table(struct flnl_request *,
int);
extern int flnl_request_get_table(struct flnl_request *);
extern int flnl_request_set_addr(struct flnl_request *,
struct nl_addr *);
extern struct nl_addr * flnl_request_get_addr(struct flnl_request *);
extern int flnl_request_cmp(struct flnl_request *,
struct flnl_request *);
#ifdef __cplusplus
}
#endif
#endif
/*
* netlink/genl/ctrl.h Generic Netlink Controller
*
* 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>
*/
#ifndef NETLINK_GENL_CTRL_H_
#define NETLINK_GENL_CTRL_H_
#include <netlink/netlink.h>
#include <netlink/cache.h>
#include <netlink/addr.h>
#ifdef __cplusplus
extern "C" {
#endif
struct genl_family;
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_sock *,
const char *);
#ifdef __cplusplus
}
#endif
#endif
/*
* netlink/genl/family.h Generic Netlink Family
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_GENL_FAMILY_H_
#define NETLINK_GENL_FAMILY_H_
#include <netlink/netlink.h>
#include <netlink/cache.h>
#ifdef __cplusplus
extern "C" {
#endif
struct genl_family;
extern struct genl_family * genl_family_alloc(void);
extern void genl_family_put(struct genl_family *);
extern unsigned int genl_family_get_id(struct genl_family *);
extern void genl_family_set_id(struct genl_family *,
unsigned int);
extern char * genl_family_get_name(struct genl_family *);
extern void genl_family_set_name(struct genl_family *,
const char *name);
extern uint8_t genl_family_get_version(struct genl_family *);
extern void genl_family_set_version(struct genl_family *,
uint8_t);
extern uint32_t genl_family_get_hdrsize(struct genl_family *);
extern void genl_family_set_hdrsize(struct genl_family *,
uint32_t);
extern uint32_t genl_family_get_maxattr(struct genl_family *);
extern void genl_family_set_maxattr(struct genl_family *,
uint32_t);
extern int genl_family_add_op(struct genl_family *,
int, int);
#ifdef __cplusplus
}
#endif
#endif
/*
* netlink/genl/genl.h Generic Netlink
*
* 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>
*/
#ifndef NETLINK_GENL_H_
#define NETLINK_GENL_H_
#include <netlink/netlink.h>
#include <netlink/msg.h>
#include <netlink/attr.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int genl_connect(struct nl_sock *);
extern int genl_send_simple(struct nl_sock *, int, int,
int, int);
extern void * genlmsg_put(struct nl_msg *, uint32_t, uint32_t,
int, int, int, uint8_t, uint8_t);
extern int genlmsg_valid_hdr(struct nlmsghdr *, int);
extern int genlmsg_validate(struct nlmsghdr *, int, int,
struct nla_policy *);
extern int genlmsg_parse(struct nlmsghdr *, int, struct nlattr **,
int, struct nla_policy *);
extern void * genlmsg_data(const struct genlmsghdr *);
extern int genlmsg_len(const struct genlmsghdr *);
extern struct nlattr * genlmsg_attrdata(const struct genlmsghdr *, int);
extern int genlmsg_attrlen(const struct genlmsghdr *, int);
extern char * genl_op2name(int, int, char *, size_t);
#ifdef __cplusplus
}
#endif
#endif
/*
* netlink/genl/mngt.h Generic Netlink Management
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_GENL_MNGT_H_
#define NETLINK_GENL_MNGT_H_
#include <netlink/netlink.h>
#include <netlink/attr.h>
#include <netlink/list.h>
#ifdef __cplusplus
extern "C" {
#endif
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
*/
struct genl_cmd
{
/** Unique command identifier */
int c_id;
/** Name/description of command */
char * c_name;
/**
* Maximum attribute identifier, must be provided if
* a message parser is available.
*/
int c_maxattr;
int (*c_msg_parser)(struct nl_cache_ops *,
struct genl_cmd *,
struct genl_info *, void *);
/**
* Attribute validation policy (optional)
*/
struct nla_policy * c_attr_policy;
};
/**
* @ingroup genl_mngt
* Generic Netlink Operations
*/
struct genl_ops
{
int o_family;
int o_id;
char * o_name;
struct nl_cache_ops * o_cache_ops;
struct genl_cmd * o_cmds;
int o_ncmds;
/* linked list of all genl cache operations */
struct nl_list_head o_list;
};
extern int genl_register(struct nl_cache_ops *);
extern void genl_unregister(struct nl_cache_ops *);
#ifdef __cplusplus
}
#endif
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment