]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
- update blip source address setting to be more generic
authorsdhsdh <sdhsdh>
Tue, 15 Sep 2009 20:43:41 +0000 (20:43 +0000)
committersdhsdh <sdhsdh>
Tue, 15 Sep 2009 20:43:41 +0000 (20:43 +0000)
 - change tcp TIME_WAIT timeout to be very very short

support/sdk/c/blip/lib6lowpan/ip.h
support/sdk/c/blip/libtcp/tcplib.h
tos/lib/net/blip/ICMPResponderP.nc
tos/lib/net/blip/IPAddressP.nc
tos/lib/net/blip/TcpP.nc
tos/lib/net/blip/UdpP.nc
tos/lib/net/blip/interfaces/IPAddress.nc

index 870062555d9ccb5f2706dfedf6a11cd80f0b868a..335687120a596f60689fb24de9ad32e9084adc59 100644 (file)
@@ -301,6 +301,7 @@ struct generic_header {
 enum {
   IP_NOHEADERS = 1 << 0,
   IP_MCAST     = 1 << 1,
+  IP_NOADDRESS = 1 << 2,
 };
 
 struct split_ip_msg {
index 40323af14fa950d0442b9bc9653497cea33bae28..0aadf709a21bfb54f058034fcaba8c733d69c150 100644 (file)
@@ -61,7 +61,7 @@ enum {
 
 enum {
   /* how many timer tics to stay in TIME_WAIT */
-  TCPLIB_TIMEWAIT_LEN = 12,
+  TCPLIB_TIMEWAIT_LEN = 1,
   /* how many un-acked retransmissions before we give up the connection */
   TCPLIB_GIVEUP = 6,
 };
index c7a335c8bc09973790467e577ca17f9c378a8e91..ce987f12e69fc358bc278249cd230c0cb39d5af5 100644 (file)
@@ -360,12 +360,9 @@ module ICMPResponderP {
         msg.headers = NULL;
         msg.data = payload;
         msg.data_len = len;
-        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);      
+        call IPAddress.setSource(&msg.hdr);
         
         req->type = ICMP_TYPE_ECHO_REPLY;
         req->code = 0;
index 68b10cb1084b45c8a60f8b2b1730856036057103..0a9bda97af36ba6ffe40fffe94110fe23cff24ac 100644 (file)
@@ -76,6 +76,30 @@ module IPAddressP {
     return globalPrefix;
   }
 
+  command void IPAddress.setSource(struct ip6_hdr *hdr) {
+    enum { LOCAL, GLOBAL } type = GLOBAL;
+      
+    if (hdr->ip6_dst.s6_addr[0] == 0xff) {
+      // link-local multicast sent from local address
+      if ((hdr->ip6_dst.s6_addr[1] & 0x0f) <= 0x2) {
+        type = LOCAL;
+      }
+    } else if (hdr->ip6_dst.s6_addr[0] == 0xfe) {
+      // link-local destinations sent from link-local
+      if ((hdr->ip6_dst.s6_addr[1] & 0xf0) <= 0x80) {
+        type = LOCAL;
+      }
+    }
+
+    if (type == GLOBAL && call IPAddress.haveAddress()) {
+      call IPAddress.getIPAddr(&hdr->ip6_src);
+    } else {
+      call IPAddress.getLLAddr(&hdr->ip6_src);
+    }
+
+  }
+
+
 #ifndef SIM
   async event void ActiveMessageAddress.changed() {
 
index 02c42aff7f80b66eb8c3b0e9ed598dca14ddab38..4ade476c94f5a746cce999e839c3c5d471154d28 100644 (file)
@@ -60,15 +60,6 @@ module TcpP {
 #include "circ.c"
 #include "tcplib.c"
 
-  void setSrcAddr(struct split_ip_msg *msg) {
-    if (msg->hdr.ip6_dst.s6_addr16[0] == htons(0xff02) ||
-        msg->hdr.ip6_dst.s6_addr16[0] == htons(0xfe80)) {
-      call IPAddress.getLLAddr(&msg->hdr.ip6_src);
-    } else {
-      call IPAddress.getIPAddr(&msg->hdr.ip6_src);
-    }
-  }
-
   struct tcplib_sock socks[uniqueCount("TCP_CLIENT")];
 
   struct tcplib_sock *tcplib_accept(struct tcplib_sock *conn,
@@ -87,7 +78,7 @@ module TcpP {
 
   void tcplib_send_out(struct split_ip_msg *msg, struct tcp_hdr *tcph) {
     printfUART("tcp output\n");
-    setSrcAddr(msg);
+    call IPAddress.setSource(&msg->hdr);
     tcph->chksum = htons(msg_cksum(msg, IANA_TCP));
     call IP.send(msg);
   }
index fa43a549e1655631d60db89e09c25230ed0ed086..cc80065273e939699cccbd53c2cb887c0e08c5fb 100644 (file)
@@ -53,16 +53,6 @@ module UdpP {
     return SUCCESS;
   }
 
-  void setSrcAddr(struct split_ip_msg *msg) {
-    if (msg->hdr.ip6_dst.s6_addr16[7] == htons(0xff02) ||
-        msg->hdr.ip6_dst.s6_addr16[7] == htons(0xfe80)) {
-      call IPAddress.getLLAddr(&msg->hdr.ip6_src);
-    } else {
-      call IPAddress.getIPAddr(&msg->hdr.ip6_src);
-    }
-  }
-
-
   command error_t UDP.bind[uint8_t clnt](uint16_t port) {
     int i;
     port = htons(port);
@@ -157,7 +147,7 @@ module UdpP {
     ip_memclr((uint8_t *)msg, sizeof(struct split_ip_msg));
     ip_memclr((uint8_t *)udp, sizeof(struct udp_hdr));
     
-    setSrcAddr(msg);
+    call IPAddress.setSource(&msg->hdr);
     memcpy(&msg->hdr.ip6_dst, dest->sin6_addr.s6_addr, 16);
     
     if (local_ports[clnt] == 0 && (local_ports[clnt] = alloc_lport(clnt)) == 0) {
index b681950bab15b48968bb868dc7963dc27e8cced9..d4a5c2185affce1be9573fedf4230b8ae2dc9f58 100644 (file)
@@ -29,6 +29,8 @@ interface IPAddress {
   command void getLLAddr(struct in6_addr *addr);
   command void getIPAddr(struct in6_addr *addr);
 
+  command void setSource(struct ip6_hdr *hdr);
+
   command void setPrefix(uint8_t *prefix);
 
   command bool haveAddress();