mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
drivers/cc1xxx_common: L2 netstats & cleanups
- Added required logic to provide correct L2 netstats when the module netstats_l2 is used. - Refactored code to use gnrc_netif_hdr_set_netif() over manually setting the pid to ease future refactoring.
This commit is contained in:
parent
137c2c0adf
commit
ccf713c5ad
@ -86,7 +86,7 @@ static gnrc_pktsnip_t *cc1xxx_adpt_recv(gnrc_netif_t *netif)
|
||||
return NULL;
|
||||
}
|
||||
netif_hdr = (gnrc_netif_hdr_t *)hdr->data;
|
||||
netif_hdr->if_pid = netif->pid;
|
||||
gnrc_netif_hdr_set_netif(netif_hdr, netif);
|
||||
netif_hdr->rssi = rx_info.rssi;
|
||||
netif_hdr->lqi = rx_info.lqi;
|
||||
if (l2hdr.dest_addr == CC1XXX_BCAST_ADDR) {
|
||||
@ -98,6 +98,11 @@ static gnrc_pktsnip_t *cc1xxx_adpt_recv(gnrc_netif_t *netif)
|
||||
/* and append the netif header */
|
||||
LL_APPEND(payload, hdr);
|
||||
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netif->stats.rx_count++;
|
||||
netif->stats.rx_bytes += pktlen;
|
||||
#endif
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
@ -122,6 +127,9 @@ static int cc1xxx_adpt_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
||||
if (netif_hdr->flags & BCAST) {
|
||||
l2hdr.dest_addr = CC1XXX_BCAST_ADDR;
|
||||
DEBUG("[cc1xxx-gnrc] send: preparing to send broadcast\n");
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netif->stats.tx_mcast_count++;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* check that destination address is valid */
|
||||
@ -130,6 +138,9 @@ static int cc1xxx_adpt_send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
|
||||
l2hdr.dest_addr = addr[0];
|
||||
DEBUG("[cc1xxx-gnrc] send: preparing to send unicast %02x --> %02x\n",
|
||||
(int)l2hdr.src_addr, (int)l2hdr.dest_addr);
|
||||
#ifdef MODULE_NETSTATS_L2
|
||||
netif->stats.tx_unicast_count++;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* now let's send out the stuff */
|
||||
|
Loading…
Reference in New Issue
Block a user