Commit dff08246 authored by 's avatar
Browse files

Changes to avoid duplicate tracking


git-svn-id: file:///home/svn/mapi/trunk@572 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 200556e4
......@@ -47,23 +47,23 @@ struct list{
};
#define HASHTABLESIZE 1024
/*
int isEdonkey(int, char);
unsigned int getSize(char *);
*/
struct mapid_edonkey {
int *shift[1];
int *skip[1];
struct list **edonkeylist;
};
/*
struct edonkey_header
{
char protocol;
char size[4];
char type;
};
*/
char edonkey_string[] = "\x03\x02\x00\x70\x72\x01\x00\x00\x00";
int isEdonkeyString(mapidflib_function_instance_t *instance, unsigned char *pkt, unsigned int len);
......
#ifndef __EDONKEY_H__
#define __EDONKEY_H__
unsigned int getSize(char *p);
int isEdonkey(int proto, char c);
struct edonkey_header {
char protocol;
char size[4];
char type;
};
/* Definitions for EDONKEY protocols */
#define EDONKEY_PROTO_EDONKEY 0xe3 /* eDonkey */
#define EDONKEY_PROTO_EMULE_EXT 0xc5 /* eMule extensions */
......@@ -163,3 +176,5 @@
/* EDONKEY SEARCH MIN/MAX */
#define EDONKEY_SEARCH_MIN 0x01
#define EDONKEY_SEARCH_MAX 0x02
#endif
......@@ -36,6 +36,7 @@
#include "log.h"
#include "tracklib.h"
#include "edonkey.h"
struct filters {
int protocol;
......@@ -146,12 +147,17 @@ static int torrent_process(mapidflib_function_instance_t *instance,
uint16_t sp, dp;
unsigned int hashval = 0;
int i = 0;
int ether_len =0 , ip_len = 0, tcp_len = 0, udp_len = 0;
p = pkt;
// lay the Ethernet header struct over the packet data
ep = (struct ether_header *)p;
ether_len = sizeof(struct ether_header);
// skip ethernet header
p += sizeof(struct ether_header);
......@@ -171,6 +177,7 @@ static int torrent_process(mapidflib_function_instance_t *instance,
// IP header struct over the packet data;
iph = (struct iphdr*)p;
ip_len = (iph->ihl & 0xf) * 4;
saddr = *((unsigned int *)&(iph->saddr));
daddr = *((unsigned int *)&(iph->daddr));
......@@ -186,6 +193,7 @@ static int torrent_process(mapidflib_function_instance_t *instance,
if(iph->protocol == 6) // TCP
{
tcph = (struct tcphdr *)p;
tcp_len = tcph->doff * 4;
sp = ntohs(tcph->source);
dp = ntohs(tcph->dest);
......@@ -200,6 +208,7 @@ static int torrent_process(mapidflib_function_instance_t *instance,
else if(iph->protocol == 17) // UDP
{
udph = (struct udphdr *)p;
udp_len = sizeof(struct udphdr);
sp = ntohs(udph->source);
dp = ntohs(udph->dest);
......@@ -217,6 +226,39 @@ static int torrent_process(mapidflib_function_instance_t *instance,
return 0;
}
/* excluding default traffic from other trackers */
if(sp == 4662 || dp == 4662) { // eDonkey
return 0;
}
{
struct edonkey_header *edonkey_h;
if(iph->protocol == 6) {
edonkey_h = (struct edonkey_header *)p;
if(edonkey_h->protocol != (char)0xE3 && edonkey_h->protocol != (char)0xC5 && edonkey_h->protocol != (char)0xd4) {
if(getSize(edonkey_h->size) != (pkt_head->wlen - ether_len - ip_len - tcp_len - 5))
if(isEdonkey(iph->protocol, edonkey_h->type) == 0)
return 0;
}
}
else if(iph->protocol == 17) {
edonkey_h = (struct edonkey_header *)p;
if(edonkey_h->protocol != (char)0xe3 && edonkey_h->protocol != (char)0xC5 && edonkey_h->protocol != (char)0xd4) {
if(getSize(edonkey_h->size) != (pkt_head->caplen - ether_len - ip_len - udp_len - 5))
if(isEdonkey(iph->protocol, edonkey_h->size[0]) == 0)
return 0;
}
}
}
if(sp == 411 || dp == 411) { // DC++
return 0;
}
gettimeofday(&ts, NULL);
for(temp = torlist[hashval]->head, prev = torlist[hashval]->head; temp != NULL; prev = temp, temp = temp->next)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment