X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=support%2Fsdk%2Fc%2Fblip%2Fdriver%2Frouting.c;h=d2efc8e2903f3aaeddb257316102edc75a470b49;hb=e1526e289da030ff214b8ee978c564289a207a53;hp=11059e14f597a4c55d34022d434a1cd2d9f2f5ec;hpb=82bee1ef3f15d5154f09e150eef5b7c65bb973cc;p=tinyos-2.x.git diff --git a/support/sdk/c/blip/driver/routing.c b/support/sdk/c/blip/driver/routing.c index 11059e14..d2efc8e2 100644 --- a/support/sdk/c/blip/driver/routing.c +++ b/support/sdk/c/blip/driver/routing.c @@ -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", ¤t_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; +}