From fe722e44b98818440e57433cd59d7d0bc0747778 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 8 Apr 2017 08:14:42 -0600 Subject: [PATCH] 6loWPAN: Fix a faulty assumption about relationship between some sizes and offsets. --- arch/sim/src/up_initialize.c | 2 +- net/sixlowpan/sixlowpan_framelist.c | 34 +++++------------------------ 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index fa8468196e0..5b3f1c0e9f9 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -187,7 +187,7 @@ void up_initialize(void) * separately. */ - syslog(LOG_INFO, "SIM: Initializing"); + syslog(LOG_INFO, "SIM: Initializing\n"); #endif #ifdef CONFIG_PM diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c index 552f394b786..7b36219205f 100644 --- a/net/sixlowpan/sixlowpan_framelist.c +++ b/net/sixlowpan/sixlowpan_framelist.c @@ -144,9 +144,7 @@ static void sixlowpan_compress_ipv6hdr(FAR const struct ipv6_hdr_s *ipv6hdr, static void sixlowpan_copy_protohdr(FAR const struct ipv6_hdr_s *ipv6hdr, FAR uint8_t *fptr) { - uint16_t combined; uint16_t protosize; - uint16_t copysize; /* What is the total size of the IPv6 + protocol header? */ @@ -162,7 +160,6 @@ static void sixlowpan_copy_protohdr(FAR const struct ipv6_hdr_s *ipv6hdr, */ protosize = ((uint16_t)tcp->tcpoffset >> 4) << 2; - combined = sizeof(struct ipv6_hdr_s) + protosize; } break; #endif @@ -170,48 +167,27 @@ static void sixlowpan_copy_protohdr(FAR const struct ipv6_hdr_s *ipv6hdr, #ifdef CONFIG_NET_UDP case IP_PROTO_UDP: protosize = sizeof(struct udp_hdr_s); - combined = sizeof(struct ipv6udp_hdr_s); break; #endif #ifdef CONFIG_NET_ICMPv6 case IP_PROTO_ICMP6: protosize = sizeof(struct icmpv6_hdr_s); - combined = sizeof(struct ipv6icmp_hdr_s); break; #endif default: nwarn("WARNING: Unrecognized proto: %u\n", ipv6hdr->proto); - protosize = 0; - combined = sizeof(struct ipv6_hdr_s); - break; + return; } - /* Copy the remaining protocol header. */ - - if (g_uncomp_hdrlen > IPv6_HDRLEN) - { - nwarn("WARNING: Protocol header not copied: " - "g_uncomp_hdren=%u IPv6_HDRLEN=%u\n", - g_uncomp_hdrlen, IPv6_HDRLEN); - return; - } - - copysize = combined - g_uncomp_hdrlen; - if (copysize != protosize) - { - nwarn("WARNING: Protocol header size mismatch: " - "g_uncomp_hdren=%u copysize=%u protosize=%u\n", - g_uncomp_hdrlen, copysize, protosize); - return; - } + /* Copy the protocol header. */ memcpy(fptr + g_frame_hdrlen, (FAR uint8_t *)ipv6hdr + g_uncomp_hdrlen, - copysize); + protosize); - g_frame_hdrlen += copysize; - g_uncomp_hdrlen += copysize; + g_frame_hdrlen += protosize; + g_uncomp_hdrlen += protosize; } /****************************************************************************