1 /******************************************************************************
6 Description: Functions for differentiating different DCCP connections.
8 ******************************************************************************/
11 /*Lookup a connection. If it doesn't exist, add a new connection and return it.*/
12 int get_host(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port, struct host **fwd, struct host **rev){
13 struct connection *ptr;
17 if(add_connection(src_id, dest_id, src_port, dest_port)==NULL){
25 /*Loop list looking for connection*/
28 if(ptr->A.id==src_id && ptr->A.port==src_port && ptr->A.state!=CLOSE){
33 if(ptr->B.id==src_id && ptr->B.port==src_port && ptr->B.state!=CLOSE){
41 /*Add new connection*/
42 ptr=add_connection(src_id, dest_id, src_port, dest_port);
51 /*Add a connection. Return it. On failure, return NULL*/
52 struct connection *add_connection(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port){
53 struct connection *ptr;
54 struct connection *prev;
58 ptr=chead=malloc(sizeof(struct connection));
66 ptr=prev->next=malloc(sizeof(struct connection));
70 dbgprintf(0,"Error: Couldn't allocate Memory\n");
79 ptr->B.port=dest_port;
85 /*Update the state on a host*/
86 int update_state(struct host* hst, enum con_state st){