net: sockets: Add fcntl to socket offloading API

Offload fcntl calls through socket offloading API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2019-01-17 14:55:05 +01:00 committed by Jukka Rissanen
parent 717b647c30
commit 0b93c68f79
4 changed files with 29 additions and 0 deletions

View file

@ -777,6 +777,16 @@ static void simplelink_freeaddrinfo(struct addrinfo *res)
free(res);
}
static int simplelink_fctnl(int fd, int cmd, va_list args)
{
ARG_UNUSED(fd);
ARG_UNUSED(cmd);
ARG_UNUSED(args);
errno = ENOTSUP;
return -1;
}
void simplelink_sockets_init(void)
{
k_mutex_init(&ga_mutex);
@ -798,4 +808,5 @@ const struct socket_offload simplelink_ops = {
.sendto = simplelink_sendto,
.getaddrinfo = simplelink_getaddrinfo,
.freeaddrinfo = simplelink_freeaddrinfo,
.fcntl = simplelink_fctnl,
};

View file

@ -158,6 +158,8 @@ static inline void freeaddrinfo(struct addrinfo *res)
return socket_ops->freeaddrinfo(res);
}
int fcntl(int fd, int cmd, ...);
#ifdef __cplusplus
}
#endif

View file

@ -49,6 +49,7 @@ struct socket_offload {
const struct addrinfo *hints,
struct addrinfo **res);
void (*freeaddrinfo)(struct addrinfo *res);
int (*fcntl)(int fd, int cmd, va_list args);
};
extern void socket_offload_register(const struct socket_offload *ops);

View file

@ -19,3 +19,18 @@ void socket_offload_register(const struct socket_offload *ops)
socket_ops = ops;
}
int fcntl(int fd, int cmd, ...)
{
__ASSERT_NO_MSG(socket_ops);
__ASSERT_NO_MSG(socket_ops->fcntl);
va_list args;
int res;
va_start(args, cmd);
res = socket_ops->fcntl(fd, cmd, args);
va_end(args);
return res;
}