EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
pcap_queue.h
Go to the documentation of this file.
1 
11 #ifndef PCAP_QUEUE_H
12 #define PCAP_QUEUE_H
13 
14 #include <stdint.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <pcap.h>
18 #include <string.h>
19 
20 #include <list.h>
21 
22 #include "../../../utils/attributes.h"
23 
28 struct pcap_queue {
29  struct pcap_pkthdr header;
30  uint8_t *packet;
31  struct dl_list list;
32 };
33 
42 struct pcap_queue *push_pcap_queue(struct pcap_queue *queue,
43  struct pcap_pkthdr *header, uint8_t *packet);
44 
51 struct pcap_queue *pop_pcap_queue(struct pcap_queue *queue);
52 
58 void free_pcap_queue_el(struct pcap_queue *el);
59 
66 ssize_t get_pcap_queue_length(struct pcap_queue *queue);
67 
73 void free_pcap_queue(struct pcap_queue *queue);
74 
81 int is_pcap_queue_empty(struct pcap_queue *queue);
82 
83 #if __GNUC__ >= 11 // this syntax will throw an error in GCC 10 or Clang, since
84  // __attribute__((malloc)) accepts no args
93 #define __must_free_pcap_queue \
94  __attribute__((malloc(free_pcap_queue, 1))) __must_check
95 #else
96 #define __must_free_pcap_queue __must_check
97 #endif /* __GNUC__ >= 11 */
98 
106 
107 #endif
struct pcap_queue * push_pcap_queue(struct pcap_queue *queue, struct pcap_pkthdr *header, uint8_t *packet)
Pushes a packet in the pcap queue.
Definition: pcap_queue.c:35
__must_free_pcap_queue struct pcap_queue * init_pcap_queue(void)
Initialises an empty pcap queue.
Definition: pcap_queue.c:21
int is_pcap_queue_empty(struct pcap_queue *queue)
Checks if pcap queue is empty.
Definition: pcap_queue.c:102
void free_pcap_queue_el(struct pcap_queue *el)
Delete a pcap entry.
Definition: pcap_queue.c:81
ssize_t get_pcap_queue_length(struct pcap_queue *queue)
Returns the pcap queue length.
Definition: pcap_queue.c:98
struct pcap_queue * pop_pcap_queue(struct pcap_queue *queue)
Extract the first pcap element from the pcap queueu.
Definition: pcap_queue.c:74
void free_pcap_queue(struct pcap_queue *queue)
Frees the pcap queue.
Definition: pcap_queue.c:89
#define __must_free_pcap_queue
Definition: pcap_queue.h:96
pcap queueu structure definition
Definition: pcap_queue.h:28
struct dl_list list
Definition: pcap_queue.h:31
uint8_t * packet
Definition: pcap_queue.h:30
struct pcap_pkthdr header
Definition: pcap_queue.h:29