]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/rtnl.h
2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <daniel.lezcano at free.fr>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 * Use this as a good size to allocate route netlink messages
30 #define RTNLMSG_GOOD_SIZE NLMSG_GOOD_SIZE
31 #define RTNLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + RTNL_HDRLEN))
34 * struct genl_handler : the structure which store the netlink handler
35 * and the family number
37 * @nlh: the netlink socket handler
40 struct nl_handler nlh
;
44 * struct rtnlmsg : the struct containing the route netlink message
47 * @nlmsghdr: a netlink message header
48 * @rtnlmsghdr: a route netlink message header pointer
52 struct nlmsghdr nlmsghdr
;
56 * rtnetlink_open : open a route netlink socket
58 * @handler: a struct rtnl_handler pointer
60 * Returns 0 on success, < 0 otherwise
62 extern int rtnetlink_open(struct rtnl_handler
*handler
);
65 * genetlink_close : close a route netlink socket
67 * @handler: the handler of the socket to be closed
69 * Returns 0 on success, < 0 otherwise
71 extern int rtnetlink_close(struct rtnl_handler
*handler
);
74 * rtnetlink_rcv : receive a route netlink socket, it is up
75 * to the caller to manage the allocation of the route netlink message
77 * @handler: the handler of the route netlink socket
78 * @rtnlmsg: the pointer to a route netlink message pre-allocated
80 * Returns 0 on success, < 0 otherwise
82 extern int rtnetlink_rcv(struct rtnl_handler
*handler
, struct rtnlmsg
*rtnlmsg
);
85 * rtnetlink_send : send a route netlink socket, it is up
86 * to the caller to manage the allocation of the route netlink message
88 * @handler: the handler of the route netlink socket
89 * @rtnlmsg: the pointer to a netlink message pre-allocated
91 * Returns 0 on success, < 0 otherwise
93 extern int rtnetlink_send(struct rtnl_handler
*handler
,
94 struct rtnlmsg
*rtnlmsg
);
96 struct genlmsg
*genlmsg_alloc(size_t size
);
98 extern void rtnlmsg_free(struct rtnlmsg
*rtnlmsg
);
101 * rtnetlink_transaction : send and receive a route netlink message in one shot
103 * @handler: the handler of the route netlink socket
104 * @request: a route netlink message containing the request to be sent
105 * @answer: a pre-allocated route netlink message to receive the response
107 * Returns 0 on success, < 0 otherwise
109 extern int rtnetlink_transaction(struct rtnl_handler
*handler
,
110 struct rtnlmsg
*request
,
111 struct rtnlmsg
*answer
);
113 #endif /* __LXC_RTNL_H */