@@ -407,7 +407,7 @@ alloc_socket(struct netconn *newconn, int accepted)
407
407
for (i = 0 ; i < NUM_SOCKETS ; ++ i ) {
408
408
/* Protect socket array */
409
409
SYS_ARCH_PROTECT (lev );
410
- if (!sockets [i ].conn ) {
410
+ if (!sockets [i ].conn && ( sockets [ i ]. select_waiting == 0 ) ) {
411
411
sockets [i ].conn = newconn ;
412
412
/* The socket is not yet known to anyone, so no need to protect
413
413
after having marked it as used. */
@@ -420,7 +420,6 @@ alloc_socket(struct netconn *newconn, int accepted)
420
420
sockets [i ].sendevent = (NETCONNTYPE_GROUP (newconn -> type ) == NETCONN_TCP ? (accepted != 0 ) : 1 );
421
421
sockets [i ].errevent = 0 ;
422
422
sockets [i ].err = 0 ;
423
- sockets [i ].select_waiting = 0 ;
424
423
return i + LWIP_SOCKET_OFFSET ;
425
424
}
426
425
SYS_ARCH_UNPROTECT (lev );
@@ -585,9 +584,9 @@ lwip_bind(int s, const struct sockaddr *name, socklen_t namelen)
585
584
LWIP_DEBUGF (SOCKETS_DEBUG , (" port=%" U16_F ")\n" , local_port ));
586
585
587
586
#if LWIP_IPV4 && LWIP_IPV6
588
- /* Dual-stack: Unmap IPv6 mapped IPv4 addresses */
589
- if (IP_IS_V6_VAL (local_addr ) && ip6_addr_isipv6mappedipv4 (ip_2_ip6 (& local_addr ))) {
590
- unmap_ipv6_mapped_ipv4 (ip_2_ip4 (& local_addr ), ip_2_ip6 (& local_addr ));
587
+ /* Dual-stack: Unmap IPv4 mapped IPv6 addresses */
588
+ if (IP_IS_V6_VAL (local_addr ) && ip6_addr_isipv4mappedipv6 (ip_2_ip6 (& local_addr ))) {
589
+ unmap_ipv4_mapped_ipv6 (ip_2_ip4 (& local_addr ), ip_2_ip6 (& local_addr ));
591
590
IP_SET_TYPE_VAL (local_addr , IPADDR_TYPE_V4 );
592
591
}
593
592
#endif /* LWIP_IPV4 && LWIP_IPV6 */
@@ -677,9 +676,9 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t namelen)
677
676
LWIP_DEBUGF (SOCKETS_DEBUG , (" port=%" U16_F ")\n" , remote_port ));
678
677
679
678
#if LWIP_IPV4 && LWIP_IPV6
680
- /* Dual-stack: Unmap IPv6 mapped IPv4 addresses */
681
- if (IP_IS_V6_VAL (remote_addr ) && ip6_addr_isipv6mappedipv4 (ip_2_ip6 (& remote_addr ))) {
682
- unmap_ipv6_mapped_ipv4 (ip_2_ip4 (& remote_addr ), ip_2_ip6 (& remote_addr ));
679
+ /* Dual-stack: Unmap IPv4 mapped IPv6 addresses */
680
+ if (IP_IS_V6_VAL (remote_addr ) && ip6_addr_isipv4mappedipv6 (ip_2_ip6 (& remote_addr ))) {
681
+ unmap_ipv4_mapped_ipv6 (ip_2_ip4 (& remote_addr ), ip_2_ip6 (& remote_addr ));
683
682
IP_SET_TYPE_VAL (remote_addr , IPADDR_TYPE_V4 );
684
683
}
685
684
#endif /* LWIP_IPV4 && LWIP_IPV6 */
@@ -865,9 +864,9 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
865
864
}
866
865
867
866
#if LWIP_IPV4 && LWIP_IPV6
868
- /* Dual-stack: Map IPv4 addresses to IPv6 mapped IPv4 */
867
+ /* Dual-stack: Map IPv4 addresses to IPv4 mapped IPv6 */
869
868
if (NETCONNTYPE_ISIPV6 (netconn_type (sock -> conn )) && IP_IS_V4 (fromaddr )) {
870
- ip4_2_ipv6_mapped_ipv4 (ip_2_ip6 (fromaddr ), ip_2_ip4 (fromaddr ));
869
+ ip4_2_ipv4_mapped_ipv6 (ip_2_ip6 (fromaddr ), ip_2_ip4 (fromaddr ));
871
870
IP_SET_TYPE (fromaddr , IPADDR_TYPE_V6 );
872
871
}
873
872
#endif /* LWIP_IPV4 && LWIP_IPV6 */
@@ -995,6 +994,10 @@ lwip_sendmsg(int s, const struct msghdr *msg, int flags)
995
994
((flags & MSG_DONTWAIT ) ? NETCONN_DONTBLOCK : 0 );
996
995
997
996
for (i = 0 ; i < msg -> msg_iovlen ; i ++ ) {
997
+ u8_t apiflags = write_flags ;
998
+ if (i + 1 < msg -> msg_iovlen ) {
999
+ apiflags |= NETCONN_MORE ;
1000
+ }
998
1001
written = 0 ;
999
1002
err = netconn_write_partly (sock -> conn , msg -> msg_iov [i ].iov_base , msg -> msg_iov [i ].iov_len , write_flags , & written );
1000
1003
if (err == ERR_OK ) {
@@ -1092,9 +1095,9 @@ lwip_sendmsg(int s, const struct msghdr *msg, int flags)
1092
1095
1093
1096
if (err == ERR_OK ) {
1094
1097
#if LWIP_IPV4 && LWIP_IPV6
1095
- /* Dual-stack: Unmap IPv6 mapped IPv4 addresses */
1096
- if (IP_IS_V6_VAL (chain_buf -> addr ) && ip6_addr_isipv6mappedipv4 (ip_2_ip6 (& chain_buf -> addr ))) {
1097
- unmap_ipv6_mapped_ipv4 (ip_2_ip4 (& chain_buf -> addr ), ip_2_ip6 (& chain_buf -> addr ));
1098
+ /* Dual-stack: Unmap IPv4 mapped IPv6 addresses */
1099
+ if (IP_IS_V6_VAL (chain_buf -> addr ) && ip6_addr_isipv4mappedipv6 (ip_2_ip6 (& chain_buf -> addr ))) {
1100
+ unmap_ipv4_mapped_ipv6 (ip_2_ip4 (& chain_buf -> addr ), ip_2_ip6 (& chain_buf -> addr ));
1098
1101
IP_SET_TYPE_VAL (chain_buf -> addr , IPADDR_TYPE_V4 );
1099
1102
}
1100
1103
#endif /* LWIP_IPV4 && LWIP_IPV6 */
@@ -1190,9 +1193,9 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
1190
1193
#endif /* LWIP_NETIF_TX_SINGLE_PBUF */
1191
1194
if (err == ERR_OK ) {
1192
1195
#if LWIP_IPV4 && LWIP_IPV6
1193
- /* Dual-stack: Unmap IPv6 mapped IPv4 addresses */
1194
- if (IP_IS_V6_VAL (buf .addr ) && ip6_addr_isipv6mappedipv4 (ip_2_ip6 (& buf .addr ))) {
1195
- unmap_ipv6_mapped_ipv4 (ip_2_ip4 (& buf .addr ), ip_2_ip6 (& buf .addr ));
1196
+ /* Dual-stack: Unmap IPv4 mapped IPv6 addresses */
1197
+ if (IP_IS_V6_VAL (buf .addr ) && ip6_addr_isipv4mappedipv6 (ip_2_ip6 (& buf .addr ))) {
1198
+ unmap_ipv4_mapped_ipv6 (ip_2_ip4 (& buf .addr ), ip_2_ip6 (& buf .addr ));
1196
1199
IP_SET_TYPE_VAL (buf .addr , IPADDR_TYPE_V4 );
1197
1200
}
1198
1201
#endif /* LWIP_IPV4 && LWIP_IPV6 */
@@ -1490,9 +1493,7 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
1490
1493
SYS_ARCH_PROTECT (lev );
1491
1494
sock = tryget_socket (i );
1492
1495
if (sock != NULL ) {
1493
- /* @todo: what if this is a new socket (reallocated?) in this case,
1494
- select_waiting-- would be wrong (a global 'sockalloc' counter,
1495
- stored per socket could help) */
1496
+ /* for now, handle select_waiting==0... */
1496
1497
LWIP_ASSERT ("sock->select_waiting > 0" , sock -> select_waiting > 0 );
1497
1498
if (sock -> select_waiting > 0 ) {
1498
1499
sock -> select_waiting -- ;
@@ -1684,8 +1685,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
1684
1685
}
1685
1686
1686
1687
/**
1687
- * Unimplemented: Close one end of a full-duplex connection.
1688
- * Currently, the full connection is closed.
1688
+ * Close one end of a full-duplex connection.
1689
1689
*/
1690
1690
int
1691
1691
lwip_shutdown (int s , int how )
@@ -1750,10 +1750,10 @@ lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
1750
1750
}
1751
1751
1752
1752
#if LWIP_IPV4 && LWIP_IPV6
1753
- /* Dual-stack: Map IPv4 addresses to IPv6 mapped IPv4 */
1753
+ /* Dual-stack: Map IPv4 addresses to IPv4 mapped IPv6 */
1754
1754
if (NETCONNTYPE_ISIPV6 (netconn_type (sock -> conn )) &&
1755
1755
IP_IS_V4_VAL (naddr )) {
1756
- ip4_2_ipv6_mapped_ipv4 (ip_2_ip6 (& naddr ), ip_2_ip4 (& naddr ));
1756
+ ip4_2_ipv4_mapped_ipv6 (ip_2_ip6 (& naddr ), ip_2_ip4 (& naddr ));
1757
1757
IP_SET_TYPE_VAL (naddr , IPADDR_TYPE_V6 );
1758
1758
}
1759
1759
#endif /* LWIP_IPV4 && LWIP_IPV6 */
@@ -2574,6 +2574,12 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
2574
2574
switch (optname ) {
2575
2575
#if LWIP_IPV6 && LWIP_RAW
2576
2576
case IPV6_CHECKSUM :
2577
+ /* It should not be possible to disable the checksum generation with ICMPv6
2578
+ * as per RFC 3542 chapter 3.1 */
2579
+ if (sock -> conn -> pcb .raw -> protocol == IPPROTO_ICMPV6 ) {
2580
+ return EINVAL ;
2581
+ }
2582
+
2577
2583
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE (sock , optlen , int , NETCONN_RAW );
2578
2584
if (* (const int * )optval < 0 ) {
2579
2585
sock -> conn -> pcb .raw -> chksum_reqd = 0 ;
0 commit comments