]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - support/sdk/c/blip/lib6lowpan/lib6lowpanIP.c
small bug fix: thanks to Benedikt Andreas Koeppel <bkoeppel@ee.ethz.ch>
[tinyos-2.x.git] / support / sdk / c / blip / lib6lowpan / lib6lowpanIP.c
index 54a70e89e5627dc71ce25b4759ab0c08c8483392..d16f9bdd6e44a51b7a3efd22e9ffafaafa9ddccd 100644 (file)
@@ -30,7 +30,6 @@
  */
 
 uint8_t linklocal_prefix [] = {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-uint8_t multicast_prefix [] = {0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 
 struct in6_addr __my_address       = {{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65}}};
@@ -134,8 +133,10 @@ static inline int decompressShortAddress(uint8_t dispatch, uint8_t *s_addr, uint
   }
   // otherwise we either have an invalid compression, or else it's a
   // multicast address
-  ip_memcpy(dest, multicast_prefix, 8);
-  ip_memclr(dest + 8, 8);
+  // ip_memcpy(dest, multicast_prefix, 8);
+  ip_memclr(dest, 16);
+  dest[0] = 0xff;
+  dest[1] = 0x02;
   switch (*s_addr & LOWPAN_IPHC_SHORT_LONG_MASK) {
   case LOWPAN_IPHC_HC1_MCAST:
     dest[14] = (*s_addr) & ~LOWPAN_IPHC_SHORT_LONG_MASK;
@@ -483,7 +484,8 @@ uint8_t packHeaders(struct split_ip_msg *msg,
   }
 
   nxt_hdr = hdr->nxt_hdr;
-  if (hdr->nxt_hdr == IANA_UDP /* or other compressed values... */) {
+  if (hdr->nxt_hdr == IANA_UDP && /* or other compressed values... */
+      msg->headers != NULL) {
     // we will add the HCNH encoding at the end of the header
     *encoding |= LOWPAN_IPHC_NH_MASK;
   } else {
@@ -618,8 +620,10 @@ void inet_pton6(char *addr, struct in6_addr *dest) {
       cur = 0;
     }
     p++;
-    if (*p == '\0')
+    if (*p == '\0') {
+      dest->s6_addr16[block++] = hton16(cur);
       return;
+    }
     if (*(p - 1) == ':' && *p == ':') {
       break;
     }