]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/rtnl.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
9 * Use this as a good size to allocate route netlink messages
11 #define RTNLMSG_GOOD_SIZE NLMSG_GOOD_SIZE
12 #define RTNLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + RTNL_HDRLEN))
15 * struct genl_handler : the structure which store the netlink handler
16 * and the family number
18 * @nlh: the netlink socket handler
21 struct nl_handler nlh
;
25 * struct rtnlmsg : the struct containing the route netlink message
28 * @nlmsghdr: a netlink message header
29 * @rtnlmsghdr: a route netlink message header pointer
33 struct nlmsghdr nlmsghdr
;
37 * rtnetlink_open : open a route netlink socket
39 * @handler: a struct rtnl_handler pointer
41 * Returns 0 on success, < 0 otherwise
43 __hidden
extern int rtnetlink_open(struct rtnl_handler
*handler
);
46 * genetlink_close : close a route netlink socket
48 * @handler: the handler of the socket to be closed
50 __hidden
extern void rtnetlink_close(struct rtnl_handler
*handler
);
53 * rtnetlink_rcv : receive a route netlink socket, it is up
54 * to the caller to manage the allocation of the route netlink message
56 * @handler: the handler of the route netlink socket
57 * @rtnlmsg: the pointer to a route netlink message pre-allocated
59 * Returns 0 on success, < 0 otherwise
61 __hidden
extern int rtnetlink_rcv(struct rtnl_handler
*handler
, struct rtnlmsg
*rtnlmsg
);
64 * rtnetlink_send : send a route netlink socket, it is up
65 * to the caller to manage the allocation of the route netlink message
67 * @handler: the handler of the route netlink socket
68 * @rtnlmsg: the pointer to a netlink message pre-allocated
70 * Returns 0 on success, < 0 otherwise
72 __hidden
extern int rtnetlink_send(struct rtnl_handler
*handler
, struct rtnlmsg
*rtnlmsg
);
74 __hidden
struct genlmsg
*genlmsg_alloc(size_t size
);
76 __hidden
extern void rtnlmsg_free(struct rtnlmsg
*rtnlmsg
);
79 * rtnetlink_transaction : send and receive a route netlink message in one shot
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
85 * Returns 0 on success, < 0 otherwise
87 __hidden
extern int rtnetlink_transaction(struct rtnl_handler
*handler
, struct rtnlmsg
*request
,
88 struct rtnlmsg
*answer
);
90 __hidden
struct rtnlmsg
*rtnlmsg_alloc(size_t size
);
92 #endif /* __LXC_RTNL_H */