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