suricata
source-nfq.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2010 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Victor Julien <victor@inliniac.net>
22 */
23
24#ifndef SURICATA_SOURCE_NFQ_H
25#define SURICATA_SOURCE_NFQ_H
26
27#ifdef NFQ
28
29#include "threads.h"
30#include <linux/netfilter.h> /* for NF_ACCEPT */
31#include <libnetfilter_queue/libnetfilter_queue.h>
32
33// Netfilter's limit
34#define NFQ_MAX_QUEUE 65535
35
36/* idea: set the recv-thread id in the packet to
37 * select an verdict-queue */
38
39typedef struct NFQPacketVars_
40{
41 int id; /* this nfq packets id */
42 uint16_t nfq_index; /* index in NFQ array */
45
46 uint32_t mark;
47 uint32_t ifi;
48 uint32_t ifo;
49 uint16_t hw_protocol;
51
52typedef struct NFQQueueVars_
53{
54 struct nfq_handle *h;
55 struct nfnl_handle *nh;
56 int fd;
57 uint8_t use_mutex;
58 /* 2 threads deal with the queue handle, so add a mutex */
59 struct nfq_q_handle *qh;
61 /* this one should be not changing after init */
62 uint16_t queue_num;
63 /* position into the NFQ queue var array */
64 uint16_t nfq_index;
65
66#ifdef DBG_PERF
67 int dbg_maxreadsize;
68#endif /* DBG_PERF */
69
70 /* counters */
71 uint32_t pkts;
72 uint64_t bytes;
73 uint32_t errs;
74 uint32_t accepted;
75 uint32_t dropped;
76 uint32_t replaced;
77 struct {
78 uint32_t packet_id; /* id of last processed packet */
79 uint32_t verdict;
80 uint32_t mark;
81 uint8_t mark_valid:1;
82 uint8_t len;
83 uint8_t maxlen;
85
87
88typedef struct NFQGlobalVars_
89{
90 char unbind;
92
93void NFQInitConfig(bool quiet);
94int NFQRegisterQueue(const uint16_t number);
95int NFQParseAndRegisterQueues(const char *queues);
96void *NFQGetQueue(int number);
97void *NFQGetThread(int number);
98void NFQContextsClean(void);
99#endif /* NFQ */
100#endif /* SURICATA_SOURCE_NFQ_H */
void NFQContextsClean(void)
Clean global contexts. Must be called on exit.
struct NFQQueueVars_ NFQQueueVars
void NFQInitConfig(bool quiet)
To initialize the NFQ global configuration data.
Definition source-nfq.c:208
void * NFQGetQueue(int number)
Get a pointer to the NFQ queue at index.
Definition source-nfq.c:946
int NFQParseAndRegisterQueues(const char *queues)
Parses and adds Netfilter queue(s).
Definition source-nfq.c:881
struct NFQGlobalVars_ NFQGlobalVars
int NFQRegisterQueue(const uint16_t number)
Add a single Netfilter queue.
Definition source-nfq.c:825
struct NFQPacketVars_ NFQPacketVars
void * NFQGetThread(int number)
Get a pointer to the NFQ thread at index.
Definition source-nfq.c:964
uint32_t ifi
Definition source-nfq.h:47
uint16_t hw_protocol
Definition source-nfq.h:49
uint32_t mark
Definition source-nfq.h:46
uint32_t ifo
Definition source-nfq.h:48
uint16_t nfq_index
Definition source-nfq.h:42
uint8_t len
Definition source-nfq.h:82
struct nfq_handle * h
Definition source-nfq.h:54
uint32_t verdict
Definition source-nfq.h:79
uint64_t bytes
Definition source-nfq.h:72
uint16_t queue_num
Definition source-nfq.h:62
uint32_t packet_id
Definition source-nfq.h:78
uint32_t mark
Definition source-nfq.h:80
struct nfq_q_handle * qh
Definition source-nfq.h:59
uint32_t dropped
Definition source-nfq.h:75
SCMutex mutex_qh
Definition source-nfq.h:60
uint32_t replaced
Definition source-nfq.h:76
uint8_t maxlen
Definition source-nfq.h:83
uint32_t errs
Definition source-nfq.h:73
uint32_t pkts
Definition source-nfq.h:71
uint8_t use_mutex
Definition source-nfq.h:57
struct NFQQueueVars_::@148 verdict_cache
uint32_t accepted
Definition source-nfq.h:74
uint16_t nfq_index
Definition source-nfq.h:64
struct nfnl_handle * nh
Definition source-nfq.h:55
uint8_t mark_valid
Definition source-nfq.h:81
#define SCMutex