1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

gnrc_netif_raw: add NETIF header on receive

... to give upper layer a hint on the interface the packet came from.
This commit is contained in:
Martine Lenders 2020-10-09 11:44:49 +02:00
parent ffb7512dfc
commit 6991ad5910
No known key found for this signature in database
GPG Key ID: CCD317364F63286F

View File

@ -14,6 +14,7 @@
*/
#include "net/gnrc/pktbuf.h"
#include "net/gnrc/netif/hdr.h"
#include "net/gnrc/netif/raw.h"
#define ENABLE_DEBUG (0)
@ -54,6 +55,7 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
gnrc_pktsnip_t *pkt = NULL;
if (bytes_expected > 0) {
gnrc_pktsnip_t *hdr;
int nread;
pkt = gnrc_pktbuf_add(NULL, NULL, bytes_expected, GNRC_NETTYPE_UNDEF);
@ -70,6 +72,14 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
gnrc_pktbuf_release(pkt);
return NULL;
}
hdr = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
if (!hdr) {
DEBUG("gnrc_netif_raw: cannot allocate pktsnip.\n");
gnrc_pktbuf_release(pkt);
return NULL;
}
gnrc_netif_hdr_set_netif(hdr->data, netif);
LL_APPEND(pkt, hdr);
#ifdef MODULE_NETSTATS_L2
netif->stats.rx_count++;
netif->stats.rx_bytes += nread;