Skip to content

Commit 37fbb7c

Browse files
kjbraceyadbridge
authored andcommitted
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 ddccbdf commit 37fbb7c

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

@@ -1315,23 +1315,23 @@ static nsapi_error_t mbed_lwip_setsockopt(nsapi_stack_t *stack, nsapi_socket_t h
13151315
switch (optname) {
13161316
#if LWIP_TCP
13171317
case NSAPI_KEEPALIVE:
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->so_options |= SOF_KEEPALIVE;
13231323
return 0;
13241324

13251325
case NSAPI_KEEPIDLE:
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

13301330
s->conn->pcb.tcp->keep_idle = *(int*)optval;
13311331
return 0;
13321332

13331333
case NSAPI_KEEPINTVL:
1334-
if (optlen != sizeof(int) || s->conn->type != NETCONN_TCP) {
1334+
if (optlen != sizeof(int) || NETCONNTYPE_GROUP(s->conn->type) != NETCONN_TCP) {
13351335
return NSAPI_ERROR_UNSUPPORTED;
13361336
}
13371337

0 commit comments

Comments
 (0)