-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathl7-conntrack.h
More file actions
66 lines (53 loc) · 1.78 KB
/
l7-conntrack.h
File metadata and controls
66 lines (53 loc) · 1.78 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
Functions and classes which track the conntracks for l7-filter
By Ethan Sommer <sommere@users.sf.net> and Matthew Strait
<quadong@users.sf.net>, (C) 2006-2007
http://l7-filter.sf.net
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.
http://www.gnu.org/licenses/gpl.txt
Based on ctnl_test.c from libnetfilter-conntrack 0.0.31 (C) 2005 by
Pablo Neira Ayuso <pablo@eurodev.net>
*/
#ifndef L7_CONNTRACK_H
#define L7_CONNTRACK_H
#include "l7-classify.h"
#include <map>
class l7_connection {
private:
unsigned int num_packets;
unsigned int mark; // this is just our part of the mark,
// e.g. 0x3 of 0x12345678 if markmask is 0x00f00000
pthread_mutex_t num_packets_mutex;
pthread_mutex_t buffer_mutex;
public:
char * buffer;
unsigned int lengthsofar;//len of data in buffer, not counting terminating \0
string key;
l7_connection();
~l7_connection();
void increment_num_packets();
int get_num_packets();
void append_to_buffer(char *inbuf, unsigned int appdatalen);
char *get_buffer();
u_int32_t classify();
u_int32_t get_mark();
};
typedef map <string, l7_connection *> l7_map;
class l7_conntrack {
private:
l7_map l7_connections;
struct nfct_handle *cth; // the callback
pthread_mutex_t map_mutex;
public:
l7_conntrack(void * foo);
~l7_conntrack();
void start();
string make_key(const unsigned char *packetdata, bool reverse) const;
l7_connection* get_l7_connection(const string key);
void add_l7_connection(l7_connection *connection, const string key);
void remove_l7_connection(const string key);
};
#endif