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

gnrc_pkt: provide type search function

This commit is contained in:
Martine Lenders 2016-02-11 00:45:25 +01:00
parent c6eb21806b
commit e8a1fab07d
5 changed files with 51 additions and 0 deletions

View File

@ -379,6 +379,7 @@ ifneq (,$(filter gnrc_pktbuf, $(USEMODULE)))
ifeq (,$(filter gnrc_pktbuf_%, $(USEMODULE)))
USEMODULE += gnrc_pktbuf_static
endif
USEMODULE += gnrc_pkt
endif
ifneq (,$(filter gnrc_pktbuf_%, $(USEMODULE)))

View File

@ -155,6 +155,18 @@ static inline size_t gnrc_pkt_count(const gnrc_pktsnip_t *pkt)
return count;
}
/**
* @brief Searches the packet for a packet snip of a specific type
*
* @param[in] pkt list of packet snips
* @param[in] type the type to search for
*
* @return the packet snip in @p pkt with @ref gnrc_nettype_t @p type
* @return NULL, if none of the snips in @p pkt is of @p type
*/
gnrc_pktsnip_t *gnrc_pktsnip_search_type(gnrc_pktsnip_t *pkt,
gnrc_nettype_t type);
#ifdef __cplusplus
}
#endif

View File

@ -73,6 +73,9 @@ endif
ifneq (,$(filter gnrc_nomac,$(USEMODULE)))
DIRS += link_layer/nomac
endif
ifneq (,$(filter gnrc_pkt,$(USEMODULE)))
DIRS += pkt
endif
ifneq (,$(filter gnrc_pktbuf_static,$(USEMODULE)))
DIRS += pktbuf_static
endif

View File

@ -0,0 +1,3 @@
MODULE := gnrc_pkt
include $(RIOTBASE)/Makefile.base

View File

@ -0,0 +1,32 @@
/*
* Copyright (C) 2016 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @{
*
* @file
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#include <assert.h>
#include "net/gnrc/pkt.h"
gnrc_pktsnip_t *gnrc_pktsnip_search_type(gnrc_pktsnip_t *ptr,
gnrc_nettype_t type)
{
while (ptr != NULL) {
if (ptr->type == type) {
return ptr;
}
ptr = ptr->next;
}
return NULL;
}
/** @} */