libnl 1.1

include/netlink/route/link/info-api.h

00001 /*
00002  * netlink/route/link/info-api.h        Link Info API
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_LINK_INFO_API_H_
00013 #define NETLINK_LINK_INFO_API_H_
00014 
00015 #include <netlink/netlink.h>
00016 
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 
00021 /**
00022  * @ingroup link_info
00023  *
00024  * Link info operations
00025  */
00026 struct rtnl_link_info_ops
00027 {
00028         /** Name of operations, must match name on kernel side */
00029         char *          io_name;
00030 
00031         /** Reference count (internal, do not use) */
00032         int             io_refcnt;
00033 
00034         /** Called to assign an info type to a link.
00035          * Has to allocate enough resources to hold attributes. Can
00036          * use link->l_info to store a pointer. */
00037         int           (*io_alloc)(struct rtnl_link *);
00038 
00039         /** Called to parse the link info attribute.
00040          * Must parse the attribute and assign all values to the link.
00041          */
00042         int           (*io_parse)(struct rtnl_link *,
00043                                   struct nlattr *,
00044                                   struct nlattr *);
00045 
00046         /** Called when the link object is dumped.
00047          * Must dump the info type specific attributes. */
00048         int           (*io_dump[NL_DUMP_MAX+1])(struct rtnl_link *,
00049                                                 struct nl_dump_params *, int);
00050 
00051         /** Called when a link object is cloned.
00052          * Must clone all info type specific attributes. */
00053         int           (*io_clone)(struct rtnl_link *, struct rtnl_link *);
00054 
00055         /** Called when construction a link netlink message.
00056          * Must append all info type specific attributes to the message. */
00057         int           (*io_put_attrs)(struct nl_msg *, struct rtnl_link *);
00058 
00059         /** Called to release all resources previously allocated
00060          * in either io_alloc() or io_parse(). */
00061         void          (*io_free)(struct rtnl_link *);
00062 
00063         struct rtnl_link_info_ops *     io_next;
00064 };
00065 
00066 extern struct rtnl_link_info_ops *rtnl_link_info_ops_lookup(const char *);
00067 
00068 extern int                      rtnl_link_register_info(struct rtnl_link_info_ops *);
00069 extern int                      rtnl_link_unregister_info(struct rtnl_link_info_ops *);
00070 
00071 #endif