1 /******************************************************************************
2 Utility to convert a DCCP flow to a TCP flow for DCCP analysis via
3 tcptrace. Functions for differentiating different DCCP connections.
5 Copyright (C) 2012 Samuel Jero <sj323707@ohio.edu>
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 Author: Samuel Jero <sj323707@ohio.edu>
25 2)DCCP MUST use 48 bit sequence numbers
26 3)Checksums are not computed (they are zeroed)
27 4)DCCP DATA packets are not implemented (Linux doesn't use them)
28 5)DCCP Ack packets show up as TCP packets containing one byte
29 ******************************************************************************/
32 /*Lookup a connection. If it doesn't exist, add a new connection and return it.*/
33 int get_host(u_char *src_id, u_char* dest_id, int id_len, int src_port, int dest_port,
34 struct host **fwd, struct host **rev){
35 struct connection *ptr;
39 if(add_connection(src_id, dest_id, id_len, src_port, dest_port)==NULL){
47 /*Loop list looking for connection*/
50 if(memcmp(ptr->A.id,src_id,id_len)==0 && ptr->A.port==src_port &&
51 !(ptr->A.state==CLOSE && ptr->B.state==CLOSE)){
56 if(memcmp(ptr->B.id,src_id,id_len)==0 && ptr->B.port==src_port &&
57 !(ptr->B.state==CLOSE && ptr->A.state==CLOSE)){
65 /*Add new connection*/
66 ptr=add_connection(src_id, dest_id, id_len, src_port, dest_port);
75 /*Add a connection. Return it. On failure, return NULL*/
76 struct connection *add_connection(u_char *src_id, u_char* dest_id, int id_len, int src_port, int dest_port){
77 struct connection *ptr;
78 struct connection *prev;
82 ptr=chead=malloc(sizeof(struct connection));
90 ptr=prev->next=malloc(sizeof(struct connection));
94 dbgprintf(0,"Error: Couldn't allocate Memory\n");
99 ptr->A.id=malloc(id_len);
100 ptr->B.id=malloc(id_len);
101 if(ptr->A.id==NULL||ptr->B.id==NULL){
102 dbgprintf(0,"Error: Couldn't allocate Memory\n");
105 memcpy(ptr->A.id,src_id,id_len);
106 ptr->A.port=src_port;
108 memcpy(ptr->B.id,dest_id,id_len);
109 ptr->B.port=dest_port;
115 /*Update the state on a host*/
116 int update_state(struct host* hst, enum con_state st){
124 /*Free all connections*/
125 void cleanup_connections(){
126 struct connection *ptr;
127 struct connection *prev;