144d362409d5469aed47d19e7908d19bd194493aThomas Graf/* 244d362409d5469aed47d19e7908d19bd194493aThomas Graf * netlink/object.c Generic Cacheable Object 344d362409d5469aed47d19e7908d19bd194493aThomas Graf * 444d362409d5469aed47d19e7908d19bd194493aThomas Graf * This library is free software; you can redistribute it and/or 544d362409d5469aed47d19e7908d19bd194493aThomas Graf * modify it under the terms of the GNU Lesser General Public 644d362409d5469aed47d19e7908d19bd194493aThomas Graf * License as published by the Free Software Foundation version 2.1 744d362409d5469aed47d19e7908d19bd194493aThomas Graf * of the License. 844d362409d5469aed47d19e7908d19bd194493aThomas Graf * 98a3efffa5b3fde252675239914118664d36a2c24Thomas Graf * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> 1044d362409d5469aed47d19e7908d19bd194493aThomas Graf */ 1144d362409d5469aed47d19e7908d19bd194493aThomas Graf 1244d362409d5469aed47d19e7908d19bd194493aThomas Graf#ifndef NETLINK_OBJECT_H_ 1344d362409d5469aed47d19e7908d19bd194493aThomas Graf#define NETLINK_OBJECT_H_ 1444d362409d5469aed47d19e7908d19bd194493aThomas Graf 1544d362409d5469aed47d19e7908d19bd194493aThomas Graf#include <netlink/netlink.h> 1644d362409d5469aed47d19e7908d19bd194493aThomas Graf#include <netlink/utils.h> 1744d362409d5469aed47d19e7908d19bd194493aThomas Graf 1844d362409d5469aed47d19e7908d19bd194493aThomas Graf#ifdef __cplusplus 1944d362409d5469aed47d19e7908d19bd194493aThomas Grafextern "C" { 2044d362409d5469aed47d19e7908d19bd194493aThomas Graf#endif 2144d362409d5469aed47d19e7908d19bd194493aThomas Graf 2244d362409d5469aed47d19e7908d19bd194493aThomas Grafstruct nl_cache; 2344d362409d5469aed47d19e7908d19bd194493aThomas Grafstruct nl_object; 2444d362409d5469aed47d19e7908d19bd194493aThomas Grafstruct nl_object_ops; 2544d362409d5469aed47d19e7908d19bd194493aThomas Graf 2644d362409d5469aed47d19e7908d19bd194493aThomas Graf#define OBJ_CAST(ptr) ((struct nl_object *) (ptr)) 2744d362409d5469aed47d19e7908d19bd194493aThomas Graf 2844d362409d5469aed47d19e7908d19bd194493aThomas Graf/* General */ 2944d362409d5469aed47d19e7908d19bd194493aThomas Grafextern struct nl_object * nl_object_alloc(struct nl_object_ops *); 308a3efffa5b3fde252675239914118664d36a2c24Thomas Grafextern int nl_object_alloc_name(const char *, 318a3efffa5b3fde252675239914118664d36a2c24Thomas Graf struct nl_object **); 3244d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_free(struct nl_object *); 3344d362409d5469aed47d19e7908d19bd194493aThomas Grafextern struct nl_object * nl_object_clone(struct nl_object *obj); 3444d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_get(struct nl_object *); 3544d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_put(struct nl_object *); 3644d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_shared(struct nl_object *); 3744d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_dump(struct nl_object *, 3844d362409d5469aed47d19e7908d19bd194493aThomas Graf struct nl_dump_params *); 3944d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_identical(struct nl_object *, 4044d362409d5469aed47d19e7908d19bd194493aThomas Graf struct nl_object *); 4144d362409d5469aed47d19e7908d19bd194493aThomas Grafextern uint32_t nl_object_diff(struct nl_object *, 4244d362409d5469aed47d19e7908d19bd194493aThomas Graf struct nl_object *); 4344d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_match_filter(struct nl_object *, 4444d362409d5469aed47d19e7908d19bd194493aThomas Graf struct nl_object *); 4544d362409d5469aed47d19e7908d19bd194493aThomas Grafextern char * nl_object_attrs2str(struct nl_object *, 4644d362409d5469aed47d19e7908d19bd194493aThomas Graf uint32_t attrs, char *buf, 4744d362409d5469aed47d19e7908d19bd194493aThomas Graf size_t); 4844d362409d5469aed47d19e7908d19bd194493aThomas Grafextern char * nl_object_attr_list(struct nl_object *, 4944d362409d5469aed47d19e7908d19bd194493aThomas Graf char *, size_t); 5044d362409d5469aed47d19e7908d19bd194493aThomas Graf 5144d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Marks */ 5244d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_mark(struct nl_object *); 5344d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_unmark(struct nl_object *); 5444d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_is_marked(struct nl_object *); 5544d362409d5469aed47d19e7908d19bd194493aThomas Graf 5644d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Access Functions */ 5744d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_get_refcnt(struct nl_object *); 5844d362409d5469aed47d19e7908d19bd194493aThomas Grafextern struct nl_cache * nl_object_get_cache(struct nl_object *); 59a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskinstatic inline void * nl_object_priv(struct nl_object *obj) 60a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskin{ 61a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskin return obj; 62a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskin} 63a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskin 6444d362409d5469aed47d19e7908d19bd194493aThomas Graf 6544d362409d5469aed47d19e7908d19bd194493aThomas Graf#ifdef __cplusplus 6644d362409d5469aed47d19e7908d19bd194493aThomas Graf} 6744d362409d5469aed47d19e7908d19bd194493aThomas Graf#endif 6844d362409d5469aed47d19e7908d19bd194493aThomas Graf 6944d362409d5469aed47d19e7908d19bd194493aThomas Graf#endif 70