object.h

00001 /*
00002  * netlink/object.c     Generic Cacheable Object
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
00010  */
00011 
00012 #ifndef NETLINK_OBJECT_H_
00013 #define NETLINK_OBJECT_H_
00014 
00015 #include <netlink/netlink.h>
00016 #include <netlink/utils.h>
00017 
00018 #ifdef __cplusplus
00019 extern "C" {
00020 #endif
00021 
00022 struct nl_cache;
00023 struct nl_object;
00024 struct nl_object_ops;
00025 
00026 #define OBJ_CAST(ptr)           ((struct nl_object *) (ptr))
00027 
00028 /* General */
00029 extern struct nl_object *       nl_object_alloc(struct nl_object_ops *);
00030 extern int                      nl_object_alloc_name(const char *,
00031                                                      struct nl_object **);
00032 extern void                     nl_object_free(struct nl_object *);
00033 extern struct nl_object *       nl_object_clone(struct nl_object *obj);
00034 extern void                     nl_object_get(struct nl_object *);
00035 extern void                     nl_object_put(struct nl_object *);
00036 extern int                      nl_object_shared(struct nl_object *);
00037 extern void                     nl_object_dump(struct nl_object *,
00038                                                struct nl_dump_params *);
00039 extern int                      nl_object_identical(struct nl_object *,
00040                                                     struct nl_object *);
00041 extern uint32_t                 nl_object_diff(struct nl_object *,
00042                                                struct nl_object *);
00043 extern int                      nl_object_match_filter(struct nl_object *,
00044                                                        struct nl_object *);
00045 extern char *                   nl_object_attrs2str(struct nl_object *,
00046                                                     uint32_t attrs, char *buf,
00047                                                     size_t);
00048 extern char *                   nl_object_attr_list(struct nl_object *,
00049                                                     char *, size_t);
00050 
00051 /* Marks */
00052 extern void                     nl_object_mark(struct nl_object *);
00053 extern void                     nl_object_unmark(struct nl_object *);
00054 extern int                      nl_object_is_marked(struct nl_object *);
00055 
00056 /* Access Functions */
00057 extern int                      nl_object_get_refcnt(struct nl_object *);
00058 extern struct nl_cache *        nl_object_get_cache(struct nl_object *);
00059 static inline void *            nl_object_priv(struct nl_object *obj)
00060 {
00061         return obj;
00062 }
00063 
00064 
00065 #ifdef __cplusplus
00066 }
00067 #endif
00068 
00069 #endif