diff --git a/configs/clicker2-stm32/README.txt b/configs/clicker2-stm32/README.txt index bcd8bd39810..679e95effe0 100644 --- a/configs/clicker2-stm32/README.txt +++ b/configs/clicker2-stm32/README.txt @@ -509,9 +509,9 @@ Configurations 2017-06-23: Added test for TCP functionality. As of yet unverified. 2017-06-24: There are significant problems with the 6LoWPAN TCP send - logic. The problems are due to the fact that the current design - bypasses the normal TCP sending logic and does not correctly support - ACKs and retransmisions. + logic. A major redesign was done to better handle ACKs and + retransmissions, and to work with TCP dynamic windowing. Current + hangs because ACKs are not received. Test Matrix: The following configurations have been tested: diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c index 900d1aaa1c4..41475cb9b58 100644 --- a/net/devif/devif_poll.c +++ b/net/devif/devif_poll.c @@ -122,6 +122,7 @@ static void devif_packet_conversion(FAR struct net_driver_s *dev, if (dev->d_len > 0) #endif { +#ifdef CONFIG_NET_TCP if (pkttype == DEVIF_TCP) { FAR struct ipv6_hdr_s *ipv6 = (FAR struct ipv6_hdr_s *)dev->d_buf; @@ -145,6 +146,7 @@ static void devif_packet_conversion(FAR struct net_driver_s *dev, } } else +#endif { nerr("ERROR: Non-TCP packet dropped. Packet type: %u\n", pkttype); } diff --git a/net/sixlowpan/sixlowpan_hc06.c b/net/sixlowpan/sixlowpan_hc06.c index 4575a301ed5..7981142d39a 100644 --- a/net/sixlowpan/sixlowpan_hc06.c +++ b/net/sixlowpan/sixlowpan_hc06.c @@ -696,10 +696,9 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee, } /* Note that the payload length is always compressed */ - /* Next header. We compress it if UDP */ -#if CONFIG_NET_UDP || UIP_CONF_ROUTER +#ifdef CONFIG_NET_UDP if (ipv6->proto == IP_PROTO_UDP) { iphc0 |= SIXLOWPAN_IPHC_NH; @@ -879,7 +878,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee, g_uncomp_hdrlen = IPv6_HDRLEN; -#if CONFIG_NET_UDP +#ifdef CONFIG_NET_UDP /* UDP header compression */ if (ipv6->proto == IP_PROTO_UDP) diff --git a/net/sixlowpan/sixlowpan_hc1.c b/net/sixlowpan/sixlowpan_hc1.c index dec9ea15767..1a106d45064 100644 --- a/net/sixlowpan/sixlowpan_hc1.c +++ b/net/sixlowpan/sixlowpan_hc1.c @@ -50,6 +50,7 @@ #include #include +#include #include #include @@ -157,8 +158,17 @@ void sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee, !sixlowpan_isaddrbased(ipv6->srcipaddr, &ieee->i_dev.d_mac.ieee802154) || !sixlowpan_islinklocal(ipv6->destipaddr) || !sixlowpan_ismacbased(ipv6->destipaddr, destmac) || - (ipv6->proto != IP_PROTO_ICMP6 && ipv6->proto != IP_PROTO_UDP && - ipv6->proto != IP_PROTO_TCP)) + ( 1 +#ifdef CONFIG_NET_TCP + && ipv6->proto != IP_PROTO_TCP +#endif +#ifdef CONFIG_NET_UDP + && ipv6->proto != IP_PROTO_UDP +#endif +#ifdef CONFIG_NET_ICMPv6 + && ipv6->proto != IP_PROTO_ICMP6 +#endif + )) { /* IPV6 DISPATCH * Something cannot be compressed, use IPV6 DISPATCH, compress @@ -187,25 +197,29 @@ void sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee, g_uncomp_hdrlen += IPv6_HDRLEN; switch (ipv6->proto) { +#ifdef CONFIG_NET_ICMPv6 case IP_PROTO_ICMP6: - /* HC1 encoding and ttl */ + { + /* HC1 encoding and ttl */ - hc1[SIXLOWPAN_HC1_ENCODING] = 0xfc; - hc1[SIXLOWPAN_HC1_TTL] = ipv6->ttl; - g_frame_hdrlen += SIXLOWPAN_HC1_HDR_LEN; + hc1[SIXLOWPAN_HC1_ENCODING] = 0xfc; + hc1[SIXLOWPAN_HC1_TTL] = ipv6->ttl; + g_frame_hdrlen += SIXLOWPAN_HC1_HDR_LEN; + } break; - -#if CONFIG_NET_TCP +#endif +#ifdef CONFIG_NET_TCP case IP_PROTO_TCP: - /* HC1 encoding and ttl */ + { + /* HC1 encoding and ttl */ - hc1[SIXLOWPAN_HC1_ENCODING] = 0xfe; - hc1[SIXLOWPAN_HC1_TTL] = ipv6->ttl; - g_frame_hdrlen += SIXLOWPAN_HC1_HDR_LEN; + hc1[SIXLOWPAN_HC1_ENCODING] = 0xfe; + hc1[SIXLOWPAN_HC1_TTL] = ipv6->ttl; + g_frame_hdrlen += SIXLOWPAN_HC1_HDR_LEN; + } break; -#endif /* CONFIG_NET_TCP */ - -#if CONFIG_NET_UDP +#endif +#ifdef CONFIG_NET_UDP case IP_PROTO_UDP: { FAR struct udp_hdr_s *udp = @@ -254,6 +268,15 @@ void sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee, } break; #endif /* CONFIG_NET_UDP */ + + default: + { + /* Test above assures that this will never happen */ + + nerr("ERROR: Unhandled protocol\n"); + DEBUGPANIC(); + } + break; } } } @@ -310,21 +333,21 @@ int sixlowpan_uncompresshdr_hc1(FAR const struct ieee802154_data_ind_s *ind, switch (hc1[SIXLOWPAN_HC1_ENCODING] & 0x06) { +#ifdef CONFIG_NET_ICMPv6 case SIXLOWPAN_HC1_NH_ICMPv6: ipv6->proto = IP_PROTO_ICMP6; ipv6->ttl = hc1[SIXLOWPAN_HC1_TTL]; g_frame_hdrlen += SIXLOWPAN_HC1_HDR_LEN; break; - -#if CONFIG_NET_TCP +#endif +#ifdef CONFIG_NET_TCP case SIXLOWPAN_HC1_NH_TCP: ipv6->proto = IP_PROTO_TCP; ipv6->ttl = hc1[SIXLOWPAN_HC1_TTL]; g_frame_hdrlen += SIXLOWPAN_HC1_HDR_LEN; break; -#endif /* CONFIG_NET_TCP */ - -#if CONFIG_NET_UDP +#endif +#ifdef CONFIG_NET_UDP case SIXLOWPAN_HC1_NH_UDP: { FAR struct udp_hdr_s *udp = (FAR struct udp_hdr_s *)(bptr + IPv6_HDRLEN); @@ -435,7 +458,7 @@ int sixlowpan_uncompresshdr_hc1(FAR const struct ieee802154_data_ind_s *ind, ninfo("IPv6 len=%02x:%02x\n", ipv6->len[0], ipv6->len[1]); -#if CONFIG_NET_UDP +#ifdef CONFIG_NET_UDP /* Length field in UDP header */ if (ipv6->proto == IP_PROTO_UDP) diff --git a/net/sixlowpan/sixlowpan_input.c b/net/sixlowpan/sixlowpan_input.c index a043ffd8cd3..d9074fab276 100644 --- a/net/sixlowpan/sixlowpan_input.c +++ b/net/sixlowpan/sixlowpan_input.c @@ -98,7 +98,7 @@ #elif defined(CONFIG_NET_UDP) /* The UDP header length is always 8 bytes */ -# define UNCOMP_MAXHDR (IPv6_HDRLEN + TCP_HDRLEN) +# define UNCOMP_MAXHDR (IPv6_HDRLEN + UDP_HDRLEN) #elif defined(CONFIG_NET_ICMPv6) /* The ICMPv6 header length is a mere 4 bytes */ @@ -836,32 +836,44 @@ int sixlowpan_input(FAR struct ieee802154_driver_s *ieee, * the protocol header. */ - if (ipv6hdr->proto != IP_PROTO_TCP) + switch (ipv6hdr->proto) { - FAR struct tcp_hdr_s *tcp = TCPBUF(&ieee->i_dev); - uint16_t tcplen; +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + { + FAR struct tcp_hdr_s *tcp = TCPBUF(&ieee->i_dev); + uint16_t tcplen; - /* The TCP header length is encoded in the top 4 bits - * of the tcpoffset field (in units of 32-bit words). - */ + /* The TCP header length is encoded in the top 4 bits + * of the tcpoffset field (in units of 32-bit words). + */ - tcplen = ((uint16_t)tcp->tcpoffset >> 4) << 2; - hdrlen = IPv6_HDRLEN + tcplen; - } - else if (ipv6hdr->proto != IP_PROTO_UDP) - { - hdrlen = IPv6_HDRLEN + UDP_HDRLEN; - } - else if (ipv6hdr->proto != IP_PROTO_ICMP6) - { - hdrlen = IPv6_HDRLEN + ICMPv6_HDRLEN; - } - else - { - nwarn("WARNING: Unsupported protoype: %u\n", - ipv6hdr->proto); - ret = -EPROTO; - goto drop; + tcplen = ((uint16_t)tcp->tcpoffset >> 4) << 2; + hdrlen = IPv6_HDRLEN + tcplen; + } + break; +#endif +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + { + hdrlen = IPv6_HDRLEN + UDP_HDRLEN; + } + break; +#endif +#ifdef CONFIG_NET_ICMPv6 + case IP_PROTO_ICMP6: + { + hdrlen = IPv6_HDRLEN + ICMPv6_HDRLEN; + } + break; +#endif + default: + { + nwarn("WARNING: Unsupported protoype: %u\n", + ipv6hdr->proto); + ret = -EPROTO; + goto drop; + } } if (hdrlen < ieee->i_dev.d_len)