Loading...
Searching...
No Matches
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
10#pragma once
11
52
53#include <stdbool.h>
54#include <stdlib.h>
55#include <string.h>
56
57#include "compiler_hints.h"
58#include "net/gnrc/pkt.h"
59#include "net/gnrc/neterr.h"
60#include "net/gnrc/nettype.h"
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
81#ifndef CONFIG_GNRC_PKTBUF_SIZE
82#define CONFIG_GNRC_PKTBUF_SIZE (6144)
83#endif
85
89#ifndef CONFIG_GNRC_PKTBUF_CHECK_USE_AFTER_FREE
90#define CONFIG_GNRC_PKTBUF_CHECK_USE_AFTER_FREE (0)
91#endif
92
101#define GNRC_PKTBUF_CANARY (0x55)
102
107
129gnrc_pktsnip_t *gnrc_pktbuf_add(gnrc_pktsnip_t *next, const void *data, size_t size,
130 gnrc_nettype_t type);
131
166
194
201void gnrc_pktbuf_hold(gnrc_pktsnip_t *pkt, unsigned int num);
202
214
225
241
251
269
323
324#ifdef DEVELHELP
333#endif
334
335/* for testing */
336#ifdef TEST_SUITES
344
352#endif
353
354#ifdef __cplusplus
355}
356#endif
357
Common macros and compiler attributes/pragmas configuration.
#define GNRC_NETERR_SUCCESS
Error code to signalise success (no error occurred) to an gnrc_neterr subscriber.
Definition neterr.h:42
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition nettype.h:51
struct gnrc_pktsnip gnrc_pktsnip_t
Type to represent parts (either headers or payload) of a packet, called snips.
bool gnrc_pktbuf_is_sane(void)
Checks if the implementation's internal invariants still uphold.
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...
bool gnrc_pktbuf_is_empty(void)
Checks if packet buffer is empty.
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_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.
gnrc_pktsnip_t * gnrc_pktbuf_reverse_snips(gnrc_pktsnip_t *pkt)
Reverses snip order of a packet in a write-protected manner.
void gnrc_pktbuf_init(void)
Initializes packet buffer module.
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_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_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_hold(gnrc_pktsnip_t *pkt, unsigned int num)
Increases gnrc_pktsnip_t::users of pkt atomically.
int gnrc_pktbuf_merge(gnrc_pktsnip_t *pkt)
Merge pktsnip chain to single pktsnip.
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:221
void gnrc_pktbuf_stats(void)
Prints some statistics about the packet buffer to stdout.
General definitions for network packets and their helper functions.
Error reporting definitions.
Protocol type definitions.