From 1b0af2a21d6f15aacb6449237e57175319c1bb0a Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Thu, 20 Oct 2011 12:37:56 +0200 Subject: [PATCH] fixed powertrace attribution for 6lowpan traffic --- core/net/sicslowpan.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core/net/sicslowpan.c b/core/net/sicslowpan.c index 820bf2052..bfaf57e0c 100644 --- a/core/net/sicslowpan.c +++ b/core/net/sicslowpan.c @@ -265,17 +265,20 @@ static struct timer reass_timer; static struct rime_sniffer *callback = NULL; void -rime_sniffer_add(struct rime_sniffer *s) { +rime_sniffer_add(struct rime_sniffer *s) +{ callback = s; } void -rime_sniffer_remove(struct rime_sniffer *s) { +rime_sniffer_remove(struct rime_sniffer *s) +{ callback = NULL; } static void -set_packet_attrs() { +set_packet_attrs() +{ int c = 0; /* set protocol in NETWORK_ID */ packetbuf_set_attr(PACKETBUF_ATTR_NETWORK_ID, UIP_IP_BUF->proto); @@ -1303,6 +1306,9 @@ packet_sent(void *ptr, int status, int transmissions) #if SICSLOWPAN_CONF_NEIGHBOR_INFO neighbor_info_packet_sent(status, transmissions); #endif /* SICSLOWPAN_CONF_NEIGHBOR_INFO */ + if(callback != NULL) { + callback->output_callback(status); + } } /*--------------------------------------------------------------------*/ /** @@ -1348,11 +1354,6 @@ output(uip_lladdr_t *localdest) /* The MAC address of the destination of the packet */ rimeaddr_t dest; - if (callback) { - set_packet_attrs(); - callback->output_callback(0); - } - /* init */ uncomp_hdr_len = 0; rime_hdr_len = 0; @@ -1364,6 +1365,12 @@ output(uip_lladdr_t *localdest) packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, SICSLOWPAN_MAX_MAC_TRANSMISSIONS); + if(callback) { + /* call the attribution when the callback comes, but set attributes + here ! */ + set_packet_attrs(); + } + #define TCP_FIN 0x01 #define TCP_ACK 0x10 #define TCP_CTL 0x3f @@ -1739,7 +1746,7 @@ input(void) #endif /* SICSLOWPAN_CONF_NEIGHBOR_INFO */ /* if callback is set then set attributes and call */ - if (callback) { + if(callback) { set_packet_attrs(); callback->input_callback(); }