From 3e44e8b258b72936e671d551d3c378e73b31ce9a Mon Sep 17 00:00:00 2001 From: kkrentz Date: Mon, 4 Aug 2014 04:34:49 -0700 Subject: [PATCH] packetbuf: Added function "packetbuf_holds_broadcast()" for checking whether the current packet is a broadcast --- core/net/packetbuf.c | 7 +++++++ core/net/packetbuf.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/core/net/packetbuf.c b/core/net/packetbuf.c index e67c8cf12..43994f61e 100644 --- a/core/net/packetbuf.c +++ b/core/net/packetbuf.c @@ -320,4 +320,11 @@ packetbuf_addr(uint8_t type) } /*---------------------------------------------------------------------------*/ #endif /* PACKETBUF_CONF_ATTRS_INLINE */ +int +packetbuf_holds_broadcast(void) +{ + return linkaddr_cmp(&packetbuf_addrs[PACKETBUF_ADDR_RECEIVER - PACKETBUF_ADDR_FIRST].addr, &linkaddr_null); +} +/*---------------------------------------------------------------------------*/ + /** @} */ diff --git a/core/net/packetbuf.h b/core/net/packetbuf.h index 2bfffd2dd..86e44bb16 100644 --- a/core/net/packetbuf.h +++ b/core/net/packetbuf.h @@ -453,6 +453,12 @@ int packetbuf_set_addr(uint8_t type, const linkaddr_t *addr); const linkaddr_t *packetbuf_addr(uint8_t type); #endif /* PACKETBUF_CONF_ATTRS_INLINE */ +/** + * \brief Checks whether the current packet is a broadcast. + * \retval 0 iff current packet is not a broadcast + */ +int packetbuf_holds_broadcast(void); + void packetbuf_attr_clear(void); void packetbuf_attr_copyto(struct packetbuf_attr *attrs,