2007-09-15 01:28:01 +02:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
2012-04-21 12:11:45 +02:00
|
|
|
* Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
|
2007-09-15 01:28:01 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NETLINK_CACHE_H_
|
|
|
|
#define NETLINK_CACHE_H_
|
|
|
|
|
|
|
|
#include <netlink/netlink.h>
|
|
|
|
#include <netlink/msg.h>
|
|
|
|
#include <netlink/utils.h>
|
|
|
|
#include <netlink/object.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-02-01 10:21:58 +01:00
|
|
|
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)
|
|
|
|
|
2007-09-15 01:28:01 +02:00
|
|
|
struct nl_cache;
|
2013-01-23 13:17:43 +01:00
|
|
|
typedef void (*change_func_t)(struct nl_cache *, struct nl_object *, int, void *);
|
2007-09-15 01:28:01 +02:00
|
|
|
|
2012-11-12 21:59:54 +01:00
|
|
|
/**
|
|
|
|
* @ingroup cache
|
|
|
|
* Explicitely iterate over all address families when updating the cache
|
|
|
|
*/
|
|
|
|
#define NL_CACHE_AF_ITER 0x0001
|
|
|
|
|
2007-09-15 01:28:01 +02:00
|
|
|
/* 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 *);
|
2008-05-14 17:49:44 +02:00
|
|
|
extern int nl_cache_alloc_and_fill(struct nl_cache_ops *,
|
2008-05-15 13:26:32 +02:00
|
|
|
struct nl_sock *,
|
2008-05-14 17:49:44 +02:00
|
|
|
struct nl_cache **);
|
|
|
|
extern int nl_cache_alloc_name(const char *,
|
|
|
|
struct nl_cache **);
|
2007-09-15 01:28:01 +02:00
|
|
|
extern struct nl_cache * nl_cache_subset(struct nl_cache *,
|
|
|
|
struct nl_object *);
|
2012-02-16 12:57:42 +01:00
|
|
|
extern struct nl_cache * nl_cache_clone(struct nl_cache *);
|
2007-09-15 01:28:01 +02:00
|
|
|
extern void nl_cache_clear(struct nl_cache *);
|
2012-11-15 20:45:44 +01:00
|
|
|
extern void nl_cache_get(struct nl_cache *);
|
2007-09-15 01:28:01 +02:00
|
|
|
extern void nl_cache_free(struct nl_cache *);
|
2012-11-16 01:11:55 +01:00
|
|
|
extern void nl_cache_put(struct nl_cache *cache);
|
2007-09-15 01:28:01 +02:00
|
|
|
|
|
|
|
/* 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 *);
|
2014-06-24 15:03:15 -04:00
|
|
|
extern int nl_cache_move(struct nl_cache *,
|
|
|
|
struct nl_object *);
|
2007-09-15 01:28:01 +02:00
|
|
|
extern void nl_cache_remove(struct nl_object *);
|
2008-05-15 13:26:32 +02:00
|
|
|
extern int nl_cache_refill(struct nl_sock *,
|
2007-09-15 01:28:01 +02:00
|
|
|
struct nl_cache *);
|
2008-05-15 13:26:32 +02:00
|
|
|
extern int nl_cache_pickup(struct nl_sock *,
|
2007-09-15 01:28:01 +02:00
|
|
|
struct nl_cache *);
|
2014-11-23 15:40:36 +01:00
|
|
|
extern int nl_cache_pickup_checkdup(struct nl_sock *,
|
|
|
|
struct nl_cache *);
|
2008-05-15 13:26:32 +02:00
|
|
|
extern int nl_cache_resync(struct nl_sock *,
|
2007-09-15 01:28:01 +02:00
|
|
|
struct nl_cache *,
|
2010-09-22 20:10:26 +02:00
|
|
|
change_func_t,
|
|
|
|
void *);
|
2007-09-15 01:28:01 +02:00
|
|
|
extern int nl_cache_include(struct nl_cache *,
|
|
|
|
struct nl_object *,
|
2010-09-22 20:10:26 +02:00
|
|
|
change_func_t,
|
|
|
|
void *);
|
2011-04-10 10:22:27 +02:00
|
|
|
extern void nl_cache_set_arg1(struct nl_cache *, int);
|
|
|
|
extern void nl_cache_set_arg2(struct nl_cache *, int);
|
2012-11-12 12:38:31 -08:00
|
|
|
extern void nl_cache_set_flags(struct nl_cache *, unsigned int);
|
2007-09-15 01:28:01 +02:00
|
|
|
|
|
|
|
/* General */
|
|
|
|
extern int nl_cache_is_empty(struct nl_cache *);
|
2011-03-22 10:53:51 +01:00
|
|
|
extern struct nl_object * nl_cache_search(struct nl_cache *,
|
|
|
|
struct nl_object *);
|
2013-12-13 15:57:43 +01:00
|
|
|
extern struct nl_object *nl_cache_find(struct nl_cache *,
|
|
|
|
struct nl_object *);
|
2007-09-15 01:28:01 +02:00
|
|
|
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 *);
|
2012-11-16 00:19:38 +01:00
|
|
|
extern struct nl_cache_ops * nl_cache_ops_lookup_safe(const char *);
|
2007-10-11 23:09:49 +02:00
|
|
|
extern struct nl_cache_ops * nl_cache_ops_associate(int, int);
|
2012-11-16 00:19:38 +01:00
|
|
|
extern struct nl_cache_ops * nl_cache_ops_associate_safe(int, int);
|
2007-10-11 23:09:49 +02:00
|
|
|
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 *);
|
2007-09-15 01:28:01 +02:00
|
|
|
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 *);
|
2012-11-16 01:11:55 +01:00
|
|
|
extern struct nl_cache * nl_cache_mngt_require_safe(const char *);
|
2011-05-11 09:33:29 +02:00
|
|
|
extern struct nl_cache * __nl_cache_mngt_require(const char *);
|
2007-09-15 01:28:01 +02:00
|
|
|
|
|
|
|
struct nl_cache_mngr;
|
|
|
|
|
|
|
|
#define NL_AUTO_PROVIDE 1
|
2012-04-21 12:11:45 +02:00
|
|
|
#define NL_ALLOCATED_SOCK 2 /* For internal use only, do not use */
|
2007-09-15 01:28:01 +02:00
|
|
|
|
2008-05-15 13:26:32 +02:00
|
|
|
extern int nl_cache_mngr_alloc(struct nl_sock *,
|
2008-05-14 17:49:44 +02:00
|
|
|
int, int,
|
|
|
|
struct nl_cache_mngr **);
|
|
|
|
extern int nl_cache_mngr_add(struct nl_cache_mngr *,
|
2007-09-15 01:28:01 +02:00
|
|
|
const char *,
|
2008-05-14 17:49:44 +02:00
|
|
|
change_func_t,
|
2010-09-22 20:10:26 +02:00
|
|
|
void *,
|
2008-05-14 17:49:44 +02:00
|
|
|
struct nl_cache **);
|
2012-11-12 12:38:32 -08:00
|
|
|
extern int nl_cache_mngr_add_cache(struct nl_cache_mngr *mngr,
|
|
|
|
struct nl_cache *cache,
|
|
|
|
change_func_t cb, void *data);
|
2007-09-15 01:28:01 +02:00
|
|
|
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 *);
|
2012-04-21 15:48:37 +02:00
|
|
|
extern void nl_cache_mngr_info(struct nl_cache_mngr *,
|
|
|
|
struct nl_dump_params *);
|
2007-09-15 01:28:01 +02:00
|
|
|
extern void nl_cache_mngr_free(struct nl_cache_mngr *);
|
|
|
|
|
2013-02-01 10:21:58 +01:00
|
|
|
extern void nl_cache_ops_get(struct nl_cache_ops *);
|
|
|
|
extern void nl_cache_ops_put(struct nl_cache_ops *);
|
2014-07-26 21:33:21 +02:00
|
|
|
extern void nl_cache_ops_set_flags(struct nl_cache_ops *,
|
|
|
|
unsigned int);
|
2013-02-01 10:21:58 +01:00
|
|
|
|
2007-09-15 01:28:01 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|