Skip to content

Commit

Permalink
net/ng_pkt: added function to count snips in pkt
Browse files Browse the repository at this point in the history
  • Loading branch information
haukepetersen committed Aug 10, 2015
1 parent 54fe08f commit ae83ab5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sys/include/net/ng_pkt.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014, 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
* 2015 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
Expand All @@ -16,6 +17,7 @@
* @brief General definitions for network packets
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef NG_PKT_H_
#define NG_PKT_H_
Expand Down Expand Up @@ -129,6 +131,25 @@ static inline size_t ng_pkt_len(ng_pktsnip_t *pkt)
return len;
}

/**
* @brief Count the numbers of snips in the given packet
*
* @param[in] pkt first snip in the packet
*
* @return number of snips in the given packet
*/
static inline size_t ng_pkt_count(const ng_pktsnip_t *pkt)
{
size_t count = 0;

while (pkt) {
++count;
pkt = pkt->next;
}

return count;
}

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit ae83ab5

Please sign in to comment.