#include <stdio.h>
+#include "compiler.h"
#include "memory_utils.h"
/*
*
* Return 0 on success, < 0 otherwise
*/
-int netlink_open(struct nl_handler *handler, int protocol);
+__hidden extern int netlink_open(struct nl_handler *handler, int protocol);
/*
* netlink_close : close a netlink socket, after this call,
*
* @handler: a handler to the netlink socket
*/
-void netlink_close(struct nl_handler *handler);
+__hidden extern void netlink_close(struct nl_handler *handler);
define_cleanup_function(struct nl_handler *, netlink_close);
/*
*
* Returns 0 on success, < 0 otherwise
*/
-int netlink_rcv(struct nl_handler *handler, struct nlmsg *nlmsg);
-int __netlink_recv(struct nl_handler *handler, struct nlmsghdr *nlmsg);
+__hidden extern int netlink_rcv(struct nl_handler *handler, struct nlmsg *nlmsg);
+__hidden extern int __netlink_recv(struct nl_handler *handler, struct nlmsghdr *nlmsg);
/*
* netlink_send: send a netlink message to the kernel. It is up
*
* Returns 0 on success, < 0 otherwise
*/
-int netlink_send(struct nl_handler *handler, struct nlmsg *nlmsg);
-int __netlink_send(struct nl_handler *handler, struct nlmsghdr *nlmsg);
+__hidden extern int netlink_send(struct nl_handler *handler, struct nlmsg *nlmsg);
+__hidden extern int __netlink_send(struct nl_handler *handler, struct nlmsghdr *nlmsg);
/*
* netlink_transaction: send a request to the kernel and read the response.
*
* Returns 0 on success, < 0 otherwise
*/
-int netlink_transaction(struct nl_handler *handler,
- struct nlmsg *request, struct nlmsg *answer);
-int __netlink_transaction(struct nl_handler *handler, struct nlmsghdr *request,
- struct nlmsghdr *answer);
+__hidden extern int netlink_transaction(struct nl_handler *handler, struct nlmsg *request,
+ struct nlmsg *answer);
+__hidden extern int __netlink_transaction(struct nl_handler *handler, struct nlmsghdr *request,
+ struct nlmsghdr *answer);
/*
* nla_put_string: copy a null terminated string to a netlink message
*
* Returns 0 on success, < 0 otherwise
*/
-int nla_put_string(struct nlmsg *nlmsg, int attr, const char *string);
+__hidden int nla_put_string(struct nlmsg *nlmsg, int attr, const char *string);
/*
* nla_put_buffer: copy a buffer with a specified size to a netlink
* Returns current nested pointer to be reused
* to nla_end_nested.
*/
-struct rtattr *nla_begin_nested(struct nlmsg *nlmsg, int attr);
+__hidden extern struct rtattr *nla_begin_nested(struct nlmsg *nlmsg, int attr);
/*
* nla_end_nested: end the nesting attribute
*
* Returns the current
*/
-void nla_end_nested(struct nlmsg *nlmsg, struct rtattr *attr);
+__hidden extern void nla_end_nested(struct nlmsg *nlmsg, struct rtattr *attr);
/*
* nlmsg_allocate : allocate a netlink message. The netlink format message
*
* Returns a pointer to the newly allocated netlink message, NULL otherwise
*/
-struct nlmsg *nlmsg_alloc(size_t size);
+__hidden extern struct nlmsg *nlmsg_alloc(size_t size);
/*
* nlmsg_alloc_reserve: like nlmsg_alloc(), but reserve the whole payload
*
* @size: the capacity of the payload to be allocated.
*/
-struct nlmsg *nlmsg_alloc_reserve(size_t size);
+__hidden extern struct nlmsg *nlmsg_alloc_reserve(size_t size);
/*
* Reserve room for additional data at the tail of a netlink message
*
* Returns a pointer to newly reserved room or NULL
*/
-void *nlmsg_reserve(struct nlmsg *nlmsg, size_t len);
+__hidden extern void *nlmsg_reserve(struct nlmsg *nlmsg, size_t len);
/*
* nlmsg_free : free a previously allocate message
*
* @nlmsg: the netlink message to be freed
*/
-void nlmsg_free(struct nlmsg *nlmsg);
+__hidden extern void nlmsg_free(struct nlmsg *nlmsg);
define_cleanup_function(struct nlmsg *, nlmsg_free);
/*
*
* Returns a pointer to the netlink data or NULL if there is no data
*/
-void *nlmsg_data(struct nlmsg *nlmsg);
+__hidden extern void *nlmsg_data(struct nlmsg *nlmsg);
-extern int addattr(struct nlmsghdr *n, size_t maxlen, int type,
- const void *data, size_t alen);
+__hidden extern int addattr(struct nlmsghdr *n, size_t maxlen, int type,
+ const void *data, size_t alen);
#endif
#include "nl.h"
#include "rtnl.h"
-extern int rtnetlink_open(struct rtnl_handler *handler)
+int rtnetlink_open(struct rtnl_handler *handler)
{
return netlink_open(&handler->nlh, NETLINK_ROUTE);
}
-extern void rtnetlink_close(struct rtnl_handler *handler)
+void rtnetlink_close(struct rtnl_handler *handler)
{
netlink_close(&handler->nlh);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align"
-extern int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
+int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
{
return netlink_rcv(&handler->nlh, (struct nlmsg *)&rtnlmsg->nlmsghdr);
}
-extern int rtnetlink_send(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
+int rtnetlink_send(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
{
return netlink_send(&handler->nlh, (struct nlmsg *)&rtnlmsg->nlmsghdr);
}
-extern int rtnetlink_transaction(struct rtnl_handler *handler,
- struct rtnlmsg *request,
- struct rtnlmsg *answer)
+int rtnetlink_transaction(struct rtnl_handler *handler, struct rtnlmsg *request,
+ struct rtnlmsg *answer)
{
return netlink_transaction(&handler->nlh,
(struct nlmsg *)&request->nlmsghdr,
#pragma GCC diagnostic pop
-extern struct rtnlmsg *rtnlmsg_alloc(size_t size)
+struct rtnlmsg *rtnlmsg_alloc(size_t size)
{
/*
size_t len;
return NULL;
}
-extern void rtnlmsg_free(struct rtnlmsg *rtnlmsg) { free(rtnlmsg); }
+void rtnlmsg_free(struct rtnlmsg *rtnlmsg) { free(rtnlmsg); }
#ifndef __LXC_RTNL_H
#define __LXC_RTNL_H
+#include <compiler.h>
+
/*
* Use this as a good size to allocate route netlink messages
*/
*
* Returns 0 on success, < 0 otherwise
*/
-extern int rtnetlink_open(struct rtnl_handler *handler);
+__hidden extern int rtnetlink_open(struct rtnl_handler *handler);
/*
* genetlink_close : close a route netlink socket
*
* @handler: the handler of the socket to be closed
*/
-extern void rtnetlink_close(struct rtnl_handler *handler);
+__hidden extern void rtnetlink_close(struct rtnl_handler *handler);
/*
* rtnetlink_rcv : receive a route netlink socket, it is up
*
* Returns 0 on success, < 0 otherwise
*/
-extern int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
+__hidden extern int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
/*
* rtnetlink_send : send a route netlink socket, it is up
*
* Returns 0 on success, < 0 otherwise
*/
-extern int rtnetlink_send(struct rtnl_handler *handler,
- struct rtnlmsg *rtnlmsg);
+__hidden extern int rtnetlink_send(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg);
-struct genlmsg *genlmsg_alloc(size_t size);
+__hidden struct genlmsg *genlmsg_alloc(size_t size);
-extern void rtnlmsg_free(struct rtnlmsg *rtnlmsg);
+__hidden extern void rtnlmsg_free(struct rtnlmsg *rtnlmsg);
/*
* rtnetlink_transaction : send and receive a route netlink message in one shot
*
* Returns 0 on success, < 0 otherwise
*/
-extern int rtnetlink_transaction(struct rtnl_handler *handler,
- struct rtnlmsg *request,
- struct rtnlmsg *answer);
+__hidden extern int rtnetlink_transaction(struct rtnl_handler *handler, struct rtnlmsg *request,
+ struct rtnlmsg *answer);
+
+__hidden struct rtnlmsg *rtnlmsg_alloc(size_t size);
#endif /* __LXC_RTNL_H */