SOURCES (LINUX_2_6): linux-2.6-nf-ipp2p.patch - updated from 0.7.2...

pluto pluto at pld-linux.org
Wed Nov 2 23:06:16 CET 2005


Author: pluto                        Date: Wed Nov  2 22:06:16 2005 GMT
Module: SOURCES                       Tag: LINUX_2_6
---- Log message:
- updated from 0.7.2 to 0.8.0.

---- Files affected:
SOURCES:
   linux-2.6-nf-ipp2p.patch (1.1.2.2 -> 1.1.2.3) 

---- Diffs:

================================================================
Index: SOURCES/linux-2.6-nf-ipp2p.patch
diff -u SOURCES/linux-2.6-nf-ipp2p.patch:1.1.2.2 SOURCES/linux-2.6-nf-ipp2p.patch:1.1.2.3
--- SOURCES/linux-2.6-nf-ipp2p.patch:1.1.2.2	Mon Oct 31 19:38:44 2005
+++ SOURCES/linux-2.6-nf-ipp2p.patch	Wed Nov  2 23:06:11 2005
@@ -1,8 +1,8 @@
- include/linux/netfilter_ipv4/ipt_ipp2p.h |   29 +
+ include/linux/netfilter_ipv4/ipt_ipp2p.h |   29 
  net/ipv4/netfilter/Kconfig               |   10 
  net/ipv4/netfilter/Makefile              |    1 
- net/ipv4/netfilter/ipt_ipp2p.c           |  640 +++++++++++++++++++++++++++++++
- 4 files changed, 680 insertions(+)
+ net/ipv4/netfilter/ipt_ipp2p.c           |  927 +++++++++++++++++++++++++++++++
+ 4 files changed, 967 insertions(+)
 
 diff -Nur --exclude '*.orig' linux-2.6.14.org/include/linux/netfilter_ipv4/ipt_ipp2p.h linux-2.6.14/include/linux/netfilter_ipv4/ipt_ipp2p.h
 --- linux-2.6.14.org/include/linux/netfilter_ipv4/ipt_ipp2p.h	1970-01-01 01:00:00.000000000 +0100
@@ -10,7 +10,7 @@
 @@ -0,0 +1,29 @@
 +#ifndef __IPT_IPP2P_H
 +#define __IPT_IPP2P_H
-+#define IPP2P_VERSION "0.7.2"
++#define IPP2P_VERSION "0.8.0"
 +
 +struct ipt_p2p_info {
 +    int cmd;
@@ -20,7 +20,7 @@
 +#endif //__IPT_IPP2P_H
 +
 +#define SHORT_HAND_IPP2P	1 /* --ipp2p switch*/
-+#define SHORT_HAND_DATA		4 /* --ipp2p-data switch*/
++//#define SHORT_HAND_DATA		4 /* --ipp2p-data switch*/
 +#define SHORT_HAND_NONE		5 /* no short hand*/
 +
 +#define IPP2P_EDK		2
@@ -64,7 +64,10 @@
 diff -Nur --exclude '*.orig' linux-2.6.14.org/net/ipv4/netfilter/ipt_ipp2p.c linux-2.6.14/net/ipv4/netfilter/ipt_ipp2p.c
 --- linux-2.6.14.org/net/ipv4/netfilter/ipt_ipp2p.c	1970-01-01 01:00:00.000000000 +0100
 +++ linux-2.6.14/net/ipv4/netfilter/ipt_ipp2p.c	2005-10-31 19:23:09.000000000 +0100
-@@ -0,0 +1,640 @@
+@@ -0,0 +1,927 @@
++#if defined(MODVERSIONS)
++#include <linux/modversions.h>
++#endif
 +#include <linux/module.h>
 +#include <linux/netfilter_ipv4/ip_tables.h>
 +#include <linux/version.h>
@@ -76,7 +79,7 @@
 +#define get_u16(X,O)  (*(__u16 *)(X + O))
 +#define get_u32(X,O)  (*(__u32 *)(X + O))
 +
-+MODULE_AUTHOR("Eicke Friedrich <ipp2p at ipp2p.org>");
++MODULE_AUTHOR("Eicke Friedrich/Klaus Degner <ipp2p at ipp2p.org>");
 +MODULE_DESCRIPTION("An extension to iptables to identify P2P traffic.");
 +MODULE_LICENSE("GPL");
 +
@@ -91,10 +94,12 @@
 +    switch (t[0]) {
 +    case 0xe3: {	/*edonkey*/
 +	switch (t[1]) {
-+			/* e3 9a + 16Bytes Hash | size == 26 */
-+	case 0x9a: if (packet_len == 26) return ((IPP2P_EDK * 100) + 1);
++			/* e3 9a + 16Bytes Hash | size == 10 + x* 16 byte hashes */
++	case 0x9a: if ( ( packet_len - 10) % 16 == 0) return ((IPP2P_EDK * 100) + 50);
 +			/* e3 96 xx yy zz kk | size == 14 | server status request */
-+	case 0x96: if (packet_len == 14) return ((IPP2P_EDK * 100) + 2);
++	case 0x96: if (packet_len == 14) return ((IPP2P_EDK * 100) + 51);
++			/* e3 94 | size is 30, 50, 70, 90,...*/
++	case 0x94: if ((packet_len-10) % 20 == 0) return ((IPP2P_EDK * 100) + 52);
 +			/* e3 a2 | size == 10 or 14 <-- recheck*/
 +	}
 +    }
@@ -102,43 +107,45 @@
 +    case 0xc5: {	/*emule*/
 +	switch (t[1]) {
 +			/* c5 91 xx yy | size == 12 (8+4) | xx != 0x00  -- xx yy queue rating */
-+	case 0x91: if ((packet_len == 12) && (t[2] != 0x00)) return ((IPP2P_EDK * 100) + 3);
++	case 0x91: if ((packet_len == 12) && (t[2] != 0x00)) return ((IPP2P_EDK * 100) + 53);
 +			/* c5 90 xx ..  yy | size == 26 (8+2+16) | xx .. yy == hash  -- file ping */
-+	case 0x90: if ((packet_len == 26) && (t[2] != 0x00)) return ((IPP2P_EDK * 100) + 4);
++	case 0x90: if ((packet_len == 26) && (t[2] != 0x00)) return ((IPP2P_EDK * 100) + 54);
 +			/* c5 92 | size == 10 (8+2) -- file not found */
-+	case 0x92: if (packet_len == 10) return ((IPP2P_EDK * 100) + 5);
++	case 0x92: if (packet_len == 10) return ((IPP2P_EDK * 100) + 55);
 +			/* c5 93 | size == 10 (8+2) -- queue full */
-+	case 0x93: if (packet_len == 10) return ((IPP2P_EDK * 100) + 6);
++	case 0x93: if (packet_len == 10) return ((IPP2P_EDK * 100) + 56);
 +	}
 +    }
 +
 +    case 0xe4: {	/*kad*/
 +	switch (t[1]) {
 +			/* e4 50 | size == 12 */
-+	    case 0x50: if (packet_len == 12) return ((IPP2P_EDK * 100) + 7);
++	    case 0x50: if (packet_len == 12) return ((IPP2P_EDK * 100) + 57);
 +			/* e4 58 | size == 14 */
-+	    case 0x58: if ((packet_len == 14) && (t[2] != 0x00)) return ((IPP2P_EDK * 100) + 8);
++	    case 0x58: if ((packet_len == 14) && (t[2] != 0x00)) return ((IPP2P_EDK * 100) + 58);
 +			/* e4 59 | size == 10 */
-+	    case 0x59: if (packet_len == 10) return ((IPP2P_EDK * 100) + 9);
++	    case 0x59: if (packet_len == 10) return ((IPP2P_EDK * 100) + 59);
 +			/* e4 30 .. | t[18] == 0x01 | size > 26 | --> search */
-+	    case 0x30: if ((packet_len > 26) && (t[18] == 0x01)) return ((IPP2P_EDK * 100) + 10);
++	    case 0x30: if ((packet_len > 26) && (t[18] == 0x01)) return ((IPP2P_EDK * 100) + 60);
 +			/* e4 28 .. 00 | t[68] == 0x00 | size > 76 */
-+	    case 0x28: if ((packet_len > 76) && (t[68] == 0x00)) return ((IPP2P_EDK * 100) + 11);
++	    case 0x28: if ((packet_len > 76) && (t[68] == 0x00)) return ((IPP2P_EDK * 100) + 61);
 +			/* e4 20 .. | size == 43 */
-+	    case 0x20: if ((packet_len == 43) && (t[2] != 0x00) && (t[34] != 0x00)) return ((IPP2P_EDK * 100) + 12);
++	    case 0x20: if ((packet_len == 43) && (t[2] != 0x00) && (t[34] != 0x00)) return ((IPP2P_EDK * 100) + 62);
 +			/* e4 00 .. 00 | size == 35 ? */
-+	    case 0x00: if ((packet_len == 35) && (t[26] == 0x00)) return ((IPP2P_EDK * 100) + 13);
++	    case 0x00: if ((packet_len == 35) && (t[26] == 0x00)) return ((IPP2P_EDK * 100) + 63);
 +			/* e4 10 .. 00 | size == 35 ? */
-+	    case 0x10: if ((packet_len == 35) && (t[26] == 0x00)) return ((IPP2P_EDK * 100) + 14);
++	    case 0x10: if ((packet_len == 35) && (t[26] == 0x00)) return ((IPP2P_EDK * 100) + 64);
 +			/* e4 18 .. 00 | size == 35 ? */
-+	    case 0x18: if ((packet_len == 35) && (t[26] == 0x00)) return ((IPP2P_EDK * 100) + 15);
++	    case 0x18: if ((packet_len == 35) && (t[26] == 0x00)) return ((IPP2P_EDK * 100) + 65);
 +			/* e4 40 .. | t[18] == 0x01 | t[19] == 0x00 | size > 40 */
-+	    case 0x40: if ((packet_len > 40) && (t[18] == 0x01) && (t[19] == 0x00)) return ((IPP2P_EDK * 100) + 16);
++	    case 0x40: if ((packet_len > 40) && (t[18] == 0x01) && (t[19] == 0x00)) return ((IPP2P_EDK * 100) + 66);
++	    		/* e4 52 .. | size = 44 */
++	    case 0x52: if (packet_len == 44 )return ((IPP2P_EDK * 100) + 67);
 +	}
 +    }
-+    
-+    default: return 0;
 +    } /* end of switch (t[0]) */
++    
++    return 0;
 +}/*udp_search_edk*/
 +
 +
@@ -149,8 +156,8 @@
 +    unsigned char *t = haystack;
 +    t += 8;
 +    
-+    if (memcmp(t, "GND", 3) == 0) return ((IPP2P_GNU * 100) + 1);
-+    if (memcmp(t, "GNUTELLA ", 9) == 0) return ((IPP2P_GNU * 100) + 2);
++    if (memcmp(t, "GND", 3) == 0) return ((IPP2P_GNU * 100) + 51);
++    if (memcmp(t, "GNUTELLA ", 9) == 0) return ((IPP2P_GNU * 100) + 52);
 +    return 0;
 +}/*udp_search_gnu*/
 +
@@ -163,41 +170,124 @@
 +    
 +    if (t[packet_len-1] == 0x00){
 +	t += (packet_len - 6);
-+	if (memcmp(t, "KaZaA", 5) == 0) return (IPP2P_KAZAA * 100);
++	if (memcmp(t, "KaZaA", 5) == 0) return (IPP2P_KAZAA * 100 +50);
 +    }
++    
 +    return 0;
 +}/*udp_search_kazaa*/
 +
-+
-+/*Search for UDP BitTorrent commands*/
++/*Search for UDP DirectConnect commands*/
 +int
-+udp_search_bit (unsigned char *haystack, int packet_len)
++udp_search_directconnect (unsigned char *haystack, int packet_len)
 +{
 +    unsigned char *t = haystack;
-+    
-+    /* packet_len has to be 24 */
-+    if (packet_len != 24) return 0;
++    if ((*(t + 8) == 0x24) && (*(t + packet_len - 1) == 0x7c)) {
++    	t+=8;
++    	if (memcmp(t, "SR ", 3) == 0)	 		return ((IPP2P_DC * 100) + 60);
++    	if (memcmp(t, "Ping ", 5) == 0)	 		return ((IPP2P_DC * 100) + 61);
++    }
++    return 0;
++}/*udp_search_directconnect*/
 +
-+    t += 8;    
 +
-+    /* ^ 00 00 04 17 27 10 19 80 */
-+    if ((ntohl(get_u32(t, 0)) == 0x00000417) && (ntohl(get_u32(t, 4)) == 0x27101980)) return (IPP2P_BIT * 100);
 +
++/*Search for UDP BitTorrent commands*/
++int
++udp_search_bit (unsigned char *haystack, int packet_len)
++{
++    switch(packet_len)
++    {
++	case 24:
++		/* ^ 00 00 04 17 27 10 19 80 */
++		if ((ntohl(get_u32(haystack, 8)) == 0x00000417) && (ntohl(get_u32(haystack, 12)) == 0x27101980)) 
++			return (IPP2P_BIT * 100 + 50);
++		break;
++	case 44:
++		if (get_u32(haystack, 16) == __constant_htonl(0x00000400) && get_u32(haystack, 36) == __constant_htonl(0x00000104)) 
++			return (IPP2P_BIT * 100 + 51);
++		if (get_u32(haystack, 16) == __constant_htonl(0x00000400))
++			return (IPP2P_BIT * 100 + 61);
++		break;
++	case 65:
++		if (get_u32(haystack, 16) == __constant_htonl(0x00000404) && get_u32(haystack, 36) == __constant_htonl(0x00000104)) 
++			return (IPP2P_BIT * 100 + 52);
++		if (get_u32(haystack, 16) == __constant_htonl(0x00000404))
++			return (IPP2P_BIT * 100 + 62);
++		break;
++	case 67:
++		if (get_u32(haystack, 16) == __constant_htonl(0x00000406) && get_u32(haystack, 36) == __constant_htonl(0x00000104)) 
++			return (IPP2P_BIT * 100 + 53);
++		if (get_u32(haystack, 16) == __constant_htonl(0x00000406))
++			return (IPP2P_BIT * 100 + 63);
++		break;
++	case 211:
++		if (get_u32(haystack, 8) == __constant_htonl(0x00000405)) 
++			return (IPP2P_BIT * 100 + 54);
++		break;
++	case 29:
++		if ((get_u32(haystack, 8) == __constant_htonl(0x00000401))) 
++			return (IPP2P_BIT * 100 + 55);
++		break;
++	default:
++		/* this packet doe not have a constant size */
++		if (get_u32(haystack, 16) == __constant_htonl(0x00000402) && get_u32(haystack, 36) == __constant_htonl(0x00000104)) 
++			return (IPP2P_BIT * 100 + 56);
++		break;
++    }
++    
++    /* some extra-bitcomet rules:
++     * "d1:" [a|r] "d2:id20:"
++     */
++    if (packet_len > 30 && get_u8(haystack, 8) == 'd' && get_u8(haystack, 9) == '1' && get_u8(haystack, 10) == ':' )
++    {
++    	if (get_u8(haystack, 11) == 'a' || get_u8(haystack, 11) == 'r')
++	{
++		if (memcmp(haystack+12,"d2:id20:",8)==0)
++			return (IPP2P_BIT * 100 + 57);
++	}
++    }
 +    return 0;
 +}/*udp_search_bit*/
 +
 +
 +
 +/*Search for Ares commands*/
++//#define IPP2P_DEBUG_ARES
++
 +int
 +search_ares (unsigned char *haystack, int packet_len, int head_len)
 +{
-+    unsigned char *t = haystack;
-+    t += head_len;
++	const unsigned char *t = haystack + head_len;
++	
++	/* all ares packets start with  */
++	if (t[1] == 0 && (packet_len - head_len - t[0]) == 3)
++	{
++		const u16 size=packet_len - head_len;
++		switch (t[2])
++		{
++			case 0x5a:
++				/* ares connect */
++				if ( size == 6 && t[5] == 0x05 ) return ((IPP2P_ARES * 100) + 1);
++				break;
++			case 0x09:
++				/* ares search, min 3 chars --> 14 bytes
++				 * lets define a search can be up to 30 chars --> max 34 bytes
++				 */
++				if ( size >= 14 && size <= 34 ) return ((IPP2P_ARES * 100) + 1);
++				break;
++#ifdef IPP2P_DEBUG_ARES
++			default:
++			printk(KERN_DEBUG "Unknown Ares command %x recognized, len: %u \n", (unsigned int) t[2],size);
++#endif /* IPP2P_DEBUG_ARES */
++		}
++	}
 +
++#if 0	        
++	/* found connect packet: 03 00 5a 04 03 05 */
++	/* new version ares 1.8: 03 00 5a xx xx 05 */
 +    if ((packet_len - head_len) == 6){	/* possible connect command*/
-+	if ((t[0] == 0x03) && (t[1] == 0x00) && (t[2] == 0x5a) && (t[3] == 0x04) && (t[4] == 0x03) && (t[5] == 0x05))
-+	    return ((IPP2P_ARES * 100) + 1);			/* found connect packet: 03 00 5a 04 03 05 */
++	if ((t[0] == 0x03) && (t[1] == 0x00) && (t[2] == 0x5a) && (t[5] == 0x05))
++	    return ((IPP2P_ARES * 100) + 1);
 +    }
 +    if ((packet_len - head_len) == 60){	/* possible download command*/
 +	if ((t[59] == 0x0a) && (t[58] == 0x0a)){
@@ -205,31 +295,122 @@
 +	    	return ((IPP2P_ARES * 100) + 2);
 +	}
 +    }
++#endif
++
 +    return 0;
 +} /*search_ares*/
 +
-+
 +/*Search for SoulSeek commands*/
 +int
 +search_soul (unsigned char *haystack, int packet_len, int head_len)
 +{
 +    unsigned char *t = haystack;
 +    t += head_len;
++//#define IPP2P_DEBUG_SOUL
++    /* match: xx xx xx xx | xx = sizeof(payload) - 4 */
++    if (get_u32(t, 0) == (packet_len - head_len - 4)){
++	const __u32 m=get_u32(t, 4);
++	/* match 00 yy yy 00, yy can be everything */
++        if ( get_u8(t, 4) == 0x00 && get_u8(t, 7) == 0x00 )
++	{
++#ifdef IPP2P_DEBUG_SOUL
++	printk(KERN_DEBUG "0: Soulseek command 0x%x recognized\n",get_u32(t, 4));
++#endif /* IPP2P_DEBUG_SOUL */
++		return ((IPP2P_SOUL * 100) + 1);
++	}
++	
++        /* next match: 01 yy 00 00 | yy can be everything */
++        if ( get_u8(t, 4) == 0x01 && get_u16(t, 6) == 0x0000 )
++	{
++#ifdef IPP2P_DEBUG_SOUL
++	printk(KERN_DEBUG "1: Soulseek command 0x%x recognized\n",get_u16(t, 4));
++#endif /* IPP2P_DEBUG_SOUL */
++		return ((IPP2P_SOUL * 100) + 2);
++	}
++	
++	/* other soulseek commandos are: 1-5,7,9,13-18,22,23,26,28,35-37,40-46,50,51,60,62-69,91,92,1001 */
++	/* try to do this in an intelligent way */
++	/* get all small commandos */
++	switch(m)
++	{
++		case 7:
++		case 9:
++		case 22:
++		case 23:
++		case 26:
++		case 28:
++		case 50:
++		case 51:
++		case 60:
++		case 91:
++		case 92:
++		case 1001:
++#ifdef IPP2P_DEBUG_SOUL
++		printk(KERN_DEBUG "2: Soulseek command 0x%x recognized\n",get_u16(t, 4));
++#endif /* IPP2P_DEBUG_SOUL */
++		return ((IPP2P_SOUL * 100) + 3);
++	}
++	
++	if (m > 0 && m < 6 ) 
++	{
++#ifdef IPP2P_DEBUG_SOUL
++		printk(KERN_DEBUG "3: Soulseek command 0x%x recognized\n",get_u16(t, 4));
++#endif /* IPP2P_DEBUG_SOUL */
++		return ((IPP2P_SOUL * 100) + 4);
++	}
++	if (m > 12 && m < 19 )
++	{
++#ifdef IPP2P_DEBUG_SOUL
++		printk(KERN_DEBUG "4: Soulseek command 0x%x recognized\n",get_u16(t, 4));
++#endif /* IPP2P_DEBUG_SOUL */
++		return ((IPP2P_SOUL * 100) + 5);
++	}
++
++	if (m > 34 && m < 38 )
++	{
++#ifdef IPP2P_DEBUG_SOUL
++		printk(KERN_DEBUG "5: Soulseek command 0x%x recognized\n",get_u16(t, 4));
++#endif /* IPP2P_DEBUG_SOUL */
++		return ((IPP2P_SOUL * 100) + 6);
++	}
++
++	if (m > 39 && m < 47 )
++	{
++#ifdef IPP2P_DEBUG_SOUL
++		printk(KERN_DEBUG "6: Soulseek command 0x%x recognized\n",get_u16(t, 4));
++#endif /* IPP2P_DEBUG_SOUL */
++		return ((IPP2P_SOUL * 100) + 7);
++	}
 +
-+    if (get_u16(t, 0) == (packet_len - head_len - 4)){
-+	    /* xx xx 00 00 yy zz 00 00 .. | xx = sizeof(payload) - 4 */
-+	if ((get_u16(t,2) == 0x0000) &&(t[4] != 0x00) && (get_u16(t,6) == 0x0000))
-+	    return ((IPP2P_SOUL * 100) + 1);
-+    } else {
-+	    /* 00 00 00 00 00 00 00 00 + sizeof(payload) == 8*/
-+	if (((packet_len - head_len) == 8) && (get_u32(t, 0) == 0x00000000) && (get_u32(t, 4) == 0x00000000))
-+	    return ((IPP2P_SOUL * 100) + 2);
++	if (m > 61 && m < 70 ) 
++	{
++#ifdef IPP2P_DEBUG_SOUL
++		printk(KERN_DEBUG "7: Soulseek command 0x%x recognized\n",get_u16(t, 4));
++#endif /* IPP2P_DEBUG_SOUL */
++		return ((IPP2P_SOUL * 100) + 8);
++	}
++
++#ifdef IPP2P_DEBUG_SOUL
++	printk(KERN_DEBUG "unknown SOULSEEK command: 0x%x, first 16 bit: 0x%x, first 8 bit: 0x%x ,soulseek ???\n",get_u32(t, 4),get_u16(t, 4) >> 16,get_u8(t, 4) >> 24);
++#endif /* IPP2P_DEBUG_SOUL */
 +    }
-+    
-+    /* 01 xx 00 00 00 yy .. zz 00 00 00 .. | xx == sizeof(nick) | yy .. zz == nick */
-+    if ((t[0] == 0x01) && (t[2] == 0x00) && (get_u16(t,3) == 0x0000) && ((packet_len - head_len) > ((get_u8(t,1))+6)) && 
-+	(t[(get_u8(t,1))+4] != 0x00) && (t[(get_u8(t,1))+5] == 0x01) && (t[(get_u8(t,1))+6] == 0x00))
-+	    return ((IPP2P_SOUL * 100) + 3);
++	
++	/* match 14 00 00 00 01 yy 00 00 00 STRING(YY) 01 00 00 00 00 46|50 00 00 00 00 */
++	/* without size at the beginning !!! */
++	if ( get_u32(t, 0) == 0x14 && get_u8(t, 4) == 0x01 )
++	{
++		__u32 y=get_u32(t, 5);
++		/* we need 19 chars + string */
++		if ( (y + 19) <= (packet_len - head_len) )
++		{
++			__u8 *w=t+9+y;
++			if (get_u32(w, 0) == 0x01 && ( get_u16(w, 4) == 0x4600 || get_u16(w, 4) == 0x5000) && get_u32(w, 6) == 0x00);
++#ifdef IPP2P_DEBUG_SOUL
++	    		printk(KERN_DEBUG "Soulssek special client command recognized\n");
++#endif /* IPP2P_DEBUG_SOUL */
++	    		return ((IPP2P_SOUL * 100) + 9);
++		}
++	}
 +    return 0;
 +}
 +
@@ -284,13 +465,25 @@
 +int
 +search_bittorrent (unsigned char *haystack, int packet_len, int head_len)
 +{
-+
-+    unsigned char *t = haystack;
-+    if (*(haystack+head_len) != 0x13) return 0; /*Bail out of first byte != 0x13*/
-+    
-+    t += head_len + 1;
++    const unsigned char *t = haystack+head_len;
 +    
-+    if (memcmp(t, "BitTorrent protocol", 19) == 0) return (IPP2P_BIT * 100);
++    /* test for match 0x13+"BitTorrent protocol" */
++    if (t[0] == 0x13) 
++    {
++        if (memcmp(t+1, "BitTorrent protocol", 19) == 0) return (IPP2P_BIT * 100);
++    }
++    
++    /* get tracker commandos, all starts with GET /
++     * then it can follow: scrape| announce
++     * and then ?hash_info=
++     */
++    if (memcmp(t,"GET /",5) == 0)
++    {
++	/* message scrape */
++	if ( memcmp(t+5,"scrape?info_hash=",17)==0 ) return (IPP2P_BIT * 100 + 1);
++	/* message announce */
++	if ( memcmp(t+5,"announce?info_hash=",19)==0 ) return (IPP2P_BIT * 100 + 2);
++    }
 +    return 0;
 +}
 +
@@ -348,9 +541,9 @@
 +	t += 8;
 +	while (c < packet_len - 22) {
 +	    if ((t[0] == 0x0d) && (t[1] == 0x0a)) {
-+		    if ((memcmp(t, "X-Gnutella-", 11) == 0) || (memcmp(t, "X-Queue:", 8) == 0)) return ((IPP2P_GNU * 100) + 3);
 +		    t += 2;
 +		    c += 2;
++		    if ((memcmp(t, "X-Gnutella-", 11) == 0) || (memcmp(t, "X-Queue:", 8) == 0)) return ((IPP2P_GNU * 100) + 3);
 +	    } else {
 +		t++;
 +		c++;
@@ -367,7 +560,7 @@
 +{
 +    unsigned char *t = haystack;
 +    int c;    
-+
++    
 +    if (!((*(haystack + packet_len - 2) == 0x0d) && (*(haystack + packet_len - 1) == 0x0a))) return 0;
 +
 +    t += head_len;
@@ -378,16 +571,16 @@
 +	t += 8;
 +	while (c < packet_len - 22) {
 +	    if ((t[0] == 0x0d) && (t[1] == 0x0a)) {
-+    		    if ( memcmp(t, "X-Kazaa-Username: ", 18) == 0 ) return ((IPP2P_KAZAA * 100) + 2);	    
 +		    t += 2;
 +		    c += 2;
++		    if ( memcmp(t, "X-Kazaa-Username: ", 18) == 0 ) return ((IPP2P_KAZAA * 100) + 2);
++		    if ( memcmp(t, "User-Agent: PeerEnabler/", 24) == 0 ) return ((IPP2P_KAZAA * 100) + 3);
 +	    } else {
 +		t++;
 +		c++;
 +	    }    
 +	}
 +    }
-+    
 +    return 0;
 +}
 +
@@ -413,7 +606,9 @@
 +{
 +    unsigned char *t = haystack;
 +    int cmd;
-+    
++
++// this stuff almost matches nothing
++#if 0    
 +    if (*(haystack+head_len) == 0xd4) {
 +	t += head_len;	
 +	cmd = get_u16(t, 1);	
@@ -452,7 +647,7 @@
 +	
 +	return 0;
 +    }
-+
++#endif
 +
 +    if (*(haystack+head_len) != 0xe3) 
 +	return 0;
@@ -462,43 +657,43 @@
 +	if (cmd == (packet_len - head_len - 5)) {
 +	    switch (t[5]) {
 +		case 0x01: return ((IPP2P_EDK * 100) + 1);	/*Client: hello or Server:hello*/
-+		case 0x50: return ((IPP2P_EDK * 100) + 2);	/*Client: file status*/
-+		case 0x16: return ((IPP2P_EDK * 100) + 3);	/*Client: search*/
-+		case 0x58: return ((IPP2P_EDK * 100) + 4);	/*Client: file request*/
-+		case 0x48: return ((IPP2P_EDK * 100) + 5);	/*???*/
-+		case 0x54: return ((IPP2P_EDK * 100) + 6);	/*???*/
-+		case 0x47: return ((IPP2P_EDK * 100) + 7);	/*Client: file segment request*/
-+		case 0x46: return ((IPP2P_EDK * 100) + 8); /*Client: download segment*/
++//		case 0x50: return ((IPP2P_EDK * 100) + 2);	/*Client: file status*/
++//		case 0x16: return ((IPP2P_EDK * 100) + 3);	/*Client: search*/
++//		case 0x58: return ((IPP2P_EDK * 100) + 4);	/*Client: file request*/
++//		case 0x48: return ((IPP2P_EDK * 100) + 5);	/*???*/
++//		case 0x54: return ((IPP2P_EDK * 100) + 6);	/*???*/
++//		case 0x47: return ((IPP2P_EDK * 100) + 7);	/*Client: file segment request*/
++//		case 0x46: return ((IPP2P_EDK * 100) + 8); 	/*Client: download segment*/
 +		case 0x4c: return ((IPP2P_EDK * 100) + 9);	/*Client: Hello-Answer*/
-+		case 0x4f: return ((IPP2P_EDK * 100) + 10);	/*Client: file status request*/
-+		case 0x59: return ((IPP2P_EDK * 100) + 11);	/*Client: file request answer*/
-+		case 0x65: return ((IPP2P_EDK * 100) + 12);	/*Client: ???*/
-+		case 0x66: return ((IPP2P_EDK * 100) + 13);	/*Client: ???*/
-+		case 0x51: return ((IPP2P_EDK * 100) + 14);	/*Client: ???*/
-+		case 0x52: return ((IPP2P_EDK * 100) + 15);	/*Client: ???*/
-+		case 0x4d: return ((IPP2P_EDK * 100) + 16);	/*Client: ???*/
-+		case 0x5c: return ((IPP2P_EDK * 100) + 17);	/*Client: ???*/
-+		case 0x38: return ((IPP2P_EDK * 100) + 18);	/*Client: ???*/
-+		case 0x69: return ((IPP2P_EDK * 100) + 19);	/*Client: ???*/
-+		case 0x19: return ((IPP2P_EDK * 100) + 20);	/*Client: ???*/
-+		case 0x42: return ((IPP2P_EDK * 100) + 21);	/*Client: ???*/
-+		case 0x34: return ((IPP2P_EDK * 100) + 22);	/*Client: ???*/
-+		case 0x94: return ((IPP2P_EDK * 100) + 23);	/*Client: ???*/
-+		case 0x1c: return ((IPP2P_EDK * 100) + 24);	/*Client: ???*/
-+		case 0x6a: return ((IPP2P_EDK * 100) + 25);	/*Client: ???*/
++//		case 0x4f: return ((IPP2P_EDK * 100) + 10);	/*Client: file status request*/
++//		case 0x59: return ((IPP2P_EDK * 100) + 11);	/*Client: file request answer*/
++//		case 0x65: return ((IPP2P_EDK * 100) + 12);	/*Client: ???*/
++//		case 0x66: return ((IPP2P_EDK * 100) + 13);	/*Client: ???*/
++//		case 0x51: return ((IPP2P_EDK * 100) + 14);	/*Client: ???*/
++//		case 0x52: return ((IPP2P_EDK * 100) + 15);	/*Client: ???*/
++//		case 0x4d: return ((IPP2P_EDK * 100) + 16);	/*Client: ???*/
++//		case 0x5c: return ((IPP2P_EDK * 100) + 17);	/*Client: ???*/
++//		case 0x38: return ((IPP2P_EDK * 100) + 18);	/*Client: ???*/
++//		case 0x69: return ((IPP2P_EDK * 100) + 19);	/*Client: ???*/
++//		case 0x19: return ((IPP2P_EDK * 100) + 20);	/*Client: ???*/
++//		case 0x42: return ((IPP2P_EDK * 100) + 21);	/*Client: ???*/
++//		case 0x34: return ((IPP2P_EDK * 100) + 22);	/*Client: ???*/
++//		case 0x94: return ((IPP2P_EDK * 100) + 23);	/*Client: ???*/
++//		case 0x1c: return ((IPP2P_EDK * 100) + 24);	/*Client: ???*/
++//		case 0x6a: return ((IPP2P_EDK * 100) + 25);	/*Client: ???*/
 +		default: return 0;
 +	    }
 +	} else {
 +	    if (cmd > packet_len - head_len - 5) {
 +		if ((t[3] == 0x00) && (t[4] == 0x00)) {
 +		    if (t[5] == 0x01) return ((IPP2P_EDK * 100) + 26);
-+		    if (t[5] == 0x4c) return ((IPP2P_EDK * 100) + 27);
++//		    if (t[5] == 0x4c) return ((IPP2P_EDK * 100) + 27);
 +		} 
 +		return 0;
 +		
 +	    }	/*non edk packet*/
-+	    if (t[cmd+5] == 0xe3) return ((IPP2P_EDK * 100) + 28);/*found another edk-command*/
-+	    if (t[cmd+5] == 0xc5) return ((IPP2P_EDK * 100) + 29);/*found an emule-command*/	    
++//	    if (t[cmd+5] == 0xe3) return ((IPP2P_EDK * 100) + 28);/*found another edk-command*/
++//	    if (t[cmd+5] == 0xc5) return ((IPP2P_EDK * 100) + 29);/*found an emule-command*/	    
 +	    return 0;
 +	}
 +    }
@@ -530,14 +725,89 @@
 +{
 +    unsigned char *t = haystack;
 +
-+    if ((*(haystack + head_len) == 0x24) && (*(haystack + packet_len - 1) == 0x7c)) {
++    if ((*(haystack + head_len) == 0x24) && (*(haystack + packet_len - 1) == 0x7c)) 
++    {
 +    	t += head_len + 1;
++	/* Client-Hub-Protocol */
++	if (memcmp(t, "Lock ", 5) == 0)	 		return ((IPP2P_DC * 100) + 1);
++#if 0	
++	if (memcmp(t, "Key ", 4) == 0)			 return ((IPP2P_DC * 100) + 2);
++	if (memcmp(t, "HubName ", 8) == 0) 		return ((IPP2P_DC * 100) + 3);
++	if (memcmp(t, "HubIsFull ", 10) == 0) 		return ((IPP2P_DC * 100) + 4);
++	if (memcmp(t, "ValidateNick ", 13) == 0) 	return ((IPP2P_DC * 100) + 5);
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/linux-2.6-nf-ipp2p.patch?r1=1.1.2.2&r2=1.1.2.3&f=u




More information about the pld-cvs-commit mailing list