update ipp2p to 0.8.1rc1
[openwrt/svn-archive/archive.git] / openwrt / package / iptables / patches / 01-ipp2p-0.8.1rc1.patch
1 diff -urN iptables.old/extensions/Makefile iptables.dev/extensions/Makefile
2 --- iptables.old/extensions/Makefile 2005-07-20 04:22:56.000000000 +0200
3 +++ iptables.dev/extensions/Makefile 2006-03-23 14:42:28.000000000 +0100
4 @@ -8,6 +8,10 @@
5 PF_EXT_SLIB:=ah addrtype comment connlimit connmark conntrack dscp ecn esp hashlimit helper icmp iprange length limit mac mark multiport owner physdev pkttype realm rpc sctp standard state tcp tcpmss tos ttl udp unclean CLASSIFY CONNMARK DNAT DSCP ECN LOG MARK MASQUERADE MIRROR NETMAP NFQUEUE NOTRACK REDIRECT REJECT SAME SNAT TARPIT TCPMSS TOS TRACE TTL ULOG
6 PF6_EXT_SLIB:=eui64 hl icmpv6 length limit mac mark multiport owner physdev standard tcp udp HL LOG NFQUEUE MARK TRACE
7
8 +
9 +# ipp2p
10 +PF_EXT_SLIB += ipp2p
11 +
12 # Optionals
13 PF_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))
14 PF6_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test6),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))
15 diff -urN iptables.old/extensions/Makefile.orig iptables.dev/extensions/Makefile.orig
16 --- iptables.old/extensions/Makefile.orig 1970-01-01 01:00:00.000000000 +0100
17 +++ iptables.dev/extensions/Makefile.orig 2005-07-20 04:22:56.000000000 +0200
18 @@ -0,0 +1,167 @@
19 +#! /usr/bin/make
20 +
21 +# WARNING:
22 +# only add extensions here that are either present in the kernel, or whose
23 +# header files are present in the include/linux directory of this iptables
24 +# package (HW)
25 +#
26 +PF_EXT_SLIB:=ah addrtype comment connlimit connmark conntrack dscp ecn esp hashlimit helper icmp iprange length limit mac mark multiport owner physdev pkttype realm rpc sctp standard state tcp tcpmss tos ttl udp unclean CLASSIFY CONNMARK DNAT DSCP ECN LOG MARK MASQUERADE MIRROR NETMAP NFQUEUE NOTRACK REDIRECT REJECT SAME SNAT TARPIT TCPMSS TOS TRACE TTL ULOG
27 +PF6_EXT_SLIB:=eui64 hl icmpv6 length limit mac mark multiport owner physdev standard tcp udp HL LOG NFQUEUE MARK TRACE
28 +
29 +# Optionals
30 +PF_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))
31 +PF6_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test6),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))
32 +
33 +PF_EXT_ALL_SLIB:=$(patsubst extensions/libipt_%.c, %, $(wildcard extensions/libipt_*.c))
34 +PF6_EXT_ALL_SLIB:=$(patsubst extensions/libip6t_%.c, %, $(wildcard extensions/libip6t_*.c))
35 +
36 +PF_EXT_MAN_ALL_MATCHES:=$(foreach T,$(PF_EXT_ALL_SLIB),$(shell test -f extensions/libipt_$(T).man && grep -q register_match extensions/libipt_$(T).c && echo $(T)))
37 +PF_EXT_MAN_ALL_TARGETS:=$(foreach T,$(PF_EXT_ALL_SLIB),$(shell test -f extensions/libipt_$(T).man && grep -q register_target extensions/libipt_$(T).c && echo $(T)))
38 +PF6_EXT_MAN_ALL_MATCHES:=$(foreach T,$(PF6_EXT_ALL_SLIB),$(shell test -f extensions/libip6t_$(T).man && grep -q register_match6 extensions/libip6t_$(T).c && echo $(T)))
39 +PF6_EXT_MAN_ALL_TARGETS:=$(foreach T,$(PF6_EXT_ALL_SLIB),$(shell test -f extensions/libip6t_$(T).man && grep -q register_target6 extensions/libip6t_$(T).c && echo $(T)))
40 +
41 +PF_EXT_MAN_MATCHES:=$(filter $(PF_EXT_ALL_SLIB), $(PF_EXT_MAN_ALL_MATCHES))
42 +PF_EXT_MAN_TARGETS:=$(filter $(PF_EXT_ALL_SLIB), $(PF_EXT_MAN_ALL_TARGETS))
43 +PF_EXT_MAN_EXTRA_MATCHES:=$(filter-out $(PF_EXT_MAN_MATCHES), $(PF_EXT_MAN_ALL_MATCHES))
44 +PF_EXT_MAN_EXTRA_TARGETS:=$(filter-out $(PF_EXT_MAN_TARGETS), $(PF_EXT_MAN_ALL_TARGETS))
45 +PF6_EXT_MAN_MATCHES:=$(filter $(PF6_EXT_ALL_SLIB), $(PF6_EXT_MAN_ALL_MATCHES))
46 +PF6_EXT_MAN_TARGETS:=$(filter $(PF6_EXT_ALL_SLIB), $(PF6_EXT_MAN_ALL_TARGETS))
47 +PF6_EXT_MAN_EXTRA_MATCHES:=$(filter-out $(PF6_EXT_MAN_MATCHES), $(PF6_EXT_MAN_ALL_MATCHES))
48 +PF6_EXT_MAN_EXTRA_TARGETS:=$(filter-out $(PF6_EXT_MAN_TARGETS), $(PF6_EXT_MAN_ALL_TARGETS))
49 +
50 +
51 +allman:
52 + @echo ALL_SLIB: $(PF_EXT_ALL_SLIB)
53 + @echo ALL_MATCH: $(PF_EXT_MAN_ALL_MATCHES)
54 + @echo ALL_TARGET: $(PF_EXT_MAN_ALL_TARGETS)
55 +
56 +PF_EXT_SLIB+=$(PF_EXT_SLIB_OPTS)
57 +PF6_EXT_SLIB+=$(PF6_EXT_SLIB_OPTS)
58 +
59 +OPTIONALS+=$(patsubst %,IPv4:%,$(PF_EXT_SLIB_OPTS))
60 +OPTIONALS+=$(patsubst %,IPv6:%,$(PF6_EXT_SLIB_OPTS))
61 +
62 +ifndef NO_SHARED_LIBS
63 +SHARED_LIBS+=$(foreach T,$(PF_EXT_SLIB),extensions/libipt_$(T).so)
64 +EXTRA_INSTALLS+=$(foreach T, $(PF_EXT_SLIB), $(DESTDIR)$(LIBDIR)/iptables/libipt_$(T).so)
65 +
66 +ifeq ($(DO_IPV6), 1)
67 +SHARED_LIBS+=$(foreach T,$(PF6_EXT_SLIB),extensions/libip6t_$(T).so)
68 +EXTRA_INSTALLS+=$(foreach T, $(PF6_EXT_SLIB), $(DESTDIR)$(LIBDIR)/iptables/libip6t_$(T).so)
69 +endif
70 +else # NO_SHARED_LIBS
71 +EXT_OBJS+=$(foreach T,$(PF_EXT_SLIB),extensions/libipt_$(T).o)
72 +EXT_FUNC+=$(foreach T,$(PF_EXT_SLIB),ipt_$(T))
73 +EXT_OBJS+= extensions/initext.o
74 +ifeq ($(DO_IPV6), 1)
75 +EXT6_OBJS+=$(foreach T,$(PF6_EXT_SLIB),extensions/libip6t_$(T).o)
76 +EXT6_FUNC+=$(foreach T,$(PF6_EXT_SLIB),ip6t_$(T))
77 +EXT6_OBJS+= extensions/initext6.o
78 +endif # DO_IPV6
79 +endif # NO_SHARED_LIBS
80 +
81 +ifndef TOPLEVEL_INCLUDED
82 +local:
83 + cd .. && $(MAKE) $(SHARED_LIBS)
84 +endif
85 +
86 +ifdef NO_SHARED_LIBS
87 +extensions/libext.a: $(EXT_OBJS)
88 + rm -f $@; ar crv $@ $(EXT_OBJS)
89 +
90 +extensions/libext6.a: $(EXT6_OBJS)
91 + rm -f $@; ar crv $@ $(EXT6_OBJS)
92 +
93 +extensions/initext.o: extensions/initext.c
94 +extensions/initext6.o: extensions/initext6.c
95 +
96 +extensions/initext.c: extensions/Makefile
97 + echo "" > $@
98 + for i in $(EXT_FUNC); do \
99 + echo "extern void $${i}_init(void);" >> $@; \
100 + done
101 + echo "void init_extensions(void) {" >> $@
102 + for i in $(EXT_FUNC); do \
103 + echo " $${i}_init();" >> $@; \
104 + done
105 + echo "}" >> $@
106 +
107 +extensions/initext6.c: extensions/Makefile
108 + echo "" > $@
109 + for i in $(EXT6_FUNC); do \
110 + echo "extern void $${i}_init(void);" >> $@; \
111 + done
112 + echo "void init_extensions(void) {" >> $@
113 + for i in $(EXT6_FUNC); do \
114 + echo " $${i}_init();" >> $@; \
115 + done
116 + echo "}" >> $@
117 +
118 +extensions/lib%.o: extensions/lib%.c
119 + $(CC) $(CFLAGS) -D_INIT=$*_init -c -o $@ $<
120 +
121 +endif
122 +
123 +EXTRAS += extensions/libipt_targets.man
124 +extensions/libipt_targets.man: $(patsubst %,extensions/libipt_%.man,$(PF_EXT_MAN_ALL_TARGETS))
125 + @for ext in $(PF_EXT_MAN_TARGETS); do \
126 + echo ".SS $$ext" ;\
127 + cat extensions/libipt_$$ext.man ;\
128 + done >extensions/libipt_targets.man
129 + @if [ -n "$(PF_EXT_MAN_EXTRA_TARGETS)" ]; then \
130 + extra=$(PF_EXT_MAN_EXTRA_TARGETS) ;\
131 + for ext in $${extra:-""}; do \
132 + echo ".SS $$ext (not supported, see Patch-O-Matic)" ;\
133 + cat extensions/libipt_$$ext.man ;\
134 + done ;\
135 + fi >>extensions/libipt_targets.man
136 +
137 +EXTRAS += extensions/libipt_matches.man
138 +extensions/libipt_matches.man: $(patsubst %,extensions/libipt_%.man,$(PF_EXT_MAN_ALL_MATCHES))
139 + @for ext in $(PF_EXT_MAN_MATCHES); do \
140 + echo ".SS $$ext" ;\
141 + cat extensions/libipt_$$ext.man ;\
142 + done >extensions/libipt_matches.man
143 + @if [ -n "$(PF_EXT_MAN_EXTRA_MATCHES)" ]; then \
144 + extra=$(PF_EXT_MAN_EXTRA_MATCHES) ;\
145 + for ext in $${extra:-""}; do \
146 + echo ".SS $$ext (not supported, see Patch-O-Matic)" ;\
147 + cat extensions/libipt_$$ext.man ;\
148 + done ;\
149 + fi >>extensions/libipt_matches.man
150 +
151 +EXTRAS += extensions/libip6t_targets.man
152 +extensions/libip6t_targets.man: $(patsubst %, extensions/libip6t_%.man, $(PF6_EXT_MAN_ALL_TARGETS))
153 + @for ext in $(PF6_EXT_MAN_TARGETS); do \
154 + echo ".SS $$ext" ;\
155 + cat extensions/libip6t_$$ext.man ;\
156 + done >extensions/libip6t_targets.man
157 + @if [ -n "$(PF6_EXT_MAN_EXTRA_TARGETS)" ]; then \
158 + extra=$(PF6_EXT_MAN_EXTRA_TARGETS) ;\
159 + for ext in $${extra:-""}; do \
160 + echo ".SS $$ext (not supported, see Patch-O-Matic)" ;\
161 + cat extensions/libip6t_$$ext.man ;\
162 + done ;\
163 + fi >>extensions/libip6t_targets.man
164 +
165 +EXTRAS += extensions/libip6t_matches.man
166 +extensions/libip6t_matches.man: $(patsubst %, extensions/libip6t_%.man, $(PF6_EXT_MAN_ALL_MATCHES))
167 + @for ext in $(PF6_EXT_MAN_MATCHES); do \
168 + echo ".SS $$ext" ;\
169 + cat extensions/libip6t_$$ext.man ;\
170 + done >extensions/libip6t_matches.man
171 + @if [ -n "$(PF6_EXT_MAN_EXTRA_MATCHES)" ]; then \
172 + extra=$(PF6_EXT_MAN_EXTRA_MATCHES) ;\
173 + for ext in $${extra:-""}; do \
174 + echo ".SS $$ext (not supported, see Patch-O-Matic)" ;\
175 + cat extensions/libip6t_$$ext.man ;\
176 + done ;\
177 + fi >>extensions/libip6t_matches.man
178 +
179 +$(DESTDIR)$(LIBDIR)/iptables/libipt_%.so: extensions/libipt_%.so
180 + @[ -d $(DESTDIR)$(LIBDIR)/iptables ] || mkdir -p $(DESTDIR)$(LIBDIR)/iptables
181 + cp $< $@
182 +
183 +$(DESTDIR)$(LIBDIR)/iptables/libip6t_%.so: extensions/libip6t_%.so
184 + @[ -d $(DESTDIR)$(LIBDIR)/iptables ] || mkdir -p $(DESTDIR)$(LIBDIR)/iptables
185 + cp $< $@
186 diff -urN iptables.old/extensions/libipt_ipp2p.c iptables.dev/extensions/libipt_ipp2p.c
187 --- iptables.old/extensions/libipt_ipp2p.c 1970-01-01 01:00:00.000000000 +0100
188 +++ iptables.dev/extensions/libipt_ipp2p.c 2006-03-23 14:43:26.000000000 +0100
189 @@ -0,0 +1,401 @@
190 +
191 +#include <stdio.h>
192 +#include <netdb.h>
193 +#include <string.h>
194 +#include <stdlib.h>
195 +#include <getopt.h>
196 +#include <ctype.h>
197 +
198 +#include <iptables.h>
199 +
200 +#include <linux/netfilter_ipv4/ipt_ipp2p.h>
201 +
202 +static void
203 +help(void)
204 +{
205 + printf(
206 + "IPP2P v%s options:\n"
207 + " --ipp2p Grab all known p2p packets\n"
208 + " --edk [TCP&UDP] All known eDonkey/eMule/Overnet packets\n"
209 + " --dc [TCP] All known Direct Connect packets\n"
210 + " --kazaa [TCP&UDP] All known KaZaA packets\n"
211 + " --gnu [TCP&UDP] All known Gnutella packets\n"
212 + " --bit [TCP&UDP] All known BitTorrent packets\n"
213 + " --apple [TCP] All known AppleJuice packets\n"
214 + " --winmx [TCP] All known WinMX\n"
215 + " --soul [TCP] All known SoulSeek\n"
216 + " --ares [TCP] All known Ares\n\n"
217 + " EXPERIMENTAL protocols (please send feedback to: ipp2p@ipp2p.org) :\n"
218 + " --mute [TCP] All known Mute packets\n"
219 + " --waste [TCP] All known Waste packets\n"
220 + " --xdcc [TCP] All known XDCC packets (only xdcc login)\n\n"
221 + " DEBUG SUPPPORT, use only if you know why\n"
222 + " --debug Generate kernel debug output, THIS WILL SLOW DOWN THE FILTER\n"
223 + "\nNote that the follwing options will have the same meaning:\n"
224 + " '--ipp2p' is equal to '--edk --dc --kazaa --gnu --bit --apple --winmx --soul --ares'\n"
225 + "\nIPP2P was intended for TCP only. Due to increasing usage of UDP we needed to change this.\n"
226 + "You can now use -p udp to search UDP packets only or without -p switch to search UDP and TCP packets.\n"
227 + "\nSee README included with this package for more details or visit http://www.ipp2p.org\n"
228 + "\nExamples:\n"
229 + " iptables -A FORWARD -m ipp2p --ipp2p -j MARK --set-mark 0x01\n"
230 + " iptables -A FORWARD -p udp -m ipp2p --kazaa --bit -j DROP\n"
231 + " iptables -A FORWARD -p tcp -m ipp2p --edk --soul -j DROP\n\n"
232 + , IPP2P_VERSION);
233 +}
234 +
235 +static struct option opts[] = {
236 + { "ipp2p", 0, 0, '1' },
237 + { "edk", 0, 0, '2' },
238 + { "dc", 0, 0, '7' },
239 + { "gnu", 0, 0, '9' },
240 + { "kazaa", 0, 0, 'a' },
241 + { "bit", 0, 0, 'b' },
242 + { "apple", 0, 0, 'c' },
243 + { "soul", 0, 0, 'd' },
244 + { "winmx", 0, 0, 'e' },
245 + { "ares", 0, 0, 'f' },
246 + { "mute", 0, 0, 'g' },
247 + { "waste", 0, 0, 'h' },
248 + { "xdcc", 0, 0, 'i' },
249 + { "debug", 0, 0, 'j' },
250 + {0}
251 +};
252 +
253 +
254 +
255 +static void
256 +init(struct ipt_entry_match *m, unsigned int *nfcache)
257 +{
258 + struct ipt_p2p_info *info = (struct ipt_p2p_info *)m->data;
259 +
260 + *nfcache |= NFC_UNKNOWN;
261 +
262 + /*init the module with default values*/
263 + info->cmd = 0;
264 + info->debug = 0;
265 +
266 +}
267 +
268 +
269 +static int
270 +parse(int c, char **argv, int invert, unsigned int *flags,
271 + const struct ipt_entry *entry,
272 + unsigned int *nfcache,
273 + struct ipt_entry_match **match)
274 +{
275 + struct ipt_p2p_info *info = (struct ipt_p2p_info *)(*match)->data;
276 +
277 + switch (c) {
278 + case '1': /*cmd: ipp2p*/
279 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
280 + exit_error(PARAMETER_PROBLEM,
281 + "ipp2p: `--ipp2p' may only be "
282 + "specified once!");
283 +/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
284 + exit_error(PARAMETER_PROBLEM,
285 + "ipp2p: `--ipp2p-data' may only be "
286 + "specified alone!");*/
287 + if ((*flags) != 0)
288 + exit_error(PARAMETER_PROBLEM,
289 + "ipp2p: `--ipp2p' may only be "
290 + "specified alone!");
291 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
292 + *flags += SHORT_HAND_IPP2P;
293 + info->cmd = *flags;
294 + break;
295 +
296 + case '2': /*cmd: edk*/
297 + if ((*flags & IPP2P_EDK) == IPP2P_EDK)
298 + exit_error(PARAMETER_PROBLEM,
299 + "ipp2p: `--edk' may only be "
300 + "specified once");
301 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
302 + exit_error(PARAMETER_PROBLEM,
303 + "ipp2p: `--ipp2p' may only be "
304 + "specified alone!");
305 +/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
306 + exit_error(PARAMETER_PROBLEM,
307 + "ipp2p: `--ipp2p-data' may only be "
308 + "specified alone!");*/
309 + if ((*flags & IPP2P_DATA_EDK) == IPP2P_DATA_EDK)
310 + exit_error(PARAMETER_PROBLEM,
311 + "ipp2p: use `--edk' OR `--edk-data' but not both of them!");
312 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
313 + *flags += IPP2P_EDK;
314 + info->cmd = *flags;
315 + break;
316 +
317 +
318 + case '7': /*cmd: dc*/
319 + if ((*flags & IPP2P_DC) == IPP2P_DC)
320 + exit_error(PARAMETER_PROBLEM,
321 + "ipp2p: `--dc' may only be "
322 + "specified once!");
323 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
324 + exit_error(PARAMETER_PROBLEM,
325 + "ipp2p: `--ipp2p' may only be "
326 + "specified alone!");
327 +/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
328 + exit_error(PARAMETER_PROBLEM,
329 + "ipp2p: `--ipp2p-data' may only be "
330 + "specified alone!");*/
331 + if ((*flags & IPP2P_DATA_DC) == IPP2P_DATA_DC)
332 + exit_error(PARAMETER_PROBLEM,
333 + "ipp2p: use `--dc' OR `--dc-data' but not both of them!");
334 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
335 + *flags += IPP2P_DC;
336 + info->cmd = *flags;
337 + break;
338 +
339 +
340 + case '9': /*cmd: gnu*/
341 + if ((*flags & IPP2P_GNU) == IPP2P_GNU)
342 + exit_error(PARAMETER_PROBLEM,
343 + "ipp2p: `--gnu' may only be "
344 + "specified once!");
345 +/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
346 + exit_error(PARAMETER_PROBLEM,
347 + "ipp2p: `--ipp2p-data' may only be "
348 + "specified alone!");*/
349 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
350 + exit_error(PARAMETER_PROBLEM,
351 + "ipp2p: `--ipp2p' may only be "
352 + "specified alone!");
353 + if ((*flags & IPP2P_DATA_GNU) == IPP2P_DATA_GNU)
354 + exit_error(PARAMETER_PROBLEM,
355 + "ipp2p: use `--gnu' OR `--gnu-data' but not both of them!");
356 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
357 + *flags += IPP2P_GNU;
358 + info->cmd = *flags;
359 + break;
360 +
361 + case 'a': /*cmd: kazaa*/
362 + if ((*flags & IPP2P_KAZAA) == IPP2P_KAZAA)
363 + exit_error(PARAMETER_PROBLEM,
364 + "ipp2p: `--kazaa' may only be "
365 + "specified once!");
366 +/* if ((*flags & SHORT_HAND_DATA) == SHORT_HAND_DATA)
367 + exit_error(PARAMETER_PROBLEM,
368 + "ipp2p: `--ipp2p-data' may only be "
369 + "specified alone!");*/
370 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
371 + exit_error(PARAMETER_PROBLEM,
372 + "ipp2p: `--ipp2p' may only be "
373 + "specified alone!");
374 + if ((*flags & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA)
375 + exit_error(PARAMETER_PROBLEM,
376 + "ipp2p: use `--kazaa' OR `--kazaa-data' but not both of them!");
377 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
378 + *flags += IPP2P_KAZAA;
379 + info->cmd = *flags;
380 + break;
381 +
382 + case 'b': /*cmd: bit*/
383 + if ((*flags & IPP2P_BIT) == IPP2P_BIT)
384 + exit_error(PARAMETER_PROBLEM,
385 + "ipp2p: `--bit' may only be "
386 + "specified once!");
387 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
388 + exit_error(PARAMETER_PROBLEM,
389 + "ipp2p: `--ipp2p' may only be "
390 + "specified alone!");
391 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
392 + *flags += IPP2P_BIT;
393 + info->cmd = *flags;
394 + break;
395 +
396 + case 'c': /*cmd: apple*/
397 + if ((*flags & IPP2P_APPLE) == IPP2P_APPLE)
398 + exit_error(PARAMETER_PROBLEM,
399 + "ipp2p: `--apple' may only be "
400 + "specified once!");
401 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
402 + exit_error(PARAMETER_PROBLEM,
403 + "ipp2p: `--ipp2p' may only be "
404 + "specified alone!");
405 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
406 + *flags += IPP2P_APPLE;
407 + info->cmd = *flags;
408 + break;
409 +
410 +
411 + case 'd': /*cmd: soul*/
412 + if ((*flags & IPP2P_SOUL) == IPP2P_SOUL)
413 + exit_error(PARAMETER_PROBLEM,
414 + "ipp2p: `--soul' may only be "
415 + "specified once!");
416 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
417 + exit_error(PARAMETER_PROBLEM,
418 + "ipp2p: `--ipp2p' may only be "
419 + "specified alone!");
420 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
421 + *flags += IPP2P_SOUL;
422 + info->cmd = *flags;
423 + break;
424 +
425 +
426 + case 'e': /*cmd: winmx*/
427 + if ((*flags & IPP2P_WINMX) == IPP2P_WINMX)
428 + exit_error(PARAMETER_PROBLEM,
429 + "ipp2p: `--winmx' may only be "
430 + "specified once!");
431 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
432 + exit_error(PARAMETER_PROBLEM,
433 + "ipp2p: `--ipp2p' may only be "
434 + "specified alone!");
435 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
436 + *flags += IPP2P_WINMX;
437 + info->cmd = *flags;
438 + break;
439 +
440 + case 'f': /*cmd: ares*/
441 + if ((*flags & IPP2P_ARES) == IPP2P_ARES)
442 + exit_error(PARAMETER_PROBLEM,
443 + "ipp2p: `--ares' may only be "
444 + "specified once!");
445 + if ((*flags & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P)
446 + exit_error(PARAMETER_PROBLEM,
447 + "ipp2p: `--ipp2p' may only be "
448 + "specified alone!");
449 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
450 + *flags += IPP2P_ARES;
451 + info->cmd = *flags;
452 + break;
453 +
454 + case 'g': /*cmd: mute*/
455 + if ((*flags & IPP2P_MUTE) == IPP2P_MUTE)
456 + exit_error(PARAMETER_PROBLEM,
457 + "ipp2p: `--mute' may only be "
458 + "specified once!");
459 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
460 + *flags += IPP2P_MUTE;
461 + info->cmd = *flags;
462 + break;
463 + case 'h': /*cmd: waste*/
464 + if ((*flags & IPP2P_WASTE) == IPP2P_WASTE)
465 + exit_error(PARAMETER_PROBLEM,
466 + "ipp2p: `--waste' may only be "
467 + "specified once!");
468 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
469 + *flags += IPP2P_WASTE;
470 + info->cmd = *flags;
471 + break;
472 + case 'i': /*cmd: xdcc*/
473 + if ((*flags & IPP2P_XDCC) == IPP2P_XDCC)
474 + exit_error(PARAMETER_PROBLEM,
475 + "ipp2p: `--ares' may only be "
476 + "specified once!");
477 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
478 + *flags += IPP2P_XDCC;
479 + info->cmd = *flags;
480 + break;
481 +
482 + case 'j': /*cmd: debug*/
483 + if (invert) exit_error(PARAMETER_PROBLEM, "ipp2p: invert [!] is not allowed!");
484 + info->debug = 1;
485 + break;
486 +
487 + default:
488 +// exit_error(PARAMETER_PROBLEM,
489 +// "\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n");
490 + return 0;
491 + }
492 + return 1;
493 +}
494 +
495 +
496 +static void
497 +final_check(unsigned int flags)
498 +{
499 + if (!flags)
500 + exit_error(PARAMETER_PROBLEM,
501 + "\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n");
502 +}
503 +
504 +
505 +
506 +static void
507 +print(const struct ipt_ip *ip,
508 + const struct ipt_entry_match *match,
509 + int numeric)
510 +{
511 + struct ipt_p2p_info *info = (struct ipt_p2p_info *)match->data;
512 +
513 + printf("ipp2p v%s", IPP2P_VERSION);
514 + if ((info->cmd & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) printf(" --ipp2p");
515 +// if ((info->cmd & SHORT_HAND_DATA) == SHORT_HAND_DATA) printf(" --ipp2p-data");
516 + if ((info->cmd & IPP2P_KAZAA) == IPP2P_KAZAA) printf(" --kazaa");
517 +// if ((info->cmd & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA) printf(" --kazaa-data");
518 +// if ((info->cmd & IPP2P_DATA_GNU) == IPP2P_DATA_GNU) printf(" --gnu-data");
519 + if ((info->cmd & IPP2P_GNU) == IPP2P_GNU) printf(" --gnu");
520 + if ((info->cmd & IPP2P_EDK) == IPP2P_EDK) printf(" --edk");
521 +// if ((info->cmd & IPP2P_DATA_EDK) == IPP2P_DATA_EDK) printf(" --edk-data");
522 +// if ((info->cmd & IPP2P_DATA_DC) == IPP2P_DATA_DC) printf(" --dc-data");
523 + if ((info->cmd & IPP2P_DC) == IPP2P_DC) printf(" --dc");
524 + if ((info->cmd & IPP2P_BIT) == IPP2P_BIT) printf(" --bit");
525 + if ((info->cmd & IPP2P_APPLE) == IPP2P_APPLE) printf(" --apple");
526 + if ((info->cmd & IPP2P_SOUL) == IPP2P_SOUL) printf(" --soul");
527 + if ((info->cmd & IPP2P_WINMX) == IPP2P_WINMX) printf(" --winmx");
528 + if ((info->cmd & IPP2P_ARES) == IPP2P_ARES) printf(" --ares");
529 + if ((info->cmd & IPP2P_MUTE) == IPP2P_MUTE) printf(" --mute");
530 + if ((info->cmd & IPP2P_WASTE) == IPP2P_WASTE) printf(" --waste");
531 + if ((info->cmd & IPP2P_XDCC) == IPP2P_XDCC) printf(" --xdcc");
532 + if (info->debug != 0) printf(" --debug");
533 + printf(" ");
534 +}
535 +
536 +
537 +
538 +static void
539 +save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
540 +{
541 + struct ipt_p2p_info *info = (struct ipt_p2p_info *)match->data;
542 +
543 + if ((info->cmd & SHORT_HAND_IPP2P) == SHORT_HAND_IPP2P) printf("--ipp2p ");
544 +// if ((info->cmd & SHORT_HAND_DATA) == SHORT_HAND_DATA) printf("--ipp2p-data ");
545 + if ((info->cmd & IPP2P_KAZAA) == IPP2P_KAZAA) printf("--kazaa ");
546 +// if ((info->cmd & IPP2P_DATA_KAZAA) == IPP2P_DATA_KAZAA) printf("--kazaa-data ");
547 +// if ((info->cmd & IPP2P_DATA_GNU) == IPP2P_DATA_GNU) printf("--gnu-data ");
548 + if ((info->cmd & IPP2P_GNU) == IPP2P_GNU) printf("--gnu ");
549 + if ((info->cmd & IPP2P_EDK) == IPP2P_EDK) printf("--edk ");
550 +// if ((info->cmd & IPP2P_DATA_EDK) == IPP2P_DATA_EDK) printf("--edk-data ");
551 +// if ((info->cmd & IPP2P_DATA_DC) == IPP2P_DATA_DC) printf("--dc-data ");
552 + if ((info->cmd & IPP2P_DC) == IPP2P_DC) printf("--dc ");
553 + if ((info->cmd & IPP2P_BIT) == IPP2P_BIT) printf("--bit ");
554 + if ((info->cmd & IPP2P_APPLE) == IPP2P_APPLE) printf("--apple ");
555 + if ((info->cmd & IPP2P_SOUL) == IPP2P_SOUL) printf("--soul ");
556 + if ((info->cmd & IPP2P_WINMX) == IPP2P_WINMX) printf("--winmx ");
557 + if ((info->cmd & IPP2P_ARES) == IPP2P_ARES) printf("--ares ");
558 + if ((info->cmd & IPP2P_MUTE) == IPP2P_MUTE) printf(" --mute");
559 + if ((info->cmd & IPP2P_WASTE) == IPP2P_WASTE) printf(" --waste");
560 + if ((info->cmd & IPP2P_XDCC) == IPP2P_XDCC) printf(" --xdcc");
561 + if (info->debug != 0) printf("--debug ");
562 +}
563 +
564 +
565 +
566 +
567 +static
568 +struct iptables_match ipp2p=
569 +{
570 + .next = NULL,
571 + .name = "ipp2p",
572 + .version = IPTABLES_VERSION,
573 + .size = IPT_ALIGN(sizeof(struct ipt_p2p_info)),
574 + .userspacesize = IPT_ALIGN(sizeof(struct ipt_p2p_info)),
575 + .help = &help,
576 + .init = &init,
577 + .parse = &parse,
578 + .final_check = &final_check,
579 + .print = &print,
580 + .save = &save,
581 + .extra_opts = opts
582 +};
583 +
584 +
585 +
586 +void _init(void)
587 +{
588 + register_match(&ipp2p);
589 +}
590 +
591 diff -urN iptables.old/include/linux/netfilter_ipv4/ipt_ipp2p.h iptables.dev/include/linux/netfilter_ipv4/ipt_ipp2p.h
592 --- iptables.old/include/linux/netfilter_ipv4/ipt_ipp2p.h 1970-01-01 01:00:00.000000000 +0100
593 +++ iptables.dev/include/linux/netfilter_ipv4/ipt_ipp2p.h 2006-03-23 14:44:26.000000000 +0100
594 @@ -0,0 +1,31 @@
595 +#ifndef __IPT_IPP2P_H
596 +#define __IPT_IPP2P_H
597 +#define IPP2P_VERSION "0.8.1_rc1"
598 +
599 +struct ipt_p2p_info {
600 + int cmd;
601 + int debug;
602 +};
603 +
604 +#endif //__IPT_IPP2P_H
605 +
606 +#define SHORT_HAND_IPP2P 1 /* --ipp2p switch*/
607 +//#define SHORT_HAND_DATA 4 /* --ipp2p-data switch*/
608 +#define SHORT_HAND_NONE 5 /* no short hand*/
609 +
610 +#define IPP2P_EDK (1 << 1)
611 +#define IPP2P_DATA_KAZAA (1 << 2)
612 +#define IPP2P_DATA_EDK (1 << 3)
613 +#define IPP2P_DATA_DC (1 << 4)
614 +#define IPP2P_DC (1 << 5)
615 +#define IPP2P_DATA_GNU (1 << 6)
616 +#define IPP2P_GNU (1 << 7)
617 +#define IPP2P_KAZAA (1 << 8)
618 +#define IPP2P_BIT (1 << 9)
619 +#define IPP2P_APPLE (1 << 10)
620 +#define IPP2P_SOUL (1 << 11)
621 +#define IPP2P_WINMX (1 << 12)
622 +#define IPP2P_ARES (1 << 13)
623 +#define IPP2P_MUTE (1 << 14)
624 +#define IPP2P_WASTE (1 << 15)
625 +#define IPP2P_XDCC (1 << 16)