1 Description: Follow API changes in libnetfilter-conntrack.
3 Bug: http://sourceforge.net/tracker/?func=detail&aid=2834175&group_id=80085&atid=558668
4 Bug-Debian: http://bugs.debian.org/547351
5 Bug-Gentoo: http://bugs.gentoo.org/280747
7 Index: l7-filter-userspace/l7-conntrack.cpp
8 ===================================================================
9 --- l7-filter-userspace.orig/l7-conntrack.cpp 2009-02-26 22:40:28.000000000 +0100
10 +++ l7-filter-userspace/l7-conntrack.cpp 2009-11-27 12:37:46.000000000 +0100
18 #include <linux/types.h>
20 return (char *)buffer;
23 -static int sprintf_conntrack_key(char *buf, struct nfct_conntrack *ct,
28 - size += nfct_sprintf_protocol(buf, ct);
29 - size += nfct_sprintf_address(buf+size, &ct->tuple[NFCT_DIR_ORIGINAL]);
30 - size += nfct_sprintf_proto(buf+size, &ct->tuple[NFCT_DIR_ORIGINAL]);
32 - /* Delete the last blank space */
38 -static string make_key(nfct_conntrack* ct, int flags)
39 +static string make_key(nf_conntrack* ct)
42 - int keysize = sprintf_conntrack_key(key, ct, flags);
43 + int keysize = nfct_snprintf(key, sizeof key, ct, NFCT_T_UNKNOWN, NFCT_O_DEFAULT, 0);
45 + stringstream stream;
46 + for (int i = 0; i < 2; i++)
48 + while (*p > 0 && *p > ' ')
50 + while (*p > 0 && *p <= ' ')
53 + while (*p > 0 && *p != 's')
55 + for (int i = 0; i < 4; i++)
57 + while (*p > 0 && *p <= ' ')
59 + while (*p > 0 && *p > ' ')
63 cerr << "Yike! Overflowed key!\n";
66 - l7printf(2, "Made key from ct:\t%s\n", key);
68 + string result = stream.str();
69 + l7printf(2, "Made key from ct:\t%s\n", result.c_str());
73 -static int l7_handle_conntrack_event(void *arg, unsigned int flags, int type,
75 +static int l7_handle_conntrack_event(enum nf_conntrack_msg_type type, nf_conntrack *ct, void *data)
77 l7_conntrack * l7_conntrack_handler = (l7_conntrack *) data;
79 - nfct_conntrack* ct = (nfct_conntrack*)arg;
80 + u_int8_t protonum = nfct_get_attr_u8(ct, ATTR_ORIG_L4PROTO);
82 // I don't think there is any demand for ICMP. These are enough work for now.
83 - if(ct->tuple[0].protonum != IPPROTO_TCP &&
84 - ct->tuple[0].protonum != IPPROTO_UDP) return 0;
85 + if(protonum != IPPROTO_TCP && protonum != IPPROTO_UDP)
86 + return NFCT_CB_CONTINUE;
88 - if(type == NFCT_MSG_DESTROY) l7printf(3, "Got event: NFCT_MSG_DESTROY\n");
89 - if(type == NFCT_MSG_NEW) l7printf(3, "Got event: NFCT_MSG_NEW\n");
90 - if(type == NFCT_MSG_UPDATE) l7printf(3, "Got event: NFCT_MSG_UPDATE\n");
91 - if(type == NFCT_MSG_UNKNOWN) l7printf(3, "Got event: NFCT_MSG_UNKNOWN\n");
92 + if(type == NFCT_T_DESTROY) l7printf(3, "Got event: NFCT_T_DESTROY\n");
93 + if(type == NFCT_T_NEW) l7printf(3, "Got event: NFCT_T_NEW\n");
94 + if(type == NFCT_T_UPDATE) l7printf(3, "Got event: NFCT_T_UPDATE\n");
95 + if(type == NFCT_T_UNKNOWN) l7printf(3, "Got event: NFCT_T_UNKNOWN\n");
97 // On the first packet, create the connection buffer, etc.
98 - if(type == NFCT_MSG_NEW){
99 - string key = make_key(ct, flags);
100 + if(type == NFCT_T_NEW){
101 + string key = make_key(ct);
102 if (l7_conntrack_handler->get_l7_connection(key)){
103 // this happens sometimes
104 cerr << "Received NFCT_MSG_NEW but already have a connection. Packets = "
105 @@ -179,21 +183,20 @@
106 l7_conntrack_handler->add_l7_connection(thisconnection, key);
107 thisconnection->key = key;
109 - else if(type == NFCT_MSG_DESTROY){
110 + else if(type == NFCT_T_DESTROY){
111 // clean up the connection buffer, etc.
112 - string key = make_key(ct, flags);
113 + string key = make_key(ct);
114 if(l7_conntrack_handler->get_l7_connection(key)){
115 l7_conntrack_handler->remove_l7_connection(key);
120 + return NFCT_CB_CONTINUE;
124 l7_conntrack::~l7_conntrack()
126 - nfct_conntrack_free(ct);
134 - nfct_register_callback(cth, l7_handle_conntrack_event, (void *)this);
135 - ret = nfct_event_conntrack(cth); // this is the main loop
136 + nfct_callback_register(cth, NFCT_T_ALL, l7_handle_conntrack_event, (void *)this);
137 + ret = nfct_catch(cth); // this is the main loop
140 - nfct_conntrack_free(ct);
142 Index: l7-filter-userspace/l7-conntrack.h
143 ===================================================================
144 --- l7-filter-userspace.orig/l7-conntrack.h 2009-11-10 21:33:44.000000000 +0100
145 +++ l7-filter-userspace/l7-conntrack.h 2009-11-10 21:35:55.000000000 +0100
149 l7_map l7_connections;
150 - struct nfct_conntrack *ct;
151 struct nfct_handle *cth; // the callback