sockets: add hooks to implement additional socket options

LWIP_HOOK_SOCKETS_SETSOCKOPT() and LWIP_HOOK_SOCKETS_GETSOCKOPT()
are introduced to implement additional socket options. The hooks
are always called first and report back if they handled the option
or not.

Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
goldsimon
2018-01-24 14:35:17 +01:00
parent 61671d6df0
commit ce79811bce
2 changed files with 60 additions and 0 deletions

View File

@@ -64,6 +64,10 @@
#include <string.h>
#ifdef LWIP_HOOK_FILENAME
#include LWIP_HOOK_FILENAME
#endif
/* If the netconn API is not required publicly, then we include the necessary
files here to get the implementation */
#if !LWIP_NETCONN
@@ -2835,6 +2839,12 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt
return EBADF;
}
#ifdef LWIP_HOOK_SOCKETS_GETSOCKOPT
if (LWIP_HOOK_SOCKETS_GETSOCKOPT(s, sock, level, optname, optval, optlen, &err)) {
return err;
}
#endif
switch (level) {
/* Level: SOL_SOCKET */
@@ -3250,6 +3260,12 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
return EBADF;
}
#ifdef LWIP_HOOK_SOCKETS_SETSOCKOPT
if (LWIP_HOOK_SOCKETS_SETSOCKOPT(s, sock, level, optname, optval, optlen, &err)) {
return err;
}
#endif
switch (level) {
/* Level: SOL_SOCKET */