From a3417b82b0d1477ab49c5971b8bb19f788e35b02 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 13 Dec 2016 15:32:21 +0100 Subject: [PATCH 1/3] Fix indentation in packetbuf.c --- core/net/packetbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/net/packetbuf.c b/core/net/packetbuf.c index 4869263cf..0affa0ff2 100644 --- a/core/net/packetbuf.c +++ b/core/net/packetbuf.c @@ -196,7 +196,7 @@ packetbuf_attr_clear(void) /*---------------------------------------------------------------------------*/ void packetbuf_attr_copyto(struct packetbuf_attr *attrs, - struct packetbuf_addr *addrs) + struct packetbuf_addr *addrs) { memcpy(attrs, packetbuf_attrs, sizeof(packetbuf_attrs)); memcpy(addrs, packetbuf_addrs, sizeof(packetbuf_addrs)); @@ -204,7 +204,7 @@ packetbuf_attr_copyto(struct packetbuf_attr *attrs, /*---------------------------------------------------------------------------*/ void packetbuf_attr_copyfrom(struct packetbuf_attr *attrs, - struct packetbuf_addr *addrs) + struct packetbuf_addr *addrs) { memcpy(packetbuf_attrs, attrs, sizeof(packetbuf_attrs)); memcpy(packetbuf_addrs, addrs, sizeof(packetbuf_addrs)); From c48cfb6b9ded0bc3aa65c5fc054573a25a8fe583 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 13 Dec 2016 15:32:21 +0100 Subject: [PATCH 2/3] Fix indentation in packetbuf.h --- core/net/packetbuf.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/net/packetbuf.h b/core/net/packetbuf.h index 6f5d4b740..54012218f 100644 --- a/core/net/packetbuf.h +++ b/core/net/packetbuf.h @@ -241,7 +241,7 @@ enum { PACKETBUF_ATTR_TSCH_SLOTFRAME, PACKETBUF_ATTR_TSCH_TIMESLOT, #endif /* TSCH_WITH_LINK_SELECTOR */ - + /* Scope 1 attributes: used between two neighbors only. */ #if PACKETBUF_WITH_PACKET_TYPE PACKETBUF_ATTR_PACKET_TYPE, @@ -267,7 +267,7 @@ enum { PACKETBUF_ATTR_KEY_INDEX, PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1, #endif /* LLSEC802154_USES_EXPLICIT_KEYS */ - + /* Scope 2 attributes: used between end-to-end nodes. */ #if NETSTACK_CONF_WITH_RIME PACKETBUF_ATTR_HOPS, @@ -343,9 +343,9 @@ int packetbuf_holds_broadcast(void); void packetbuf_attr_clear(void); void packetbuf_attr_copyto(struct packetbuf_attr *attrs, - struct packetbuf_addr *addrs); + struct packetbuf_addr *addrs); void packetbuf_attr_copyfrom(struct packetbuf_attr *attrs, - struct packetbuf_addr *addrs); + struct packetbuf_addr *addrs); #define PACKETBUF_ATTRIBUTES(...) { __VA_ARGS__ PACKETBUF_ATTR_LAST } #define PACKETBUF_ATTR_LAST { PACKETBUF_ATTR_NONE, 0 } From aa1f40882573b6e735cff7e3d427eec15dafc286 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 13 Dec 2016 15:32:21 +0100 Subject: [PATCH 3/3] 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