Tizen 2.1 base
[platform/upstream/libnl2.git] / include / netlink / route / link / info-api.h
1 /*
2  * netlink/route/link/info-api.h        Link Info API
3  *
4  *      This library is free software; you can redistribute it and/or
5  *      modify it under the terms of the GNU Lesser General Public
6  *      License as published by the Free Software Foundation version 2.1
7  *      of the License.
8  *
9  * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
10  */
11
12 #ifndef NETLINK_LINK_INFO_API_H_
13 #define NETLINK_LINK_INFO_API_H_
14
15 #include <netlink/netlink.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /**
22  * @ingroup link_info
23  *
24  * Link info operations
25  */
26 struct rtnl_link_info_ops
27 {
28         /** Name of operations, must match name on kernel side */
29         char *          io_name;
30
31         /** Reference count (internal, do not use) */
32         int             io_refcnt;
33
34         /** Called to assign an info type to a link.
35          * Has to allocate enough resources to hold attributes. Can
36          * use link->l_info to store a pointer. */
37         int           (*io_alloc)(struct rtnl_link *);
38
39         /** Called to parse the link info attribute.
40          * Must parse the attribute and assign all values to the link.
41          */
42         int           (*io_parse)(struct rtnl_link *,
43                                   struct nlattr *,
44                                   struct nlattr *);
45
46         /** Called when the link object is dumped.
47          * Must dump the info type specific attributes. */
48         void          (*io_dump[NL_DUMP_MAX+1])(struct rtnl_link *,
49                                                 struct nl_dump_params *);
50
51         /** Called when a link object is cloned.
52          * Must clone all info type specific attributes. */
53         int           (*io_clone)(struct rtnl_link *, struct rtnl_link *);
54
55         /** Called when construction a link netlink message.
56          * Must append all info type specific attributes to the message. */
57         int           (*io_put_attrs)(struct nl_msg *, struct rtnl_link *);
58
59         /** Called to release all resources previously allocated
60          * in either io_alloc() or io_parse(). */
61         void          (*io_free)(struct rtnl_link *);
62
63         struct rtnl_link_info_ops *     io_next;
64 };
65
66 extern struct rtnl_link_info_ops *rtnl_link_info_ops_lookup(const char *);
67
68 extern int                      rtnl_link_register_info(struct rtnl_link_info_ops *);
69 extern int                      rtnl_link_unregister_info(struct rtnl_link_info_ops *);
70
71 #endif