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 
60 {
61 #if IS_USED(MODULE_GNRC_NETIF_PKTQ)
62  assert(netif != NULL);
63 
64  gnrc_pktsnip_t *pkt = NULL;
66  &netif->send_queue.queue
67  );
68 
69  if (entry != NULL) {
70  pkt = entry->pkt;
71  entry->pkt = NULL;
72  }
73  return pkt;
74 #else /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
75  (void)netif;
76  return NULL;
77 #endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
78 }
79 
94 
110 
121 static inline bool gnrc_netif_pktq_empty(gnrc_netif_t *netif)
122 {
123 #if IS_USED(MODULE_GNRC_NETIF_PKTQ)
124  assert(netif != NULL);
125 
126  return (netif->send_queue.queue == NULL);
127 #else /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
128  (void)netif;
129  return false;
130 #endif /* IS_USED(MODULE_GNRC_NETIF_PKTQ) */
131 }
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif /* NET_GNRC_NETIF_PKTQ_H */
138 
gnrc_netif_pktq_put
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.
gnrc_netif_pktq_empty
static bool gnrc_netif_pktq_empty(gnrc_netif_t *netif)
Check if a network interface's packet send queue is empty.
Definition: pktq.h:121
assert
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:104
assert.h
POSIX.1-2008 compliant version of the assert macro.
gnrc_netif_pktq_get
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:59
type.h
Send queue for Network interface API type definitions
gnrc_netif_pktq_t::queue
gnrc_pktqueue_t * queue
the actual packet queue class
Definition: type.h:37
gnrc_pktqueue
data type for packet queue nodes
Definition: pktqueue.h:37
gnrc_netif_t
Representation of a network interface.
Definition: netif.h:115
pkt.h
General definitions for network packets and their helper functions.
gnrc_pktqueue_remove_head
static gnrc_pktqueue_t * gnrc_pktqueue_remove_head(gnrc_pktqueue_t **queue)
remove the packet queue's head
Definition: pktqueue.h:78
gnrc_netif_pktq_push_back
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.
netif.h
Definition for GNRC's network interfaces.
gnrc_netif_t::send_queue
gnrc_netif_pktq_t send_queue
Packet queue for sending.
Definition: netif.h:184
gnrc_pktqueue::pkt
gnrc_pktsnip_t * pkt
pointer to the packet
Definition: pktqueue.h:39
gnrc_netif_pktq_sched_get
void gnrc_netif_pktq_sched_get(gnrc_netif_t *netif)
Schedule a dequeue notification to network interface.
gnrc_pktsnip
Type to represent parts (either headers or payload) of a packet, called snips.
Definition: pkt.h:108