X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Flib%2Fnet%2Fblip%2FIPRoutingP.nc;h=4a5097842013dae908d164444567b5b18bc4866e;hb=152cde92b9bc426618d0ebb1c96736304ec2d85f;hp=ebec62152686945b6a6a9c17fd2add83d2bb55aa;hpb=e1526e289da030ff214b8ee978c564289a207a53;p=tinyos-2.x.git diff --git a/tos/lib/net/blip/IPRoutingP.nc b/tos/lib/net/blip/IPRoutingP.nc index ebec6215..4a509784 100644 --- a/tos/lib/net/blip/IPRoutingP.nc +++ b/tos/lib/net/blip/IPRoutingP.nc @@ -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 { @@ -85,13 +85,6 @@ module IPRoutingP { void evictNeighbor(struct neigh_entry *neigh); uint16_t getMetric(struct neigh_entry *neigh); - uint16_t adjustLQI(uint8_t val) { - uint16_t result = (80 - (val - 50)); - result = (((result * result) >> 3) * result) >> 3; // result = (result ^ 3) / 64 - dbg("Lqi", "adjustLqi in: 0x%x out: 0x%x\n", val, result); - return result; - } - void clearStats(struct neigh_entry *r) { ip_memclr((uint8_t *)r->stats, sizeof(struct epoch_stats) * N_EPOCHS); #if 0 @@ -119,6 +112,7 @@ module IPRoutingP { traffic_interval += (call Random.rand16()) % (TGEN_BASE_TIME); if (call TrafficGenTimer.isRunning()) call TrafficGenTimer.stop(); + traffic_sent = FALSE; call TrafficGenTimer.startOneShot(traffic_interval); } @@ -126,9 +120,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); @@ -158,7 +155,6 @@ module IPRoutingP { command void IPRouting.reset() { int i; - printfUART("ROUTING RESET\n"); for (i = 0; i < N_NEIGH; i++) { neigh_table[i].flags = 0; @@ -204,9 +200,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 +781,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 +806,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 +1164,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 +1179,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;