]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/rtnl.h
cgroups: use zalloc
[mirror_lxc.git] / src / lxc / rtnl.h
CommitLineData
cc73685d 1/* SPDX-License-Identifier: LGPL-2.1+ */
736da9d0 2
f1a4a029
ÇO
3#ifndef __LXC_RTNL_H
4#define __LXC_RTNL_H
0ad19a3f 5
6822ba9b
CB
6#include <compiler.h>
7
0ad19a3f 8/*
9 * Use this as a good size to allocate route netlink messages
10 */
11#define RTNLMSG_GOOD_SIZE NLMSG_GOOD_SIZE
12#define RTNLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + RTNL_HDRLEN))
13
14/*
f79d43bb 15 * struct genl_handler : the structure which store the netlink handler
0ad19a3f 16 * and the family number
17 *
18 * @nlh: the netlink socket handler
19 */
736da9d0 20struct rtnl_handler {
0ad19a3f 21 struct nl_handler nlh;
22};
23
24/*
25 * struct rtnlmsg : the struct containing the route netlink message
26 * format
27 *
28 * @nlmsghdr: a netlink message header
29 * @rtnlmsghdr: a route netlink message header pointer
30 *
31 */
32struct rtnlmsg {
33 struct nlmsghdr nlmsghdr;
34};
35
36/*
37 * rtnetlink_open : open a route netlink socket
38 *
39 * @handler: a struct rtnl_handler pointer
40 *
41 * Returns 0 on success, < 0 otherwise
42 */
6822ba9b 43__hidden extern int rtnetlink_open(struct rtnl_handler *handler);
0ad19a3f 44
45/*
46 * genetlink_close : close a route netlink socket
47 *
48 * @handler: the handler of the socket to be closed
0ad19a3f 49 */
6822ba9b 50__hidden extern void rtnetlink_close(struct rtnl_handler *handler);
0ad19a3f 51
52/*
53 * rtnetlink_rcv : receive a route netlink socket, it is up
54 * to the caller to manage the allocation of the route netlink message
55 *
56 * @handler: the handler of the route netlink socket
57 * @rtnlmsg: the pointer to a route netlink message pre-allocated
58 *
59 * Returns 0 on success, < 0 otherwise
60 */
6822ba9b 61__hidden extern int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
0ad19a3f 62
63/*
64 * rtnetlink_send : send a route netlink socket, it is up
65 * to the caller to manage the allocation of the route netlink message
66 *
67 * @handler: the handler of the route netlink socket
68 * @rtnlmsg: the pointer to a netlink message pre-allocated
69 *
70 * Returns 0 on success, < 0 otherwise
71 */
6822ba9b 72__hidden extern int rtnetlink_send(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
0ad19a3f 73
6822ba9b 74__hidden struct genlmsg *genlmsg_alloc(size_t size);
0ad19a3f 75
6822ba9b 76__hidden extern void rtnlmsg_free(struct rtnlmsg *rtnlmsg);
0ad19a3f 77
78/*
79 * rtnetlink_transaction : send and receive a route netlink message in one shot
80 *
81 * @handler: the handler of the route netlink socket
82 * @request: a route netlink message containing the request to be sent
83 * @answer: a pre-allocated route netlink message to receive the response
84 *
85 * Returns 0 on success, < 0 otherwise
86 */
6822ba9b
CB
87__hidden extern int rtnetlink_transaction(struct rtnl_handler *handler, struct rtnlmsg *request,
88 struct rtnlmsg *answer);
89
90__hidden struct rtnlmsg *rtnlmsg_alloc(size_t size);
736da9d0
CB
91
92#endif /* __LXC_RTNL_H */