X-Git-Url: http://sjero.net/git/?p=dccp2tcp;a=blobdiff_plain;f=dccp2tcp.h;h=64c8dd29ba09067c5105c54cd0da75c9d9d2b3fc;hp=6c08d2839d51372711a5f544cb8039066a898811;hb=55c388bacaff0cff07ddebc423a16c7d728acba3;hpb=57e13b610191569ac7812bd308e38a859ea2ffc7 diff --git a/dccp2tcp.h b/dccp2tcp.h index 6c08d28..64c8dd2 100644 --- a/dccp2tcp.h +++ b/dccp2tcp.h @@ -1,19 +1,18 @@ /****************************************************************************** Author: Samuel Jero -Date: 2/2011 +Date: 7/2011 Description: Header file for program to convert a DCCP flow to a TCP flow for DCCP analysis via tcptrace. Notes: - 1)Supports only a single DCCP contection per capture - 2)Source Port!=Destination Port - 3)DCCP MUST use 48 bit sequence numbers - 4)Checksums are not computed (they are zeroed) - 5)Only implements those packet types normally used in a session - 6)DCCP Ack packets show up as TCP packets containing one byte - 7)Very little error checking of packet headers + 1)CCID2 ONLY + 2)DCCP MUST use 48 bit sequence numbers + 3)Checksums are not computed (they are zeroed) + 4)Only implements those packet types normally used in a session + 5)DCCP Ack packets show up as TCP packets containing one byte + 6)Very little error checking of packet headers ******************************************************************************/ #ifndef _DCCP2TCP_H #define _DCCP2TCP_H @@ -44,35 +43,68 @@ Notes: #define MAX_PACKET 1600 /*Maximum size of TCP packet */ -#define TBL_SZ 10000 /*Size of Sequence Number Table*/ +#define TBL_SZ 40000 /*Size of Sequence Number Table*/ -/*sequence number structure--one per side of the connection */ -struct seq_num{ - int cur; /*current sequence number */ - __be16 addr; /*connection half id---source port */ - struct tbl *table; /*sequence number table */ - int size; /*sequence number table size */ + +/*Packet structure*/ +struct packet{ + struct pcap_pkthdr *h; /*libpcap header*/ + u_char *data; /*Packet Data*/ + int length; /*Packet length*/ + uint32_t src_id; /*Source ID of packet*/ + uint32_t dest_id; /*Destination ID of packet*/ +}; + +/*Constant Packet structure*/ +struct const_packet{ + const struct pcap_pkthdr *h; /*libpcap header*/ + const u_char *data; /*Packet Data*/ + int length; /*Packet length*/ + uint32_t src_id; /*Source ID of packet*/ + uint32_t dest_id;/*Destination ID of packet*/ +}; + +/*Connection states*/ +enum con_state{ + INIT, + OPEN, + CLOSE, +}; + +/*Host---half of a connection*/ +struct host{ + uint32_t id; /*Host ID*/ + __be16 port; /*Host DCCP port*/ + struct tbl *table; /*Host Sequence Number Table*/ + int size; /*Size of Sequence Number Table*/ + int cur; /*Current TCP Sequence Number*/ + enum con_state state; /*Connection state*/ +}; + +/*Connection structure*/ +struct connection{ + struct connection *next; /*List pointer*/ + struct host A; /*Host A*/ + struct host B; /*Host B*/ }; /*sequence number table structure */ struct tbl{ - __be32 old; /*DCCP sequence number */ - u_int32_t new; /*TCP sequence number */ - int size; /*packet size*/ - enum dccp_pkt_type type; /*packet type*/ + __be32 old; /*DCCP sequence number */ + u_int32_t new; /*TCP sequence number */ + int size; /*packet size*/ + enum dccp_pkt_type type; /*packet type*/ }; /*Option flags*/ extern int debug; /*set to 1 to turn on debugging information*/ -extern int yellow; /*tcptrace yellow line as currently acked packet*/ +extern int yellow; /*tcptrace yellow line as currently acked packet*/ extern int green; /*tcptrace green line as currently acked packet*/ extern int sack; /*add TCP SACKS*/ -/*Half Connection Structures*/ -extern struct seq_num *s1; /*sequence number structure for side one of connection*/ -extern struct seq_num *s2; /*sequence number structure for side two of connection*/ +extern struct connection *chead;/*connection list*/ /*debug printf @@ -83,5 +115,13 @@ extern struct seq_num *s2; /*sequence number structure for side two of connectio */ void dbgprintf(int level, const char *fmt, ...); +/*Function to parse encapsulation*/ +int do_encap(int link, struct packet *new, const struct const_packet *old); + +/*Connection functions*/ +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 *add_connection(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port); +int update_state(struct host* hst, enum con_state st); +void cleanup_connections(); #endif