1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #15194 from miri64/gnrc_netif_raw/fix/netif-hdr

gnrc_netif_raw: add NETIF header on receive
This commit is contained in:
benpicco 2020-10-09 14:35:54 +02:00 committed by GitHub
commit 3384c327a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;