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 NET_GNRC_PKTBUF_H
31 #define NET_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 
62 #ifndef CONFIG_GNRC_PKTBUF_SIZE
63 #define CONFIG_GNRC_PKTBUF_SIZE (6144)
64 #endif
65 
70 void gnrc_pktbuf_init(void);
71 
93 gnrc_pktsnip_t *gnrc_pktbuf_add(gnrc_pktsnip_t *next, const void *data, size_t size,
94  gnrc_nettype_t type);
95 
130 
150 int gnrc_pktbuf_realloc_data(gnrc_pktsnip_t *pkt, size_t size);
151 
158 void gnrc_pktbuf_hold(gnrc_pktsnip_t *pkt, unsigned int num);
159 
170 void gnrc_pktbuf_release_error(gnrc_pktsnip_t *pkt, uint32_t err);
171 
178 static inline void gnrc_pktbuf_release(gnrc_pktsnip_t *pkt)
179 {
181 }
182 
198 
208 
226 
280 
281 #ifdef DEVELHELP
282 
289 void gnrc_pktbuf_stats(void);
290 #endif
291 
292 /* for testing */
293 #ifdef TEST_SUITES
294 
300 bool gnrc_pktbuf_is_empty(void);
301 
308 bool gnrc_pktbuf_is_sane(void);
309 #endif
310 
311 #ifdef __cplusplus
312 }
313 #endif
314 
315 #endif /* NET_GNRC_PKTBUF_H */
316 
gnrc_pktbuf_release
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:178
gnrc_pktbuf_hold
void gnrc_pktbuf_hold(gnrc_pktsnip_t *pkt, unsigned int num)
Increases gnrc_pktsnip_t::users of pkt atomically.
gnrc_pktbuf_release_error
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...
neterr.h
Error reporting definitions.
gnrc_pktbuf_add
gnrc_pktsnip_t * gnrc_pktbuf_add(gnrc_pktsnip_t *next, const void *data, size_t size, gnrc_nettype_t type)
Adds a new gnrc_pktsnip_t and its packet to the packet buffer.
gnrc_pktbuf_is_sane
bool gnrc_pktbuf_is_sane(void)
Checks if the implementation's internal invariants still uphold.
gnrc_pktbuf_mark
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...
gnrc_pktbuf_is_empty
bool gnrc_pktbuf_is_empty(void)
Checks if packet buffer is empty.
gnrc_pktbuf_start_write
gnrc_pktsnip_t * gnrc_pktbuf_start_write(gnrc_pktsnip_t *pkt)
Must be called once before there is a write operation on a packet snip in a thread.
pkt.h
General definitions for network packets and their helper functions.
nettype.h
Protocol type definitions.
gnrc_pktbuf_merge
int gnrc_pktbuf_merge(gnrc_pktsnip_t *pkt)
Merge pktsnip chain to single pktsnip.
gnrc_pktbuf_reverse_snips
gnrc_pktsnip_t * gnrc_pktbuf_reverse_snips(gnrc_pktsnip_t *pkt)
Reverses snip order of a packet in a write-protected manner.
gnrc_pktbuf_realloc_data
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.
gnrc_nettype_t
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition: nettype.h:50
gnrc_pktbuf_stats
void gnrc_pktbuf_stats(void)
Prints some statistics about the packet buffer to stdout.
utlist.h
Macros for basic linked list operations.
gnrc_pktbuf_remove_snip
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.
GNRC_NETERR_SUCCESS
#define GNRC_NETERR_SUCCESS
Error code to signalise success (no error occurred) to an gnrc_neterr subscriber.
Definition: neterr.h:43
gnrc_pktsnip
Type to represent parts (either headers or payload) of a packet, called snips.
Definition: pkt.h:108
gnrc_pktbuf_init
void gnrc_pktbuf_init(void)
Initializes packet buffer module.