From aa1f40882573b6e735cff7e3d427eec15dafc286 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 13 Dec 2016 15:32:21 +0100 Subject: [PATCH] packetbuf: add packetbuf_remaininglen() packetbuf_freelen() returns the length of free space in packetbuf. --- core/net/packetbuf.c | 6 ++++++ core/net/packetbuf.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/core/net/packetbuf.c b/core/net/packetbuf.c index 0affa0ff2..915dfd8fa 100644 --- a/core/net/packetbuf.c +++ b/core/net/packetbuf.c @@ -184,6 +184,12 @@ packetbuf_totlen(void) return packetbuf_hdrlen() + packetbuf_datalen(); } /*---------------------------------------------------------------------------*/ +uint16_t +packetbuf_remaininglen(void) +{ + return PACKETBUF_SIZE - packetbuf_totlen(); +} +/*---------------------------------------------------------------------------*/ void packetbuf_attr_clear(void) { diff --git a/core/net/packetbuf.h b/core/net/packetbuf.h index 54012218f..bf96ed718 100644 --- a/core/net/packetbuf.h +++ b/core/net/packetbuf.h @@ -123,6 +123,13 @@ uint16_t packetbuf_datalen(void); */ uint16_t packetbuf_totlen(void); +/** + * \brief Get the total length of the remaining space in the packetbuf + * \return Length of the remaining space in the packetbuf + * + */ +uint16_t packetbuf_remaininglen(void); + /** * \brief Set the length of the data in the packetbuf * \param len The length of the data