Commit c6f6f6f6 authored by 's avatar
Browse files

timeout added


git-svn-id: file:///home/svn/mapi/trunk@385 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 113d19dd
......@@ -40,6 +40,7 @@ struct filters {
unsigned int daddr;
uint16_t sp;
uint16_t dp;
struct timeval ts;
struct filters *next;
};
......@@ -103,7 +104,8 @@ static int dc_process(mapidflib_function_instance_t *instance,
struct filters *temp = NULL, *prev = NULL, *new = NULL;
int len = pkt_head->caplen;
unsigned char *p = NULL;
struct timeval ts;
struct list *dclist = ((struct mapid_dc*)instance->internal_data)->dclist;
uint16_t ethertype;
struct ether_header *ep = NULL;
......@@ -157,6 +159,8 @@ static int dc_process(mapidflib_function_instance_t *instance,
return 0;
}
gettimeofday(&ts, NULL);
for(temp = dclist->head, prev = dclist->head; temp != NULL; prev = temp, temp = temp->next)
{
if(temp->protocol == iph->protocol &&
......@@ -166,6 +170,8 @@ static int dc_process(mapidflib_function_instance_t *instance,
(temp->saddr == daddr && temp->daddr == saddr && temp->sp == dp && temp->dp == sp))
)
{
gettimeofday(&(temp->ts), NULL);
if(iph->protocol == 6 && tcph->fin) {
if(temp == dclist->head){
dclist->head = temp->next;
......@@ -179,6 +185,16 @@ static int dc_process(mapidflib_function_instance_t *instance,
return 1;
}
else if(ts.tv_sec - temp->ts.tv_sec > 1) {
if(temp == dclist->head){
dclist->head = temp->next;
}
else {
prev->next = temp->next;
}
temp->next = NULL;
free(temp);
}
}
if(isDc(instance,pkt,len) == 1)
......
......@@ -35,6 +35,7 @@ struct filters {
unsigned int daddr;
uint16_t sp;
uint16_t dp;
struct timeval last_timestamp;
struct filters *next;
};
......@@ -236,7 +237,8 @@ static int edonkey_process(mapidflib_function_instance_t *instance,
struct tcphdr *tcph = NULL;
struct udphdr *udph = NULL;
int ether_len =0 , ip_len = 0, tcp_len = 0, udp_len = 0;
struct timeval ts;
struct edonkey_header *edonkey_h;
unsigned int saddr, daddr;
......@@ -289,6 +291,8 @@ static int edonkey_process(mapidflib_function_instance_t *instance,
return 0;
}
gettimeofday(&ts, NULL);
for(temp = edonkeylist->head, prev = edonkeylist->head; temp != NULL; prev = temp, temp = temp->next)
{
if(temp->protocol == iph->protocol &&
......@@ -298,6 +302,8 @@ static int edonkey_process(mapidflib_function_instance_t *instance,
(temp->saddr == daddr && temp->daddr == saddr && temp->sp == dp && temp->dp == sp))
)
{
gettimeofday(&(temp->last_timestamp), NULL);
if(iph->protocol == 6 && tcph->fin) {
if(temp == edonkeylist->head) {
edonkeylist->head = temp->next;
......@@ -311,6 +317,16 @@ static int edonkey_process(mapidflib_function_instance_t *instance,
return 1;
}
else if(ts.tv_sec - temp->last_timestamp.tv_sec > 1) {
if(temp == edonkeylist->head) {
edonkeylist->head = temp->next;
}
else {
prev->next = temp->next;
}
temp->next = NULL;
free(temp);
}
}
if(iph->protocol == 6)
......@@ -365,6 +381,8 @@ static int edonkey_process(mapidflib_function_instance_t *instance,
new->daddr = daddr;
new->sp = sp;
new->dp = dp;
gettimeofday(&(new->last_timestamp), NULL);
/*
for(temp = edonkeylist->head; temp != NULL; temp = temp->next)
{
......
......@@ -40,6 +40,7 @@ struct filters {
unsigned int daddr;
uint16_t sp;
uint16_t dp;
struct timeval ts;
struct filters *next;
};
......@@ -99,7 +100,8 @@ static int gnutella_process(mapidflib_function_instance_t *instance,
struct filters *temp = NULL, *prev = NULL, *new = NULL;
int len = pkt_head->caplen;
unsigned char *p = NULL;
struct timeval ts;
struct list *gnulist = ((struct mapid_gnutella*)instance->internal_data)->gnulist;
uint16_t ethertype;
struct ether_header *ep = NULL;
......@@ -152,6 +154,8 @@ static int gnutella_process(mapidflib_function_instance_t *instance,
return 0;
}
gettimeofday(&ts, NULL);
for(temp = gnulist->head, prev = gnulist->head; temp != NULL; prev = temp, temp = temp->next)
{
if(temp->protocol == iph->protocol &&
......@@ -161,6 +165,8 @@ static int gnutella_process(mapidflib_function_instance_t *instance,
(temp->saddr == daddr && temp->daddr == saddr && temp->sp == dp && temp->dp == sp))
)
{
gettimeofday(&(temp->ts), NULL);
if(iph->protocol == 6 && tcph->fin) {
if(temp == gnulist->head) {
gnulist->head = temp->next;
......@@ -174,6 +180,16 @@ static int gnutella_process(mapidflib_function_instance_t *instance,
return 1;
}
else if(ts.tv_sec - temp->ts.tv_sec > 1) {
if(temp == gnulist->head) {
gnulist->head = temp->next;
}
else {
prev->next = temp->next;
}
temp->next = NULL;
free(temp);
}
}
if(isGnutella(instance,pkt,len) == 1)
......
......@@ -40,6 +40,7 @@ struct filters {
unsigned int daddr;
uint16_t sp;
uint16_t dp;
struct timeval ts;
struct filters *next;
};
......@@ -100,7 +101,8 @@ static int torrent_process(mapidflib_function_instance_t *instance,
struct filters *temp = NULL, *prev = NULL, *new = NULL;
int len = pkt_head->caplen;
unsigned char *p = NULL;
struct timeval ts;
struct list *torlist = ((struct mapid_torrent*)instance->internal_data)->torlist;
uint16_t ethertype;
struct ether_header *ep = NULL;
......@@ -156,6 +158,8 @@ static int torrent_process(mapidflib_function_instance_t *instance,
return 0;
}
gettimeofday(&ts, NULL);
for(temp = torlist->head, prev = torlist->head; temp != NULL; prev = temp, temp = temp->next)
{
if(temp->protocol == iph->protocol &&
......@@ -165,6 +169,8 @@ static int torrent_process(mapidflib_function_instance_t *instance,
(temp->saddr == daddr && temp->daddr == saddr && temp->sp == dp && temp->dp == sp))
)
{
gettimeofday(&(temp->ts), NULL);
if(iph->protocol == 6 && tcph->fin) {
if(temp == torlist->head) {
torlist->head = temp->next;
......@@ -178,6 +184,17 @@ static int torrent_process(mapidflib_function_instance_t *instance,
return 1;
}
else if(ts.tv_sec - temp->ts.tv_sec > 1) {
if(temp == torlist->head) {
torlist->head = temp->next;
}
else {
prev->next = temp->next;
}
temp->next = NULL;
free(temp);
}
}
if(isTorrent(instance,pkt,len) == 1)
......
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