From 586fb9a7feb7ef843c28cdfa57ad477d88438c45 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Wed, 14 Dec 2016 14:00:14 +0100 Subject: [PATCH 1/3] framer-802154: bugfix on source address setting --- core/net/mac/framer-802154.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/net/mac/framer-802154.c b/core/net/mac/framer-802154.c index 35e39cf33..86f550fd1 100644 --- a/core/net/mac/framer-802154.c +++ b/core/net/mac/framer-802154.c @@ -173,7 +173,8 @@ create_frame(int type, int do_create) * Set up the source address using only the long address mode for * phase 1. */ - linkaddr_copy((linkaddr_t *)¶ms.src_addr, &linkaddr_node_addr); + linkaddr_copy((linkaddr_t *)¶ms.src_addr, + packetbuf_addr(PACKETBUF_ADDR_SENDER)); params.payload = packetbuf_dataptr(); params.payload_len = packetbuf_datalen(); From da29a5f8e38bdaf279938d4cf7c9e691a2b0558d Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 13 Dec 2016 15:32:21 +0100 Subject: [PATCH 2/3] ContikiMAC: set PACKET_ADDR_SENDER in qsend_list() --- core/net/mac/contikimac/contikimac.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/net/mac/contikimac/contikimac.c b/core/net/mac/contikimac/contikimac.c index 229cfb473..7088e8e54 100644 --- a/core/net/mac/contikimac/contikimac.c +++ b/core/net/mac/contikimac/contikimac.c @@ -873,6 +873,10 @@ qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list) if(next != NULL) { packetbuf_set_attr(PACKETBUF_ATTR_PENDING, 1); } +#if !NETSTACK_CONF_BRIDGE_MODE + /* If NETSTACK_CONF_BRIDGE_MODE is set, assume PACKETBUF_ADDR_SENDER is already set. */ + packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr); +#endif packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1); if(NETSTACK_FRAMER.create() < 0) { PRINTF("contikimac: framer failed\n"); From 5186fa2ef17fd8f0bfbcad4cb65399b8558f66bd Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 13 Dec 2016 15:32:21 +0100 Subject: [PATCH 3/3] TSCH: set PACKETBUF_ADDR_SENDER before NETSTACK_framer.create() --- core/net/mac/tsch/tsch.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/net/mac/tsch/tsch.c b/core/net/mac/tsch/tsch.c index a31d4a1ae..348406dac 100644 --- a/core/net/mac/tsch/tsch.c +++ b/core/net/mac/tsch/tsch.c @@ -910,6 +910,15 @@ send_packet(mac_callback_t sent, void *ptr) packet_count_before = tsch_queue_packet_count(addr); +#if !NETSTACK_CONF_BRIDGE_MODE + /* + * In the Contiki stack, the source address of a frame is set at the RDC + * layer. Since TSCH doesn't use any RDC protocol and bypasses the layer to + * transmit a frame, it should set the source address by itself. + */ + packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr); +#endif + if((hdr_len = NETSTACK_FRAMER.create()) < 0) { PRINTF("TSCH:! can't send packet due to framer error\n"); ret = MAC_TX_ERR;