]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - support/sdk/c/blip/driver/routing.c
- fix async warning in resource queue
[tinyos-2.x.git] / support / sdk / c / blip / driver / routing.c
index 11059e14f597a4c55d34022d434a1cd2d9f2f5ec..d2efc8e2903f3aaeddb257316102edc75a470b49 100644 (file)
@@ -40,6 +40,7 @@
 #include "netlink.h"
 
 static ieee154_saddr_t my_short_addr;
+static uint16_t current_seqno;
 extern struct in6_addr  __my_address;
 
 char proxy_dev[IFNAMSIZ], tun_dev[IFNAMSIZ];
@@ -81,6 +82,13 @@ int routing_init(struct config *c, char *tun_name) {
     fclose(fd);
   }
 
+  if ((fd = fopen("/var/run/ip-driver.seq", "r")) != NULL) {
+    if (fscanf(fd, "%hi\n", &current_seqno) != 1) {
+      current_seqno = 0;
+    }
+    fclose(fd);
+  }
+
   return (mcast_sock >= 0) ? 0 : -1;
 }
 
@@ -398,3 +406,17 @@ ieee154_saddr_t routing_get_nexthop(struct split_ip_msg *msg) {
 
   return ret;
 }
+
+uint16_t routing_get_seqno() {
+  return current_seqno;
+}
+
+uint16_t routing_incr_seqno() {
+  FILE *fd;
+  ++current_seqno;
+  if ((fd = fopen("/var/run/ip-driver.seq", "w")) != NULL) {
+    fprintf(fd, "%hi\n", current_seqno);
+    fclose(fd);
+  }
+  return current_seqno;
+}