Loading...
Searching...
No Matches
pktq.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019-2020 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#include <assert.h>
21#include <stdbool.h>
22
23#include "net/gnrc/netif.h"
25#include "net/gnrc/pkt.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
45
51unsigned gnrc_netif_pktq_usage(void);
52
64{
65#if IS_USED(MODULE_GNRC_NETIF_PKTQ)
66 assert(netif != NULL);
67
68 gnrc_pktsnip_t *pkt = NULL;
70 &netif->send_queue.queue
71 );
72
73 if (entry != NULL) {
74 pkt = entry->pkt;
75 entry->pkt = NULL;
76 }
77 return pkt;
78#else /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
79 (void)netif;
80 return NULL;
81#endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
82}
83
98
114
125static inline bool gnrc_netif_pktq_empty(gnrc_netif_t *netif)
126{
127#if IS_USED(MODULE_GNRC_NETIF_PKTQ)
128 assert(netif != NULL);
129
130 return (netif->send_queue.queue == NULL);
131#else /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
132 (void)netif;
133 return false;
134#endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
135}
136
137#ifdef __cplusplus
138}
139#endif
140
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition assert.h:143
Definition for GNRC's network interfaces.
void gnrc_netif_pktq_sched_get(gnrc_netif_t *netif)
Schedule a dequeue notification to network interface.
static gnrc_pktsnip_t * gnrc_netif_pktq_get(gnrc_netif_t *netif)
Gets a packet from the packet send queue of a network interface.
Definition pktq.h:63
unsigned gnrc_netif_pktq_usage(void)
Returns the overall usage of the packet queue resources.
int gnrc_netif_pktq_put(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
Puts a packet into the packet send queue of a network interface.
static bool gnrc_netif_pktq_empty(gnrc_netif_t *netif)
Check if a network interface's packet send queue is empty.
Definition pktq.h:125
int gnrc_netif_pktq_push_back(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt)
Pushes a packet back to the head of the packet send queue of a network interface.
struct gnrc_pktsnip gnrc_pktsnip_t
Type to represent parts (either headers or payload) of a packet, called snips.
static gnrc_pktqueue_t * gnrc_pktqueue_remove_head(gnrc_pktqueue_t **queue)
remove the packet queue's head
Definition pktqueue.h:74
struct gnrc_pktqueue gnrc_pktqueue_t
data type for packet queue nodes
Send queue for type definitions
General definitions for network packets and their helper functions.
gnrc_pktqueue_t * queue
the actual packet queue class
Definition type.h:34
Representation of a network interface.
Definition netif.h:137
gnrc_netif_pktq_t send_queue
Packet queue for sending.
Definition netif.h:217
gnrc_pktsnip_t * pkt
pointer to the packet
Definition pktqueue.h:35