mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #2440 from geky/nsapi-lwip-reuseaddr
[nsapi] Add support for NSAPI_REUSEADDR to the lwip interfacepull/2495/merge
commit
c9426e7987
|
@ -28,6 +28,7 @@
|
|||
#include "lwip/dhcp.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/ip.h"
|
||||
|
||||
|
||||
/* Static arena of sockets */
|
||||
|
@ -415,6 +416,18 @@ static int lwip_setsockopt(nsapi_stack_t *stack, nsapi_socket_t handle, int leve
|
|||
s->conn->pcb.tcp->keep_intvl = *(int*)optval;
|
||||
return 0;
|
||||
|
||||
case NSAPI_REUSEADDR:
|
||||
if (optlen != sizeof(int)) {
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (*(int *)optval) {
|
||||
s->conn->pcb.tcp->so_options |= SOF_REUSEADDR;
|
||||
} else {
|
||||
s->conn->pcb.tcp->so_options &= ~SOF_REUSEADDR;
|
||||
}
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@
|
|||
#define LWIP_DHCP 1
|
||||
#define LWIP_DNS 1
|
||||
|
||||
#define SO_REUSE 1
|
||||
|
||||
// Support Multicast
|
||||
#include "stdlib.h"
|
||||
#define LWIP_IGMP 1
|
||||
|
|
Loading…
Reference in New Issue