From a5a9b424579243f6dbefe849ab2a5a516a676fff Mon Sep 17 00:00:00 2001 From: kkrentz Date: Sun, 16 Mar 2014 08:53:34 -0700 Subject: [PATCH] packetbuf: Made packetbuf_hdrlen applicable to inbound packets, too --- core/net/packetbuf.c | 11 ++++++++++- core/net/packetbuf.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/net/packetbuf.c b/core/net/packetbuf.c index 94e8a4966..2248936d6 100644 --- a/core/net/packetbuf.c +++ b/core/net/packetbuf.c @@ -244,7 +244,16 @@ packetbuf_datalen(void) uint8_t packetbuf_hdrlen(void) { - return PACKETBUF_HDR_SIZE - hdrptr; + uint8_t hdrlen; + + hdrlen = PACKETBUF_HDR_SIZE - hdrptr; + if(hdrlen) { + /* outbound packet */ + return hdrlen; + } else { + /* inbound packet */ + return bufptr; + } } /*---------------------------------------------------------------------------*/ uint16_t diff --git a/core/net/packetbuf.h b/core/net/packetbuf.h index ab84da8fe..c3efcb731 100644 --- a/core/net/packetbuf.h +++ b/core/net/packetbuf.h @@ -132,7 +132,7 @@ void *packetbuf_dataptr(void); void *packetbuf_hdrptr(void); /** - * \brief Get the length of the header in the packetbuf, for outbound packets + * \brief Get the length of the header in the packetbuf * \return Length of the header in the packetbuf * * For outbound packets, the packetbuf consists of two