]> sjero.net Git - dccp2tcp/blobdiff - connections.c
Update Changelog, Release Notes, and File Headers for release 1.5
[dccp2tcp] / connections.c
index b5eb11287c71bfea62b3d9fdc7437badd177f47b..0edc451ba60c4209d50eaeaede55c6210a658848 100644 (file)
@@ -1,7 +1,7 @@
 /******************************************************************************
 Author: Samuel Jero
 
-Date: 7/2011
+Date: 11/2011
 
 Description: Functions for differentiating different DCCP connections.
 
@@ -25,12 +25,14 @@ int get_host(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port, str
        /*Loop list looking for connection*/
        ptr=chead;
        while(ptr!=NULL){
-               if(ptr->A.id==src_id && ptr->A.port==src_port && ptr->A.state!=CLOSE){
+               if(ptr->A.id==src_id && ptr->A.port==src_port &&
+                               !(ptr->A.state==CLOSE && ptr->B.state==CLOSE)){
                        *fwd=&ptr->A;
                        *rev=&ptr->B;
                        return 0;
                }
-               if(ptr->B.id==src_id && ptr->B.port==src_port && ptr->B.state!=CLOSE){
+               if(ptr->B.id==src_id && ptr->B.port==src_port &&
+                               !(ptr->B.state==CLOSE && ptr->A.state==CLOSE)){
                        *fwd=&ptr->B;
                        *rev=&ptr->A;
                        return 0;
@@ -90,3 +92,17 @@ int update_state(struct host* hst, enum con_state st){
        hst->state=st;
        return 0;
 }
+
+/*Free all connections*/
+void cleanup_connections(){
+       struct connection *ptr;
+       struct connection *prev;
+       prev=ptr=chead;
+
+       while(ptr!=NULL){
+               prev=ptr;
+               ptr=ptr->next;
+               free(prev);
+       }
+return;
+}