Applied patch by James Smith to implement IPV6_V6ONLY support in

sockets and netconns.

Change-Id: I2ecd8e218703114890b2d678cc1ccf997a16f5e3
This commit is contained in:
James Smith
2012-07-03 13:16:04 -06:00
committed by Ivan Delamer
parent b56a1501d2
commit e65202f825
4 changed files with 104 additions and 2 deletions

View File

@@ -1076,11 +1076,23 @@ lwip_netconn_do_listen(struct api_msg_msg *msg)
if (msg->conn->pcb.tcp != NULL) {
if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_TCP) {
if (msg->conn->state == NETCONN_NONE) {
struct tcp_pcb* lpcb;
#if LWIP_IPV6
if ((msg->conn->flags & NETCONN_FLAG_IPV6_V6ONLY) == 0) {
#if TCP_LISTEN_BACKLOG
struct tcp_pcb* lpcb = tcp_listen_with_backlog(msg->conn->pcb.tcp, msg->msg.lb.backlog);
lpcb = tcp_listen_dual_with_backlog(msg->conn->pcb.tcp, msg->msg.lb.backlog);
#else /* TCP_LISTEN_BACKLOG */
struct tcp_pcb* lpcb = tcp_listen(msg->conn->pcb.tcp);
lpcb = tcp_listen_dual(msg->conn->pcb.tcp);
#endif /* TCP_LISTEN_BACKLOG */
} else
#endif /* LWIP_IPV6 */
{
#if TCP_LISTEN_BACKLOG
lpcb = tcp_listen_with_backlog(msg->conn->pcb.tcp, msg->msg.lb.backlog);
#else /* TCP_LISTEN_BACKLOG */
lpcb = tcp_listen(msg->conn->pcb.tcp);
#endif /* TCP_LISTEN_BACKLOG */
}
if (lpcb == NULL) {
/* in this case, the old pcb is still allocated */
msg->err = ERR_MEM;

View File

@@ -1664,6 +1664,24 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
} /* switch (optname) */
break;
#endif /* LWIP_TCP */
#if LWIP_IPV6
/* Level: IPPROTO_IPV6 */
case IPPROTO_IPV6:
switch (optname) {
case IPV6_V6ONLY:
if (*optlen < sizeof(int)) {
err = EINVAL;
}
break;
default:
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IPV6, UNIMPL: optname=0x%x, ..)\n",
s, optname));
err = ENOPROTOOPT;
} /* switch (optname) */
break;
#endif /* LWIP_IPV6 */
#if LWIP_UDP && LWIP_UDPLITE
/* Level: IPPROTO_UDPLITE */
case IPPROTO_UDPLITE:
@@ -1902,6 +1920,23 @@ lwip_getsockopt_internal(void *arg)
} /* switch (optname) */
break;
#endif /* LWIP_TCP */
#if LWIP_IPV6
/* Level: IPPROTO_IPV6 */
case IPPROTO_IPV6:
switch (optname) {
case IPV6_V6ONLY:
*(int*)optval = ((sock->conn->flags & NETCONN_FLAG_IPV6_V6ONLY) ? 1 : 0);
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IPV6, IPV6_V6ONLY) = %d\n",
s, *(int *)optval));
break;
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */
break;
#endif /* LWIP_IPV6 */
#if LWIP_UDP && LWIP_UDPLITE
/* Level: IPPROTO_UDPLITE */
case IPPROTO_UDPLITE:
@@ -2081,6 +2116,24 @@ lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t opt
} /* switch (optname) */
break;
#endif /* LWIP_TCP */
#if LWIP_IPV6
/* Level: IPPROTO_IPV6 */
case IPPROTO_IPV6:
switch (optname) {
case IPV6_V6ONLY:
if (optlen < sizeof(int)) {
err = EINVAL;
}
break;
default:
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IPV6, UNIMPL: optname=0x%x, ..)\n",
s, optname));
err = ENOPROTOOPT;
} /* switch (optname) */
break;
#endif /* LWIP_IPV6 */
#if LWIP_UDP && LWIP_UDPLITE
/* Level: IPPROTO_UDPLITE */
case IPPROTO_UDPLITE:
@@ -2310,6 +2363,27 @@ lwip_setsockopt_internal(void *arg)
} /* switch (optname) */
break;
#endif /* LWIP_TCP*/
#if LWIP_IPV6
/* Level: IPPROTO_IPV6 */
case IPPROTO_IPV6:
switch (optname) {
case IPV6_V6ONLY:
if (*(int*)optval) {
sock->conn->flags |= NETCONN_FLAG_IPV6_V6ONLY;
} else {
sock->conn->flags &= ~NETCONN_FLAG_IPV6_V6ONLY;
}
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IPV6, IPV6_V6ONLY, ..) -> %d\n",
s, ((sock->conn->flags & NETCONN_FLAG_IPV6_V6ONLY) ? 1 : 0)));
break;
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */
break;
#endif /* LWIP_IPV6 */
#if LWIP_UDP && LWIP_UDPLITE
/* Level: IPPROTO_UDPLITE */
case IPPROTO_UDPLITE: