Merge pull request #2440 from geky/nsapi-lwip-reuseaddr

[nsapi] Add support for NSAPI_REUSEADDR to the lwip interface
pull/2495/merge
Martin Kojtal 2016-08-19 11:23:21 +01:00 committed by GitHub
commit c9426e7987
2 changed files with 15 additions and 0 deletions

View File

@ -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;
}

View File

@ -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