From: sdhsdh Date: Tue, 15 Sep 2009 20:43:41 +0000 (+0000) Subject: - update blip source address setting to be more generic X-Git-Tag: rc_6_tinyos_2_1_1~265 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=b5f791c14df3d1a9bfebf2a49440ac118438c5fd - update blip source address setting to be more generic - change tcp TIME_WAIT timeout to be very very short --- diff --git a/support/sdk/c/blip/lib6lowpan/ip.h b/support/sdk/c/blip/lib6lowpan/ip.h index 87006255..33568712 100644 --- a/support/sdk/c/blip/lib6lowpan/ip.h +++ b/support/sdk/c/blip/lib6lowpan/ip.h @@ -301,6 +301,7 @@ struct generic_header { enum { IP_NOHEADERS = 1 << 0, IP_MCAST = 1 << 1, + IP_NOADDRESS = 1 << 2, }; struct split_ip_msg { diff --git a/support/sdk/c/blip/libtcp/tcplib.h b/support/sdk/c/blip/libtcp/tcplib.h index 40323af1..0aadf709 100644 --- a/support/sdk/c/blip/libtcp/tcplib.h +++ b/support/sdk/c/blip/libtcp/tcplib.h @@ -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, }; diff --git a/tos/lib/net/blip/ICMPResponderP.nc b/tos/lib/net/blip/ICMPResponderP.nc index c7a335c8..ce987f12 100644 --- a/tos/lib/net/blip/ICMPResponderP.nc +++ b/tos/lib/net/blip/ICMPResponderP.nc @@ -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; diff --git a/tos/lib/net/blip/IPAddressP.nc b/tos/lib/net/blip/IPAddressP.nc index 68b10cb1..0a9bda97 100644 --- a/tos/lib/net/blip/IPAddressP.nc +++ b/tos/lib/net/blip/IPAddressP.nc @@ -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() { diff --git a/tos/lib/net/blip/TcpP.nc b/tos/lib/net/blip/TcpP.nc index 02c42aff..4ade476c 100644 --- a/tos/lib/net/blip/TcpP.nc +++ b/tos/lib/net/blip/TcpP.nc @@ -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); } diff --git a/tos/lib/net/blip/UdpP.nc b/tos/lib/net/blip/UdpP.nc index fa43a549..cc800652 100644 --- a/tos/lib/net/blip/UdpP.nc +++ b/tos/lib/net/blip/UdpP.nc @@ -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) { diff --git a/tos/lib/net/blip/interfaces/IPAddress.nc b/tos/lib/net/blip/interfaces/IPAddress.nc index b681950b..d4a5c218 100644 --- a/tos/lib/net/blip/interfaces/IPAddress.nc +++ b/tos/lib/net/blip/interfaces/IPAddress.nc @@ -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();