diff --git a/pkg/opendsme/contrib/opendsme.cpp b/pkg/opendsme/contrib/opendsme.cpp index a61c16215b33..99a122b7ff84 100644 --- a/pkg/opendsme/contrib/opendsme.cpp +++ b/pkg/opendsme/contrib/opendsme.cpp @@ -25,12 +25,24 @@ static bool _pan_coord; extern void heap_stats(void); static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt) { - /* TODO */ - uint8_t addr[IEEE802154_SHORT_ADDRESS_LEN]; + /* Note that there the short address is assigned by the coordinator and the + * user should not have control over it. + * Given that, and the fact the current MAC does not communicate with + * different PANs, we can always use the short address */ + uint8_t *addr; gnrc_netif_hdr_t *hdr = (gnrc_netif_hdr_t*) pkt->data; - memcpy(addr, gnrc_netif_hdr_get_dst_addr(hdr), IEEE802154_SHORT_ADDRESS_LEN); - pkt = gnrc_pktbuf_remove_snip(pkt, pkt); + if (hdr->dst_l2addr_len == IEEE802154_LONG_ADDRESS_LEN) { + addr = gnrc_netif_hdr_get_dst_addr(hdr) + + IEEE802154_LONG_ADDRESS_LEN + - IEEE802154_SHORT_ADDRESS_LEN; + } + else { + assert(hdr->dst_l2addr_len == IEEE802154_SHORT_ADDRESS_LEN); + addr = gnrc_netif_hdr_get_dst_addr(hdr); + } + uint16_t _addr = byteorder_ntohs(*((network_uint16_t*) addr)); + pkt = gnrc_pktbuf_remove_snip(pkt, pkt); m_dsme.sendFrame(_addr, (iolist_t*) pkt); return 0;