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 * 9054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewart * Copyright (c) 2003-2012 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); 34054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewartextern int nl_object_update(struct nl_object *dst, 35054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewart struct nl_object *src); 3644d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_get(struct nl_object *); 3744d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_put(struct nl_object *); 3844d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_shared(struct nl_object *); 3944d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_dump(struct nl_object *, 4044d362409d5469aed47d19e7908d19bd194493aThomas Graf struct nl_dump_params *); 41054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewartextern void nl_object_dump_buf(struct nl_object *, char *, size_t); 4244d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_identical(struct nl_object *, 4344d362409d5469aed47d19e7908d19bd194493aThomas Graf struct nl_object *); 4444d362409d5469aed47d19e7908d19bd194493aThomas Grafextern uint32_t nl_object_diff(struct nl_object *, 4544d362409d5469aed47d19e7908d19bd194493aThomas Graf struct nl_object *); 4644d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_match_filter(struct nl_object *, 4744d362409d5469aed47d19e7908d19bd194493aThomas Graf struct nl_object *); 4844d362409d5469aed47d19e7908d19bd194493aThomas Grafextern char * nl_object_attrs2str(struct nl_object *, 4944d362409d5469aed47d19e7908d19bd194493aThomas Graf uint32_t attrs, char *buf, 5044d362409d5469aed47d19e7908d19bd194493aThomas Graf size_t); 5144d362409d5469aed47d19e7908d19bd194493aThomas Grafextern char * nl_object_attr_list(struct nl_object *, 5244d362409d5469aed47d19e7908d19bd194493aThomas Graf char *, size_t); 53054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewartextern void nl_object_keygen(struct nl_object *, 54054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewart uint32_t *, uint32_t); 5544d362409d5469aed47d19e7908d19bd194493aThomas Graf 5644d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Marks */ 5744d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_mark(struct nl_object *); 5844d362409d5469aed47d19e7908d19bd194493aThomas Grafextern void nl_object_unmark(struct nl_object *); 5944d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_is_marked(struct nl_object *); 6044d362409d5469aed47d19e7908d19bd194493aThomas Graf 6144d362409d5469aed47d19e7908d19bd194493aThomas Graf/* Access Functions */ 6244d362409d5469aed47d19e7908d19bd194493aThomas Grafextern int nl_object_get_refcnt(struct nl_object *); 6344d362409d5469aed47d19e7908d19bd194493aThomas Grafextern struct nl_cache * nl_object_get_cache(struct nl_object *); 64054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewartextern const char * nl_object_get_type(const struct nl_object *); 65054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewartextern int nl_object_get_msgtype(const struct nl_object *); 66054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewartstruct nl_object_ops * nl_object_get_ops(const struct nl_object *); 67054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewartuint32_t nl_object_get_id_attrs(struct nl_object *obj); 68054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewart 69054c80d775f2ae9b8f50260bdfcb821e99c0da2aPaul Stewart 70a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskinstatic inline void * nl_object_priv(struct nl_object *obj) 71a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskin{ 72a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskin return obj; 73a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskin} 74a8cd7b62c86127e2c946373d50efac9d2ed8da38Pavel Roskin 7544d362409d5469aed47d19e7908d19bd194493aThomas Graf 7644d362409d5469aed47d19e7908d19bd194493aThomas Graf#ifdef __cplusplus 7744d362409d5469aed47d19e7908d19bd194493aThomas Graf} 7844d362409d5469aed47d19e7908d19bd194493aThomas Graf#endif 7944d362409d5469aed47d19e7908d19bd194493aThomas Graf 8044d362409d5469aed47d19e7908d19bd194493aThomas Graf#endif 81