]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/rtnl.h
spelling: timeout
[mirror_lxc.git] / src / lxc / rtnl.h
CommitLineData
0ad19a3f 1/*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2008
5 *
6 * Authors:
9afe19d6 7 * Daniel Lezcano <daniel.lezcano at free.fr>
0ad19a3f 8 *
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.
13 *
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.
18 *
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
250b1eec 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0ad19a3f 22 */
736da9d0 23
f1a4a029
ÇO
24#ifndef __LXC_RTNL_H
25#define __LXC_RTNL_H
0ad19a3f 26
27/*
28 * Use this as a good size to allocate route netlink messages
29 */
30#define RTNLMSG_GOOD_SIZE NLMSG_GOOD_SIZE
31#define RTNLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + RTNL_HDRLEN))
32
33/*
f79d43bb 34 * struct genl_handler : the structure which store the netlink handler
0ad19a3f 35 * and the family number
36 *
37 * @nlh: the netlink socket handler
38 */
736da9d0 39struct rtnl_handler {
0ad19a3f 40 struct nl_handler nlh;
41};
42
43/*
44 * struct rtnlmsg : the struct containing the route netlink message
45 * format
46 *
47 * @nlmsghdr: a netlink message header
48 * @rtnlmsghdr: a route netlink message header pointer
49 *
50 */
51struct rtnlmsg {
52 struct nlmsghdr nlmsghdr;
53};
54
55/*
56 * rtnetlink_open : open a route netlink socket
57 *
58 * @handler: a struct rtnl_handler pointer
59 *
60 * Returns 0 on success, < 0 otherwise
61 */
736da9d0 62extern int rtnetlink_open(struct rtnl_handler *handler);
0ad19a3f 63
64/*
65 * genetlink_close : close a route netlink socket
66 *
67 * @handler: the handler of the socket to be closed
68 *
69 * Returns 0 on success, < 0 otherwise
70 */
736da9d0 71extern int rtnetlink_close(struct rtnl_handler *handler);
0ad19a3f 72
73/*
74 * rtnetlink_rcv : receive a route netlink socket, it is up
75 * to the caller to manage the allocation of the route netlink message
76 *
77 * @handler: the handler of the route netlink socket
78 * @rtnlmsg: the pointer to a route netlink message pre-allocated
79 *
80 * Returns 0 on success, < 0 otherwise
81 */
736da9d0 82extern int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
0ad19a3f 83
84/*
85 * rtnetlink_send : send a route netlink socket, it is up
86 * to the caller to manage the allocation of the route netlink message
87 *
88 * @handler: the handler of the route netlink socket
89 * @rtnlmsg: the pointer to a netlink message pre-allocated
90 *
91 * Returns 0 on success, < 0 otherwise
92 */
736da9d0
CB
93extern int rtnetlink_send(struct rtnl_handler *handler,
94 struct rtnlmsg *rtnlmsg);
0ad19a3f 95
96struct genlmsg *genlmsg_alloc(size_t size);
97
736da9d0 98extern void rtnlmsg_free(struct rtnlmsg *rtnlmsg);
0ad19a3f 99
100/*
101 * rtnetlink_transaction : send and receive a route netlink message in one shot
102 *
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
106 *
107 * Returns 0 on success, < 0 otherwise
108 */
736da9d0
CB
109extern int rtnetlink_transaction(struct rtnl_handler *handler,
110 struct rtnlmsg *request,
111 struct rtnlmsg *answer);
112
113#endif /* __LXC_RTNL_H */