]>
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 <dlezcano at fr.ibm.com>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Use this as a good size to allocate route netlink messages
29 #define RTNLMSG_GOOD_SIZE NLMSG_GOOD_SIZE
30 #define RTNLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + RTNL_HDRLEN))
33 * struct genl_handler : the structure which store the netlink handler
34 * and the family number
36 * @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 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 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 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 int rtnetlink_send(struct rtnl_handler
*handler
, struct rtnlmsg
*rtnlmsg
);
95 struct genlmsg
*genlmsg_alloc(size_t size
);
97 void rtnlmsg_free(struct rtnlmsg
*rtnlmsg
);
100 * rtnetlink_transaction : send and receive a route netlink message in one shot
102 * @handler: the handler of the route netlink socket
103 * @request: a route netlink message containing the request to be sent
104 * @answer: a pre-allocated route netlink message to receive the response
106 * Returns 0 on success, < 0 otherwise
108 int rtnetlink_transaction(struct rtnl_handler
*handler
,
109 struct rtnlmsg
*request
, struct rtnlmsg
*answer
);