pktbuf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Martine Lenders <mlenders@inf.fu-berlin.de>
3  * 2015 Freie Universit├Ąt Berlin
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
30 #ifndef GNRC_PKTBUF_H
31 #define GNRC_PKTBUF_H
32 
33 #include <stdbool.h>
34 #include <stdlib.h>
35 #include <string.h>
36 
37 #include "cpu_conf.h"
38 #include "net/gnrc/pkt.h"
39 #include "net/gnrc/neterr.h"
40 #include "net/gnrc/nettype.h"
41 #include "utlist.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
57 #ifndef GNRC_PKTBUF_SIZE
58 #define GNRC_PKTBUF_SIZE (6144)
59 #endif /* GNRC_PKTBUF_SIZE */
60 
64 void gnrc_pktbuf_init(void);
65 
89 
121 
142 
149 void gnrc_pktbuf_hold(gnrc_pktsnip_t *pkt, unsigned int num);
150 
161 void gnrc_pktbuf_release_error(gnrc_pktsnip_t *pkt, uint32_t err);
162 
169 static inline void gnrc_pktbuf_release(gnrc_pktsnip_t *pkt)
170 {
172 }
173 
189 
206 
216 
227 
277 
278 #ifdef DEVELHELP
279 
286 void gnrc_pktbuf_stats(void);
287 #endif
288 
289 /* for testing */
290 #ifdef TEST_SUITES
291 
297 bool gnrc_pktbuf_is_empty(void);
298 
305 bool gnrc_pktbuf_is_sane(void);
306 #endif
307 
308 #ifdef __cplusplus
309 }
310 #endif
311 
312 #endif /* GNRC_PKTBUF_H */
313 
static void gnrc_pktbuf_release(gnrc_pktsnip_t *pkt)
Decreases gnrc_pktsnip_t::users of pkt atomically and removes it if it reaches 0 and reports GNRC_NET...
Definition: pktbuf.h:169
gnrc_pktsnip_t * gnrc_pktbuf_mark(gnrc_pktsnip_t *pkt, size_t size, gnrc_nettype_t type)
Marks the first size bytes in a received packet with a new packet snip that is appended to the packet...
Error reporting definitions.
General definitions for network packets and their helper functions.
void gnrc_pktbuf_stats(void)
Prints some statistics about the packet buffer to stdout.
int gnrc_pktbuf_realloc_data(gnrc_pktsnip_t *pkt, size_t size)
Reallocates gnrc_pktsnip_t::data of pkt in the packet buffer, without changing the content...
bool gnrc_pktbuf_is_sane(void)
Checks if the implementation's internal invariants still uphold.
struct gnrc_pktsnip * next
next snip in the packet
gnrc_pktsnip_t * gnrc_pktbuf_add(gnrc_pktsnip_t *next, void *data, size_t size, gnrc_nettype_t type)
Adds a new gnrc_pktsnip_t and its packet to the packet buffer.
void gnrc_pktbuf_hold(gnrc_pktsnip_t *pkt, unsigned int num)
Increases gnrc_pktsnip_t::users of pkt atomically.
#define GNRC_NETERR_SUCCESS
Error code to signalise success (no error occured) to an gnrc_neterr subscriber.
Definition: neterr.h:43
Macros for basic linked list operations.
bool gnrc_pktbuf_is_empty(void)
Checks if packet buffer is empty.
gnrc_pktsnip_t * gnrc_pktbuf_remove_snip(gnrc_pktsnip_t *pkt, gnrc_pktsnip_t *snip)
Deletes a snip from a packet and the packet buffer.
void gnrc_pktbuf_release_error(gnrc_pktsnip_t *pkt, uint32_t err)
Decreases gnrc_pktsnip_t::users of pkt atomically and removes it if it reaches 0 and reports a possib...
gnrc_nettype_t type
protocol of the packet snip
void gnrc_pktbuf_init(void)
Initializes packet buffer module.
size_t size
the length of the snip in byte
gnrc_pktsnip_t * gnrc_pktbuf_start_write(gnrc_pktsnip_t *pkt)
Must be called once before there is a write operation in a thread.
void * data
pointer to the data of the snip
Type to represent parts (either headers or payload) of a packet, called snips.
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition: nettype.h:42
gnrc_pktsnip_t * gnrc_pktbuf_duplicate_upto(gnrc_pktsnip_t *pkt, gnrc_nettype_t type)
Duplicates pktsnip chain upto (including) a snip with the given type as a continuous snip...
gnrc_pktsnip_t * gnrc_pktbuf_get_iovec(gnrc_pktsnip_t *pkt, size_t *len)
Create a IOVEC representation of the packet pointed to by pkt
stdlib.h wrapper for MSP430
gnrc_pktsnip_t * gnrc_pktbuf_replace_snip(gnrc_pktsnip_t *pkt, gnrc_pktsnip_t *old, gnrc_pktsnip_t *add)
Replace a snip from a packet and the packet buffer by another snip.
Protocol type definitions.