-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNFQueue.hpp
52 lines (38 loc) · 1.36 KB
/
NFQueue.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef _NFQUEUE_HPP_
#define _NFQUEUE_HPP_
#include <libnetfilter_queue/libnetfilter_queue.h>
#include "PacketHandler.hpp"
#define NFQUEUE_BUFF_SZ 4096
class NFQueue {
private:
PacketHandler &pHandler;
struct nfq_handle *nfq_hand = NULL;
struct nfq_q_handle *nfq_queue = NULL;
int _nfq_fd = -1;
int queue; /*!< Queue ID */
uint8_t buff[NFQUEUE_BUFF_SZ]; /*!< Buffer used to store packet information */
uint8_t newPayload[NFQUEUE_BUFF_SZ]; /*!< Buffer used to store manipulated payload */
static int handle_callback(struct nfq_q_handle *_queue, struct nfgenmsg *_nfmsg, struct nfq_data *_data, void *_class);
public:
/**
* @brief Construct a new NFQueue object
*
* @param _queue Queue ID we wish to connect to
* @param _pHandler
*/
NFQueue(int _queue, PacketHandler &_pHandler);
int callback(struct nfq_q_handle *_queue, struct nfgenmsg *_nfmsg, struct nfq_data *_data);
/**
* @brief Connect to the NF queue
*/
void open(void);
/**
* @brief Start reading from the NF queue and handling packets.
*/
void run(void);
/**
* @brief Release the NF queue
*/
void close(void);
};
#endif /* _NFQUEUE_HPP_ */