]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/net/lqi/LqiForwardingEngineP.nc
Call is needed.
[tinyos-2.x.git] / tos / lib / net / lqi / LqiForwardingEngineP.nc
index 039b5252767a364b73b62c0e967e7c4c9ea2e61e..c52e80b412467859b2155afc82445ace9d04cc04 100644 (file)
@@ -1,6 +1,5 @@
 // $Id$
 
-
 /* Copyright (c) 2007 Stanford University.
  * All rights reserved.
  *
@@ -249,6 +248,10 @@ implementation {
       if (call SubSend.send(call AMPacket.destination(msg),
                            msg,
                            call SubPacket.payloadLength(msg)) == SUCCESS) {
+       call CollectionDebug.logEventMsg(NET_C_DBG_1, 
+                                        call CollectionPacket.getSequenceNumber(msg), 
+                                        call CollectionPacket.getOrigin(msg), 
+                                        call AMPacket.destination(msg));
        dbg("LQI", "%s: Send to %hu success.\n", __FUNCTION__, call AMPacket.destination(msg));
       }
       fwdbusy = TRUE;
@@ -260,10 +263,17 @@ implementation {
     payload += sizeof(lqi_header_t);
     len -= sizeof(lqi_header_t);
 
+    call CollectionDebug.logEventMsg(NET_C_FE_RCV_MSG, 
+                                    call CollectionPacket.getSequenceNumber(msg), 
+                                    call CollectionPacket.getOrigin(msg), 
+                                    call AMPacket.destination(msg));
     if (call RootControl.isRoot()) {
       dbg("LQI,LQIDeliver", "LQI Root is receiving packet from node %hu @%s\n", getHeader(msg)->originaddr, sim_time_string());
       return signal Receive.receive[id](msg, payload, len);
     }
+    else if (call AMPacket.destination(msg) != call AMPacket.address()) {
+      return msg;
+    }
     else if (signal Intercept.forward[id](msg, payload, len)) {
       dbg("LQI,LQIDeliver", "LQI fwd is forwarding packet from node %hu @%s\n", getHeader(msg)->originaddr, sim_time_string());
       return mForward(msg);
@@ -275,7 +285,7 @@ implementation {
   
   message_t* nextMsg() {
     int i;
-    int inc = call Random.rand16();
+    uint16_t inc = call Random.rand16() & 0xfff;
     for (i = 0; i < FWD_QUEUE_SIZE; i++) {
       int pindex = (i + inc) % FWD_QUEUE_SIZE;
       if (FwdBufBusy[pindex]) {
@@ -499,6 +509,8 @@ implementation {
     lqi_header_t* hdr = getHeader(msg);
     hdr->originseqno = seqno;
   }
+
+
   
  default event void Send.sendDone(message_t* pMsg, error_t success) {}
  default event message_t* Snoop.receive[collection_id_t id](message_t* pMsg, void* payload, uint8_t len) {return pMsg;}