@@ -29,10 +29,9 @@ static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
2929 uint8_t bcast[2 ] = { 0xFF , 0xFF };
3030 uint8_t *addr;
3131
32- pkt = gnrc_pktbuf_start_write (pkt);
3332 gnrc_netif_hdr_t *hdr = (gnrc_netif_hdr_t *)pkt->data ;
3433
35- if (hdr->flags &= GNRC_NETIF_HDR_FLAGS_MULTICAST ) {
34+ if (hdr->flags & GNRC_NETIF_HDR_FLAGS_MULTICAST ) {
3635 addr = static_cast <uint8_t *>(&bcast[0 ]);
3736 }
3837 else if (hdr->dst_l2addr_len == IEEE802154_LONG_ADDRESS_LEN ) {
@@ -44,16 +43,30 @@ static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
4443 addr = gnrc_netif_hdr_get_dst_addr (hdr);
4544 }
4645 else {
47- gnrc_pktbuf_release (pkt);
4846 return -EBADMSG ;
4947 }
5048
5149 uint16_t _addr = byteorder_ntohs (*((network_uint16_t *)addr));
50+ gnrc_pktsnip_t *payload = pkt->next ;
5251
53- pkt = gnrc_pktbuf_remove_snip (pkt, pkt);
54- m_dsme.sendFrame (_addr, (iolist_t *)pkt);
52+ if (!m_dsme.isAssociated ()) {
53+ return -ENOTCONN ;
54+ }
55+ if (payload == NULL ) {
56+ return -ENODATA ;
57+ }
5558
56- return 0 ;
59+ int len = (int )gnrc_pkt_len (payload);
60+
61+ /* openDSME releases its own reference to the payload once the MAC confirmed the frame.
62+ * There is no confirm_send() as there is no netdev for opendsme towards gnrc_netif,
63+ * so report the frame as handed over right away.
64+ * (Kind of ugly hack)
65+ */
66+ gnrc_pktbuf_hold (payload, 1 );
67+ m_dsme.sendFrame (_addr, (iolist_t *)payload);
68+
69+ return (len > 0 ) ? len : 1 ;
5770}
5871
5972static gnrc_pktsnip_t *_recv (gnrc_netif_t *netif)
0 commit comments