From 333e076b24b4492f5405f76464a2f21ba6744897 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 6 May 2015 14:34:29 +0200 Subject: [PATCH] Disable PACKETBUF_ATTR_PACKET_TYPE in the non-Rime case by default --- core/net/ipv6/sicslowpan.c | 2 ++ core/net/mac/csma.c | 6 ++++-- core/net/mac/cxmac/cxmac.c | 9 ++++++--- core/net/packetbuf.h | 8 ++++++++ dev/cc2420/cc2420.c | 2 ++ dev/cc2520/cc2520.c | 2 ++ 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/core/net/ipv6/sicslowpan.c b/core/net/ipv6/sicslowpan.c index 320b5c5ba..62b9014c5 100644 --- a/core/net/ipv6/sicslowpan.c +++ b/core/net/ipv6/sicslowpan.c @@ -1383,6 +1383,7 @@ output(const uip_lladdr_t *localdest) set_packet_attrs(); } +#if PACKETBUF_WITH_PACKET_TYPE #define TCP_FIN 0x01 #define TCP_ACK 0x10 #define TCP_CTL 0x3f @@ -1397,6 +1398,7 @@ output(const uip_lladdr_t *localdest) packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE, PACKETBUF_ATTR_PACKET_TYPE_STREAM_END); } +#endif /* * The destination address will be tagged to each outbound diff --git a/core/net/mac/csma.c b/core/net/mac/csma.c index 6ede3ec8d..ab6fec726 100644 --- a/core/net/mac/csma.c +++ b/core/net/mac/csma.c @@ -373,11 +373,13 @@ send_packet(mac_callback_t sent, void *ptr) } metadata->sent = sent; metadata->cptr = ptr; - +#if PACKETBUF_WITH_PACKET_TYPE if(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) == PACKETBUF_ATTR_PACKET_TYPE_ACK) { list_push(n->queued_packet_list, q); - } else { + } else +#endif + { list_add(n->queued_packet_list, q); } diff --git a/core/net/mac/cxmac/cxmac.c b/core/net/mac/cxmac/cxmac.c index 857c67adb..770a5c19d 100644 --- a/core/net/mac/cxmac/cxmac.c +++ b/core/net/mac/cxmac/cxmac.c @@ -473,7 +473,7 @@ send_packet(void) return MAC_TX_ERR; } -#if WITH_STREAMING +#if WITH_STREAMING && PACKETBUF_WITH_PACKET_TYPE if(is_streaming == 1 && (linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &is_streaming_to) || @@ -517,7 +517,7 @@ send_packet(void) wait = ((rtimer_clock_t)(e->time - now)) % (DEFAULT_PERIOD); expected = now + wait - 2 * DEFAULT_ON_TIME; -#if WITH_ACK_OPTIMIZATION +#if WITH_ACK_OPTIMIZATION && PACKETBUF_WITH_PACKET_TYPE /* Wait until the receiver is expected to be awake */ if(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) != PACKETBUF_ATTR_PACKET_TYPE_ACK && @@ -627,8 +627,11 @@ send_packet(void) packetbuf_attr(PACKETBUF_ATTR_RELIABLE) || packetbuf_attr(PACKETBUF_ATTR_ERELIABLE) || #endif /* NETSTACK_CONF_WITH_RIME */ +#if PACKETBUF_WITH_PACKET_TYPE packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) == - PACKETBUF_ATTR_PACKET_TYPE_STREAM)) { + PACKETBUF_ATTR_PACKET_TYPE_STREAM || +#endif + 0)) { on(); /* Wait for ACK packet */ waiting_for_packet = 1; } else { diff --git a/core/net/packetbuf.h b/core/net/packetbuf.h index d3b6600ec..3c1839bf1 100644 --- a/core/net/packetbuf.h +++ b/core/net/packetbuf.h @@ -74,6 +74,12 @@ #define PACKETBUF_HDR_SIZE 48 #endif +#ifdef PACKETBUF_CONF_WITH_PACKET_TYPE +#define PACKETBUF_WITH_PACKET_TYPE PACKETBUF_CONF_WITH_PACKET_TYPE +#else +#define PACKETBUF_WITH_PACKET_TYPE NETSTACK_CONF_WITH_RIME +#endif + /** * \brief Clear and reset the packetbuf * @@ -309,7 +315,9 @@ enum { PACKETBUF_ATTR_IS_CREATED_AND_SECURED, /* Scope 1 attributes: used between two neighbors only. */ +#if PACKETBUF_WITH_PACKET_TYPE PACKETBUF_ATTR_PACKET_TYPE, +#endif #if NETSTACK_CONF_WITH_RIME PACKETBUF_ATTR_PACKET_ID, PACKETBUF_ATTR_RELIABLE, diff --git a/dev/cc2420/cc2420.c b/dev/cc2420/cc2420.c index 970f9dca7..d455e02df 100644 --- a/dev/cc2420/cc2420.c +++ b/dev/cc2420/cc2420.c @@ -658,11 +658,13 @@ cc2420_transmit(unsigned short payload_len) { rtimer_clock_t sfd_timestamp; sfd_timestamp = cc2420_sfd_start_time; +#if PACKETBUF_WITH_PACKET_TYPE if(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) == PACKETBUF_ATTR_PACKET_TYPE_TIMESTAMP) { /* Write timestamp to last two bytes of packet in TXFIFO. */ write_ram((uint8_t *) &sfd_timestamp, CC2420RAM_TXFIFO + payload_len - 1, 2, WRITE_RAM_IN_ORDER); } +#endif } if(!(get_status() & BV(CC2420_TX_ACTIVE))) { diff --git a/dev/cc2520/cc2520.c b/dev/cc2520/cc2520.c index 249bc6ad6..b6c0e43fa 100644 --- a/dev/cc2520/cc2520.c +++ b/dev/cc2520/cc2520.c @@ -438,11 +438,13 @@ cc2520_transmit(unsigned short payload_len) { rtimer_clock_t sfd_timestamp; sfd_timestamp = cc2520_sfd_start_time; +#if PACKETBUF_WITH_PACKET_TYPE if(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) == PACKETBUF_ATTR_PACKET_TYPE_TIMESTAMP) { /* Write timestamp to last two bytes of packet in TXFIFO. */ CC2520_WRITE_RAM(&sfd_timestamp, CC2520RAM_TXFIFO + payload_len - 1, 2); } +#endif } if(!(status() & BV(CC2520_TX_ACTIVE))) {