pktq.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019-20 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef NET_GNRC_NETIF_PKTQ_H
21 #define NET_GNRC_NETIF_PKTQ_H
22 
23 #include <assert.h>
24 #include <stdbool.h>
25 
26 #include "net/gnrc/netif.h"
28 #include "net/gnrc/pkt.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
48 
54 unsigned gnrc_netif_pktq_usage(void);
55 
67 {
68 #if IS_USED(MODULE_GNRC_NETIF_PKTQ)
69  assert(netif != NULL);
70 
71  gnrc_pktsnip_t *pkt = NULL;
73  &netif->send_queue.queue
74  );
75 
76  if (entry != NULL) {
77  pkt = entry->pkt;
78  entry->pkt = NULL;
79  }
80  return pkt;
81 #else /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
82  (void)netif;
83  return NULL;
84 #endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
85 }
86 
101 
117 
128 static inline bool gnrc_netif_pktq_empty(gnrc_netif_t *netif)
129 {
130 #if IS_USED(MODULE_GNRC_NETIF_PKTQ)
131  assert(netif != NULL);
132 
133  return (netif->send_queue.queue == NULL);
134 #else /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
135  (void)netif;
136  return false;
137 #endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
138 }
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* NET_GNRC_NETIF_PKTQ_H */
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:136
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:66
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:128
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.
static gnrc_pktqueue_t * gnrc_pktqueue_remove_head(gnrc_pktqueue_t **queue)
remove the packet queue's head
Definition: pktqueue.h:78
Send queue for Network interface API type definitions
General definitions for network packets and their helper functions.
gnrc_pktqueue_t * queue
the actual packet queue class
Definition: type.h:37
Representation of a network interface.
Definition: netif.h:135
gnrc_netif_pktq_t send_queue
Packet queue for sending.
Definition: netif.h:218
data type for packet queue nodes
Definition: pktqueue.h:37
gnrc_pktsnip_t * pkt
pointer to the packet
Definition: pktqueue.h:39
Type to represent parts (either headers or payload) of a packet, called snips.
Definition: pkt.h:108