mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-18 06:06:57 +08:00
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:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user