From 0b93c68f79108a1026d452dde5d28a119f55d14f Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Thu, 17 Jan 2019 14:55:05 +0100 Subject: [PATCH] net: sockets: Add fcntl to socket offloading API Offload fcntl calls through socket offloading API. Signed-off-by: Robert Lubos --- drivers/wifi/simplelink/simplelink_sockets.c | 11 +++++++++++ include/net/socket_offload.h | 2 ++ include/net/socket_offload_ops.h | 1 + subsys/net/lib/sockets/socket_offload.c | 15 +++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/drivers/wifi/simplelink/simplelink_sockets.c b/drivers/wifi/simplelink/simplelink_sockets.c index 59e5c766b7..9e25fc236d 100644 --- a/drivers/wifi/simplelink/simplelink_sockets.c +++ b/drivers/wifi/simplelink/simplelink_sockets.c @@ -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, }; diff --git a/include/net/socket_offload.h b/include/net/socket_offload.h index f9f0212b37..3961d8e8c0 100644 --- a/include/net/socket_offload.h +++ b/include/net/socket_offload.h @@ -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 diff --git a/include/net/socket_offload_ops.h b/include/net/socket_offload_ops.h index 37a64fdd8b..b68c9348ae 100644 --- a/include/net/socket_offload_ops.h +++ b/include/net/socket_offload_ops.h @@ -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); diff --git a/subsys/net/lib/sockets/socket_offload.c b/subsys/net/lib/sockets/socket_offload.c index bd78897c43..ed12c0433a 100644 --- a/subsys/net/lib/sockets/socket_offload.c +++ b/subsys/net/lib/sockets/socket_offload.c @@ -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; +}