Commit 2e0350e9 authored by 's avatar
Browse files

changed the order in which the checks for each

packet are done


git-svn-id: file:///home/svn/mapi/trunk@284 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 63711a12
......@@ -56,6 +56,8 @@ struct mapid_gnutella {
struct list *gnulist;
};
int isGnutella(mapidflib_function_instance_t *, const unsigned char *, int );
static int gnutella_init(mapidflib_function_instance_t *instance,
MAPI_UNUSED flist_t *flits)
{
......@@ -151,6 +153,26 @@ static int gnutella_process(mapidflib_function_instance_t *instance,
return 0;
}
for(temp = gnulist->head, prev = gnulist->head; temp != NULL; prev = temp, temp = temp->next)
{
if(temp->protocol == iph->protocol &&
(
(temp->saddr == saddr && temp->daddr == daddr && temp->sp == sp && temp->dp == dp)
||
(temp->saddr == daddr && temp->daddr == saddr && temp->sp == dp && temp->dp == sp))
)
{
/* if(tcph->fin)
{
prev->next = temp->next;
temp->next = NULL;
free(temp);
}
*/
return 1;
}
}
if(isGnutella(instance,pkt,len) == 1)
{
new = (struct filters*)malloc(sizeof(struct filters));
......@@ -181,28 +203,6 @@ static int gnutella_process(mapidflib_function_instance_t *instance,
return 1;
}
else
{
for(temp = gnulist->head, prev = gnulist->head; temp != NULL; prev = temp, temp = temp->next)
{
if(temp->protocol == iph->protocol &&
(
(temp->saddr == saddr && temp->daddr == daddr && temp->sp == sp && temp->dp == dp)
||
(temp->saddr == daddr && temp->daddr == saddr && temp->sp == dp && temp->dp == sp))
)
{
/* if(tcph->fin)
{
prev->next = temp->next;
temp->next = NULL;
free(temp);
}
*/
return 1;
}
}
}
return 0;
}
......
......@@ -29,8 +29,8 @@ int main(MAPI_UNUSED int argc, char *argv[])
fid2=mapi_apply_function(fd,"BYTE_COUNTER");
// mapi_apply_function(fd,"TRACK_FTP");
// mapi_apply_function(fd,"TRACK_GNUTELLA");
// mapi_apply_function(fd,"TRACK_TORRENT");
mapi_apply_function(fd,"TRACK_DC");
mapi_apply_function(fd,"TRACK_TORRENT");
// mapi_apply_function(fd,"TRACK_DC");
fid3=mapi_apply_function(fd,"PKT_COUNTER");
fid4=mapi_apply_function(fd,"BYTE_COUNTER");
......
......@@ -50,6 +50,8 @@ struct list{
char *torrent_strings[4]={"BitTorrent protocol","GET /scrape?info_hash=","GET /announce?info_hash=","announce"};
int isTorrent(mapidflib_function_instance_t *, const unsigned char *, int );
struct mapid_torrent {
int *shift[4];
int *skip[4];
......@@ -152,6 +154,26 @@ static int torrent_process(mapidflib_function_instance_t *instance,
return 0;
}
for(temp = torlist->head, prev = torlist->head; temp != NULL; prev = temp, temp = temp->next)
{
if(temp->protocol == iph->protocol &&
(
(temp->saddr == saddr && temp->daddr == daddr && temp->sp == sp && temp->dp == dp)
||
(temp->saddr == daddr && temp->daddr == saddr && temp->sp == dp && temp->dp == sp))
)
{
/* if(tcph->fin)
{
prev->next = temp->next;
temp->next = NULL;
free(temp);
}
*/
return 1;
}
}
if(isTorrent(instance,pkt,len) == 1)
{
new = (struct filters*)malloc(sizeof(struct filters));
......@@ -180,28 +202,6 @@ static int torrent_process(mapidflib_function_instance_t *instance,
return 1;
}
else
{
for(temp = torlist->head, prev = torlist->head; temp != NULL; prev = temp, temp = temp->next)
{
if(temp->protocol == iph->protocol &&
(
(temp->saddr == saddr && temp->daddr == daddr && temp->sp == sp && temp->dp == dp)
||
(temp->saddr == daddr && temp->daddr == saddr && temp->sp == dp && temp->dp == sp))
)
{
/* if(tcph->fin)
{
prev->next = temp->next;
temp->next = NULL;
free(temp);
}
*/
return 1;
}
}
}
return 0;
}
......
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