X-Git-Url: http://sjero.net/git/?p=dccp2tcp;a=blobdiff_plain;f=connections.c;h=b5eb11287c71bfea62b3d9fdc7437badd177f47b;hp=511692fc48ecca9cfc9049c5236c76888fae69cf;hb=1bbfe6080ec64a1d292d863935dc18fec3c6373f;hpb=62022bc31bf0909a04349bd05aedc5546f6d0550 diff --git a/connections.c b/connections.c index 511692f..b5eb112 100644 --- a/connections.c +++ b/connections.c @@ -9,7 +9,7 @@ Description: Functions for differentiating different DCCP connections. #include "dccp2tcp.h" /*Lookup a connection. If it doesn't exist, add a new connection and return it.*/ -int get_host(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port, struct host *fwd, struct host *rev){ +int get_host(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port, struct host **fwd, struct host **rev){ struct connection *ptr; /*Empty list*/ @@ -17,8 +17,8 @@ int get_host(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port, str if(add_connection(src_id, dest_id, src_port, dest_port)==NULL){ return 1; } - fwd=&chead->A; - rev=&chead->B; + *fwd=&chead->A; + *rev=&chead->B; return 0; } @@ -26,13 +26,13 @@ int get_host(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port, str ptr=chead; while(ptr!=NULL){ if(ptr->A.id==src_id && ptr->A.port==src_port && ptr->A.state!=CLOSE){ - fwd=&ptr->A; - rev=&ptr->B; + *fwd=&ptr->A; + *rev=&ptr->B; return 0; } if(ptr->B.id==src_id && ptr->B.port==src_port && ptr->B.state!=CLOSE){ - fwd=&ptr->B; - rev=&ptr->A; + *fwd=&ptr->B; + *rev=&ptr->A; return 0; } ptr=ptr->next; @@ -43,8 +43,8 @@ int get_host(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port, str if(ptr==NULL){ return 1; } - fwd=&ptr->A; - rev=&ptr->B; + *fwd=&ptr->A; + *rev=&ptr->B; return 0; } @@ -54,7 +54,7 @@ struct connection *add_connection(uint32_t src_id, uint32_t dest_id, int src_por struct connection *prev; /*Allocate memory*/ - if(chead){ + if(chead==NULL){ ptr=chead=malloc(sizeof(struct connection)); }else{ ptr=chead; @@ -73,6 +73,7 @@ struct connection *add_connection(uint32_t src_id, uint32_t dest_id, int src_por /*Initialize*/ ptr->A.id=src_id; + ptr->A.port=src_port; ptr->A.state=INIT; ptr->B.id=dest_id; ptr->B.port=dest_port;