* create_netlink(): Create netlink socket and returns it.
* Returns: Created socket on success and -1 on failure.
*/
-int create_netlink(int protocol, uint32_t groups)
+API int create_netlink(int protocol, uint32_t groups)
{
/**
* TODO it's one socket, in future make set of sockets
int sock;
sock = socket(PF_NETLINK, SOCK_RAW, protocol);
if (sock < 0)
- return -EINVAL;
+ return -EINVAL; //LCOV_EXCL_LINE
struct sockaddr_nl src_addr = { 0, };
src_addr.nl_groups = groups;
if (bind(sock, (struct sockaddr *)&src_addr, sizeof(src_addr)) < 0) {
- close(sock);
- return -1;
+ close(sock); //LCOV_EXCL_LINE
+ return -1; //LCOV_EXCL_LINE
}
return sock;
/* read netlink message from socket
* return opaque pointer to genl structure
*/
-int read_netlink(int sock, void *buf, size_t len)
+API int read_netlink(int sock, void *buf, size_t len)
{
ssize_t ret;
struct sockaddr_nl addr;
};
ret = recvmsg(sock, &msg, 0);
if (ret == -1)
- return ret;
+ return ret; //LCOV_EXCL_LINE
if (msg.msg_flags & MSG_TRUNC) {
- errno = ENOSPC;
- return -1;
+ errno = ENOSPC; //LCOV_EXCL_LINE
+ return -1; //LCOV_EXCL_LINE
}
if (msg.msg_namelen != sizeof(struct sockaddr_nl)) {
- errno = EINVAL;
- return -1;
+ errno = EINVAL; //LCOV_EXCL_LINE
+ return -1; //LCOV_EXCL_LINE
}
return ret;