its queue entry is pointed to by clientPtrs. */
fe_queue_entry_t clientEntries[CLIENT_COUNT];
- fe_queue_entry_t* clientPtrs[CLIENT_COUNT];
+ fe_queue_entry_t* ONE_NOK clientPtrs[CLIENT_COUNT];
/* The loopback message is for when a collection roots calls
Send.send. Since Send passes a pointer but Receive allows
See sendTask(). */
message_t loopbackMsg;
- message_t* loopbackMsgPtr;
+ message_t* ONE_NOK loopbackMsgPtr;
command error_t Init.init() {
int i;
}
ctp_data_header_t* getHeader(message_t* m) {
- return (ctp_data_header_t*)call SubPacket.getPayload(m, NULL);
+ return (ctp_data_header_t*)call SubPacket.getPayload(m, sizeof(ctp_data_header_t));
}
/*
return call Packet.maxPayloadLength();
}
- command void* Send.getPayload[uint8_t client](message_t* msg) {
- return call Packet.getPayload(msg, NULL);
+ command void* Send.getPayload[uint8_t client](message_t* msg, uint8_t len) {
+ return call Packet.getPayload(msg, len);
}
/*
if (call SentCache.lookup(qe->msg)) {
call CollectionDebug.logEvent(NET_C_FE_DUPLICATE_CACHE_AT_SEND);
call SendQueue.dequeue();
+ if (call MessagePool.put(qe->msg) != SUCCESS)
+ call CollectionDebug.logEvent(NET_C_FE_PUT_MSGPOOL_ERR);
+ if (call QEntryPool.put(qe) != SUCCESS)
+ call CollectionDebug.logEvent(NET_C_FE_PUT_QEPOOL_ERR);
post sendTask();
return;
}
dbg("Forwarder", "%s: I'm a root, so loopback and signal receive.\n", __FUNCTION__);
loopbackMsgPtr = signal Receive.receive[collectid](loopbackMsgPtr,
- call Packet.getPayload(loopbackMsgPtr, NULL),
- call Packet.payloadLength(loopbackMsgPtr));
+ call Packet.getPayload(loopbackMsgPtr, call Packet.payloadLength(loopbackMsgPtr)),
+ call Packet.payloadLength(loopbackMsgPtr));
signal SubSend.sendDone(qe->msg, SUCCESS);
return;
}
* message in the pool, it returns the passed message and does not
* put it on the send queue.
*/
- message_t* forward(message_t* m) {
+ message_t* ONE forward(message_t* ONE m) {
if (call MessagePool.empty()) {
dbg("Route", "%s cannot forward, message pool empty.\n", __FUNCTION__);
// send a debug message to the uart
// Loop-detection code:
if (call CtpInfo.getEtx(&gradient) == SUCCESS) {
// We only check for loops if we know our own metric
- if (call CtpPacket.getEtx(m) < gradient) {
- // The incoming packet's metric (gradient) is less than our
- // own gradient. Trigger a route update and backoff.
+ if (call CtpPacket.getEtx(m) <= gradient) {
+ // If our etx metric is less than or equal to the etx value
+ // on the packet (etx of the previous hop node), then we believe
+ // we are in a loop.
+ // Trigger a route update and backoff.
call CtpInfo.triggerImmediateRouteUpdate();
startRetxmitTimer(LOOPY_WINDOW, LOOPY_OFFSET);
call CollectionDebug.logEventMsg(NET_C_FE_LOOP_DETECTED,
}
// NB: at this point, we have a resource acquistion problem.
- // Trigger an immediate route update, log the event, and drop the
+ // Log the event, and drop the
// packet on the floor.
- call CtpInfo.triggerImmediateRouteUpdate();
+
call CollectionDebug.logEvent(NET_C_FE_SEND_QUEUE_FULL);
return m;
}
*/
event message_t*
SubReceive.receive(message_t* msg, void* payload, uint8_t len) {
- uint8_t netlen;
collection_id_t collectid;
bool duplicate = FALSE;
fe_queue_entry_t* qe;
call CollectionDebug.logEventMsg(NET_C_FE_RCV_MSG,
call CollectionPacket.getSequenceNumber(msg),
call CollectionPacket.getOrigin(msg),
- call AMPacket.destination(msg));
+ thl--);
if (len > call SubSend.maxPayloadLength()) {
return msg;
}
// If I'm the root, signal receive.
else if (call RootControl.isRoot())
return signal Receive.receive[collectid](msg,
- call Packet.getPayload(msg, &netlen),
- call Packet.payloadLength(msg));
+ call Packet.getPayload(msg, call Packet.payloadLength(msg)),
+ call Packet.payloadLength(msg));
// I'm on the routing path and Intercept indicates that I
// should not forward the packet.
else if (!signal Intercept.forward[collectid](msg,
- call Packet.getPayload(msg, &netlen),
- call Packet.payloadLength(msg)))
+ call Packet.getPayload(msg, call Packet.payloadLength(msg)),
+ call Packet.payloadLength(msg)))
return msg;
else {
dbg("Route", "Forwarding packet from %hu.\n", getHeader(msg)->origin);
}
}
- command void*
- Receive.getPayload[collection_id_t id](message_t* msg, uint8_t* len) {
- return call Packet.getPayload(msg, NULL);
- }
-
- command uint8_t
- Receive.payloadLength[collection_id_t id](message_t *msg) {
- return call Packet.payloadLength(msg);
- }
-
- command void *
- Snoop.getPayload[collection_id_t id](message_t *msg, uint8_t *len) {
- return call Packet.getPayload(msg, NULL);
- }
-
- command uint8_t Snoop.payloadLength[collection_id_t id](message_t *msg) {
- return call Packet.payloadLength(msg);
- }
-
event message_t*
SubSnoop.receive(message_t* msg, void *payload, uint8_t len) {
//am_addr_t parent = call UnicastNameFreeRouting.nextHop();
// Check for the pull bit (P) [TEP123] and act accordingly. This
// check is made for all packets, not just ones addressed to us.
- if (call CtpPacket.option(msg, CTP_OPT_PULL))
+ if (call CtpPacket.option(msg, CTP_OPT_PULL)) {
call CtpInfo.triggerRouteUpdate();
+ }
call CtpInfo.setNeighborCongested(proximalSrc, call CtpPacket.option(msg, CTP_OPT_ECN));
return signal Snoop.receive[call CtpPacket.getType(msg)]
return call SubPacket.maxPayloadLength() - sizeof(ctp_data_header_t);
}
- command void* Packet.getPayload(message_t* msg, uint8_t* len) {
- uint8_t* payload = call SubPacket.getPayload(msg, len);
- if (len != NULL) {
- *len -= sizeof(ctp_data_header_t);
+ command void* Packet.getPayload(message_t* msg, uint8_t len) {
+ uint8_t* payload = call SubPacket.getPayload(msg, len + sizeof(ctp_data_header_t));
+ if (payload != NULL) {
+ payload += sizeof(ctp_data_header_t);
}
- return payload + sizeof(ctp_data_header_t);
+ return payload;
}
command am_addr_t CollectionPacket.getOrigin(message_t* msg) {return getHeader(msg)->origin;}
default event bool
Intercept.forward[collection_id_t collectid](message_t* msg, void* payload,
- uint16_t len) {
+ uint8_t len) {
return TRUE;
}