]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
- fix last nits needed to compile
authorsdhsdh <sdhsdh>
Fri, 11 Sep 2009 21:44:25 +0000 (21:44 +0000)
committersdhsdh <sdhsdh>
Fri, 11 Sep 2009 21:44:25 +0000 (21:44 +0000)
 - a few bug-fixes

apps/UDPEcho/UDPEchoC.nc
support/make/blip.extra
support/sdk/c/blip/lib6lowpan/6lowpan.h
support/sdk/c/blip/lib6lowpan/ip.h
support/sdk/c/blip/lib6lowpan/lib6lowpanIP.c
tos/lib/net/blip/ICMPResponderP.nc
tos/lib/net/blip/IPRoutingP.nc

index 984f55d9ad34742ca669cfe76adb04e52645d286..8cc47ab93a7d9e436a0772db849d35956c6c1ff3 100644 (file)
@@ -21,7 +21,9 @@
  */
 
 #include <6lowpan.h>
+#ifdef DBG_TRACK_FLOWS
 #include "TestDriver.h"
+#endif
 
 configuration UDPEchoC {
 
index 06c0c7f683b0dfa01e9b12890a54691c9653b0df..ae486254982d9255a5ea03ac455970a135cee8ce 100644 (file)
@@ -10,7 +10,8 @@ endif
 
 PFLAGS+=-DENABLE_SPI0_DMA
 
-PFLAGS+=-I$(LOWPAN_ROOT)/support/sdk/c/blip/include/
+PFLAGS+=-I$(TOSROOT)/tos/lib/net/
+PFLAGS+=-I$(LOWPAN_ROOT)/support/sdk/c/blip/lib6lowpan/
 PFLAGS+=-I$(LOWPAN_ROOT)/support/sdk/c/blip/libtcp/
 PFLAGS+=-I$(LOWPAN_ROOT)/tos/lib/net/blip/
 PFLAGS+=-I$(LOWPAN_ROOT)/tos/lib/net/blip/interfaces/ 
index 81056fe040ea8f1684287c9b359502bcad4ca79e..c93d6cf39d6b8669e5ad342ee2046f599d58b152 100644 (file)
@@ -38,6 +38,7 @@
 typedef uint8_t ip6_addr_t [16];
 typedef uint16_t cmpr_ip6_addr_t;
 #ifdef PC
+#include "../config.h"
 typedef uint16_t ieee154_saddr_t;
 typedef uint16_t hw_pan_t;
 enum {
@@ -189,7 +190,11 @@ enum {
 };
 
 #ifndef BLIP_L2_RETRIES
-#define BLIP_L2_RETRIES 10
+#define BLIP_L2_RETRIES 5
+#endif
+
+#ifndef BLIP_L2_DELAY
+#define BLIP_L2_DELAY 15
 #endif
 
 #endif
index 666cc1f26ba12826b23f71d5e984c0acc96ac3ca..870062555d9ccb5f2706dfedf6a11cd80f0b868a 100644 (file)
@@ -152,6 +152,7 @@ enum {
   // option message.
   TLV_TYPE_INSTALL  = 0x0b,
   TLV_TYPE_FLOW     = 0x0c,
+  TLV_TYPE_MCASTSEQ = 0x0d,
 };
 
 struct ip6_route {
@@ -298,7 +299,8 @@ struct generic_header {
 };
 
 enum {
-  IP_NOHEADERS = 1,
+  IP_NOHEADERS = 1 << 0,
+  IP_MCAST     = 1 << 1,
 };
 
 struct split_ip_msg {
index 54a70e89e5627dc71ce25b4759ab0c08c8483392..2cf73577b8bcb7d42518e1574376d2dadcc33eee 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 {
index 5f2f0187e9c9e481284f52c01bf4e84b612dbf09..3975c1b46cee1b9d8ab2bf43bbf4700d7cb2bdfd 100644 (file)
@@ -58,10 +58,9 @@ module ICMPResponderP {
   uint16_t ping_seq, ping_n, ping_rcv, ping_ident;
   struct in6_addr ping_dest;
 
-#ifndef SIM
-#define CHECK_NODE_ID
-#else
-#define CHECK_NODE_ID if (TOS_NODE_ID == BASESTATION_ID) return
+#ifdef PRINTFUART_ENABLED
+#undef dbg
+#define dbg(X, fmt, args ...) printfUART(fmt, ## args)
 #endif
 
   command uint16_t ICMP.cksum(struct split_ip_msg *msg, uint8_t nxt_hdr) {
@@ -71,7 +70,6 @@ module ICMPResponderP {
 
   command void ICMP.sendSolicitations() {
     uint16_t jitter = (call Random.rand16()) % TRICKLE_JITTER;
-    CHECK_NODE_ID;
     if (call Solicitation.isRunning()) return;
     solicitation_period = TRICKLE_PERIOD;
     call Solicitation.startOneShot(jitter);
@@ -81,7 +79,6 @@ module ICMPResponderP {
 
 
     uint16_t jitter = (call Random.rand16()) % TRICKLE_JITTER;
-    CHECK_NODE_ID;
     if (call Advertisement.isRunning()) return;
     advertisement_period = TRICKLE_PERIOD;
     call Advertisement.startOneShot(jitter);
@@ -156,8 +153,7 @@ module ICMPResponderP {
 
     if (ipmsg == NULL) return;
 
-    dbg("ICMPResponder", "Solicitation\n");
-    //BLIP_STATS_INCR(stats.sol_tx);
+    BLIP_STATS_INCR(stats.sol_tx);
 
     msg->type = ICMP_TYPE_ROUTER_SOL;
     msg->code = 0;
@@ -244,7 +240,7 @@ module ICMPResponderP {
       }
 
 
-      dbg("ICMPResponder", " * beacon cost: 0x%x\n", cost);
+      dbg("ICMPResponder", " * beacon cost: 0x%x\n", beacon->metric);
     } else {
         dbg("ICMPResponder", " * no beacon cost\n");
     }
@@ -269,6 +265,7 @@ module ICMPResponderP {
       ip_free(ipmsg);
       return;
     }
+    BLIP_STATS_INCR(stats.adv_tx);
 
     r->type = ICMP_TYPE_ROUTER_ADV;
     r->code = 0;
@@ -332,14 +329,15 @@ module ICMPResponderP {
 
     switch (req->type) {
     case ICMP_TYPE_ROUTER_ADV:
-        handleRouterAdv(payload, len, meta);
-        //BLIP_STATS_INCR(stats.adv_rx);
-        break;
+      handleRouterAdv(payload, len, meta);
+      BLIP_STATS_INCR(stats.adv_rx);
+      break;
     case ICMP_TYPE_ROUTER_SOL:
       // only reply to solicitations if we have established a default route.
       if (call IPRouting.hasRoute()) {
           call ICMP.sendAdvertisements();
       }
+      BLIP_STATS_INCR(stats.sol_rx);
       break;
     case ICMP_TYPE_ECHO_REPLY:
       {
@@ -350,6 +348,7 @@ module ICMPResponderP {
         p_stat.rtt = (call LocalTime.get()) - (*sendTime);
         signal ICMPPing.pingReply[req->ident](&iph->ip6_src, &p_stat);
         ping_rcv++;
+        BLIP_STATS_INCR(stats.echo_rx);
       }
       break;
     case ICMP_TYPE_ECHO_REQUEST:
@@ -359,7 +358,11 @@ module ICMPResponderP {
         msg.headers = NULL;
         msg.data = payload;
         msg.data_len = len;
-        call IPAddress.getIPAddr(&msg.hdr.ip6_src);
+        if (iph->ip6_src.s6_addr[0] == 0xfe) {
+          call IPAddress.getLLAddr(&msg.hdr.ip6_src);
+        } else {
+          call IPAddress.getIPAddr(&msg.hdr.ip6_src);
+        }
         memcpy(&msg.hdr.ip6_dst, &iph->ip6_src, 16);      
         
         req->type = ICMP_TYPE_ECHO_REPLY;
@@ -369,15 +372,18 @@ module ICMPResponderP {
         
         // remember, this can't really fail in a way we care about
         call IP.send(&msg);
+        BLIP_STATS_INCR(stats.echo_tx);
         break;
       }
+    default:
+      BLIP_STATS_INCR(stats.unk_rx);
     }
   }
 
 
   event void Solicitation.fired() {
     sendSolicitation();
-    dbg("ICMPResponder", "solicitation period: 0x%x max: 0x%x\n", solicitation_period, TRICKLE_MAX);
+    dbg("ICMPResponder", "solicitation period: 0x%x max: 0x%x seq: %i\n", solicitation_period, TRICKLE_MAX, nd_seqno);
     solicitation_period <<= 1;
     if (solicitation_period < TRICKLE_MAX) {
       call Solicitation.startOneShot(solicitation_period);
@@ -423,7 +429,7 @@ module ICMPResponderP {
 
 
   command void Statistics.get(icmp_statistics_t *statistics) {
-    statistics = &stats;
+    memcpy(statistics, &stats, sizeof(icmp_statistics_t));
   }
   
   command void Statistics.clear() {
index a348d7f0ea20946350d06d57c8d511a11b0c0d42..10ed1b0f23ca9bd1dc3e4bfd88e35713012be76e 100644 (file)
@@ -44,8 +44,8 @@ module IPRoutingP {
 } implementation {
 
 #ifdef PRINTFUART_ENABLED
-/* #undef dbg */
-/* #define dbg(X, fmt, args...)  printfUART(fmt, ## args) */
+// #undef dbg
+// #define dbg(X, fmt, args...)  printfUART(fmt, ## args)
 #endif
 
   enum {
@@ -127,9 +127,12 @@ module IPRoutingP {
   event void TrafficGenTimer.fired() {
     struct split_ip_msg *msg;
     if (traffic_sent) goto done;
-    traffic_sent = FALSE;
     msg = (struct split_ip_msg *)ip_malloc(sizeof(struct split_ip_msg));
-    if (msg == NULL) goto done;
+    if (msg == NULL) {
+      printfUART("malloc fail\n");
+      goto done;
+    }
+    traffic_sent = FALSE;
 
     ip_memclr((uint8_t *)&msg->hdr, sizeof(struct ip6_hdr));
     inet_pton6("ff05::1", &msg->hdr.ip6_dst);
@@ -204,9 +207,11 @@ module IPRoutingP {
     // me.
     struct in6_addr *my_address = call IPAddress.getPublicAddr();
     return (((cmpPfx(my_address->s6_addr, hdr->ip6_dst.s6_addr) || 
-              cmpPfx(linklocal_prefix, hdr->ip6_dst.s6_addr)) 
-             && cmpPfx(&my_address->s6_addr[8], &hdr->ip6_dst.s6_addr[8])) 
-            || cmpPfx(multicast_prefix, hdr->ip6_dst.s6_addr));
+              cmpPfx(linklocal_prefix, hdr->ip6_dst.s6_addr)) &&
+             cmpPfx(&my_address->s6_addr[8], &hdr->ip6_dst.s6_addr[8])) ||
+            (hdr->ip6_dst.s6_addr[0] == 0xff && 
+             (hdr->ip6_dst.s6_addr[1] & 0x0f) <= 3))
+;
   }
 
 #ifdef CENTRALIZED_ROUTING
@@ -783,8 +788,8 @@ module IPRoutingP {
     struct flow_entry *r = getFlowEntry_Header(hdr);
 #endif
     prev_hop = 0;
-    ret->retries = N_RETRIES;;
-    ret->delay = 30;
+    ret->retries = BLIP_L2_RETRIES;
+    ret->delay = (BLIP_L2_DELAY % (call Random.rand16())) + BLIP_L2_DELAY;
     ret->current = 0;
     ret->nchoices = 0;
  
@@ -808,7 +813,8 @@ module IPRoutingP {
       ret->dest[0] = ntohs(sh->hops[ROUTE_NENTRIES(sh) - sh->segs_remain]);
       ret->nchoices = 1;
 
-    } else if (hdr->ip6_dst.s6_addr16[0] == htons(0xff02)) {
+    } else if (hdr->ip6_dst.s6_addr[0] == 0xff &&
+               (hdr->ip6_dst.s6_addr[1] & 0xf) <= 0x03) {
       //hdr->dst_addr[0] == 0xff && (hdr->dst_addr[1] & 0xf) == 0x2) {
       // if it's multicast, for now, we send it to the local broadcast
       ret->dest[0] = 0xffff;
@@ -1165,6 +1171,11 @@ module IPRoutingP {
     tlv->len = sizeof(struct tlv_hdr) + sizeof(struct topology_header);
     tlv->type = TLV_TYPE_TOPOLOGY;
 
+    if (iph->ip6_dst.s6_addr[0] == 0xff &&
+        (iph->ip6_dst.s6_addr[1] & 0xf) <= 3) {
+      return NULL;
+    }
+
     printfUART("inserting destination options header\n");
 
     // AT: We theoretically only want to attach this topology header if we're
@@ -1175,7 +1186,8 @@ module IPRoutingP {
     // only attach the topology information if we are.  This still isn't
     // perfect since somebody further down the tree may have a route and the
     // packet might not get to the controller.
-    if (iph->nxt_hdr == IANA_UDP || iph->nxt_hdr == IPV6_NONEXT) {
+    if (iph->nxt_hdr == IANA_UDP || 
+        iph->nxt_hdr == IPV6_NONEXT) {
       int i,j = 0;
       if (iph->ip6_dst.s6_addr16[0] == htons(0xff02)) return NULL;
       if (traffic_sent) return NULL;