Skip to content

Commit b3eb51a

Browse files
committed
lwIP: fix some IPv6 errors, eg TCP keepalive
Glue code was inspecting lwIP's netconn "type", checking directly for NETCONN_UDP and NETCONN_TCP. Unfortunately the type byte has some flag bits like "IPv6", which means the tests fail if it's an IPv6 socket. So, for example, TCP socket options were rejected for IPv6. Add the necessary NETCONNTYPE_GROUP macros to fix this.
1 parent f6bcbfe commit b3eb51a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

features/FEATURE_LWIP/lwip-interface/lwip_stack.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,9 +1125,9 @@ static nsapi_error_t mbed_lwip_socket_bind(nsapi_stack_t *stack, nsapi_socket_t
11251125

11261126
if (
11271127
#if LWIP_TCP
1128-
(s->conn->type == NETCONN_TCP && s->conn->pcb.tcp->local_port != 0) ||
1128+
(NETCONNTYPE_GROUP(s->conn->type) == NETCONN_TCP && s->conn->pcb.tcp->local_port != 0) ||
11291129
#endif
1130-
(s->conn->type == NETCONN_UDP && s->conn->pcb.udp->local_port != 0)) {
1130+
(NETCONNTYPE_GROUP(s->conn->type) == NETCONN_UDP && s->conn->pcb.udp->local_port != 0)) {
11311131
return NSAPI_ERROR_PARAMETER;
11321132
}
11331133

@@ -1307,23 +1307,23 @@ static nsapi_error_t mbed_lwip_setsockopt(nsapi_stack_t *stack, nsapi_socket_t h
13071307
switch (optname) {
13081308
#if LWIP_TCP
13091309
case NSAPI_KEEPALIVE:
1310-
if (optlen != sizeof(int) || s->conn->type != NETCONN_TCP) {
1310+
if (optlen != sizeof(int) || NETCONNTYPE_GROUP(s->conn->type) != NETCONN_TCP) {
13111311
return NSAPI_ERROR_UNSUPPORTED;
13121312
}
13131313

13141314
s->conn->pcb.tcp->so_options |= SOF_KEEPALIVE;
13151315
return 0;
13161316

13171317
case NSAPI_KEEPIDLE:
1318-
if (optlen != sizeof(int) || s->conn->type != NETCONN_TCP) {
1318+
if (optlen != sizeof(int) || NETCONNTYPE_GROUP(s->conn->type) != NETCONN_TCP) {
13191319
return NSAPI_ERROR_UNSUPPORTED;
13201320
}
13211321

13221322
s->conn->pcb.tcp->keep_idle = *(int*)optval;
13231323
return 0;
13241324

13251325
case NSAPI_KEEPINTVL:
1326-
if (optlen != sizeof(int) || s->conn->type != NETCONN_TCP) {
1326+
if (optlen != sizeof(int) || NETCONNTYPE_GROUP(s->conn->type) != NETCONN_TCP) {
13271327
return NSAPI_ERROR_UNSUPPORTED;
13281328
}
13291329

0 commit comments

Comments
 (0)