X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=dccp2tcp.h;h=d8615c2173e7b6ff7e066aed09f0257e6534f469;hb=5e3bc5722d048a5b9581cbe27c64de5048d444b0;hp=e45269191a2db9788bfda85115e03ea986f31e73;hpb=a8f2eb11701914f60decdcd2610e15010dd5a3f4;p=dccp2tcp diff --git a/dccp2tcp.h b/dccp2tcp.h index e452691..d8615c2 100644 --- a/dccp2tcp.h +++ b/dccp2tcp.h @@ -1,19 +1,28 @@ /****************************************************************************** -Author: Samuel Jero +Utility to convert a DCCP flow to a TCP flow for DCCP analysis via + tcptrace. -Date: 1/2011 +Copyright (C) 2013 Samuel Jero -Description: Header file for program to convert a DCCP flow to a TCP flow for DCCP - analysis via tcptrace. +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +Author: Samuel Jero +Date: 02/2013 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)DCCP MUST use 48 bit sequence numbers + 2)DCCP Ack packets show up as TCP packets containing one byte ******************************************************************************/ #ifndef _DCCP2TCP_H #define _DCCP2TCP_H @@ -41,38 +50,91 @@ Notes: #include #include #include +#include "checksums.h" #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*/ + + +#define TRUE 1 +#define FALSE 0 +typedef __be16 dccp_port; +typedef __be32 d_seq_num; + +/*Packet structure*/ +struct packet{ + struct pcap_pkthdr *h; /*libpcap header*/ + u_char *data; /*Packet Data*/ + int length; /*Packet length*/ + int id_len; /*Length of IDs*/ + u_char *src_id; /*Source ID of packet*/ + u_char *dest_id;/*Destination ID of packet*/ + char* (*print_id)(char* buf, int len, u_char* id, int id_len); /*Function to print ID*/ +}; +/*Constant Packet structure*/ +struct const_packet{ + const struct pcap_pkthdr *h; /*libpcap header*/ + const u_char *data; /*Packet Data*/ + int length; /*Packet length*/ + int id_len; /*Length of IDs*/ + u_char *src_id; /*Source ID of packet*/ + u_char *dest_id;/*Destination ID of packet*/ + char* (*print_id)(char* buf, int len, u_char* id, int id_len); /*Function to print ID*/ +}; +/*Connection states*/ +enum con_state{ + INIT, + OPEN, + CLOSE, + DEAD, + IGNORE, +}; -/*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 */ +/*Connection Types (i.e. CCID)*/ +enum con_type{ + UNKNOWN, + CCID2, + CCID3, +}; + +/*Half Connection structure*/ +struct hcon{ + int id_len; /*Length of ID*/ + u_char *id; /*Host ID*/ + dccp_port port; /*Host DCCP port*/ + struct tbl *table; /*Host Sequence Number Table*/ + int size; /*Size of Sequence Number Table*/ + int cur; /*Current TCP Sequence Number*/ + int high_ack;/*Highest ACK seen*/ + enum con_state state; /*Connection state*/ + enum con_type type; /*Connection type*/ +}; + +/*Connection structure*/ +struct connection{ + struct connection *next; /*List pointer*/ + struct hcon A; /*Host A*/ + struct hcon 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*/ + d_seq_num 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 * Levels: @@ -82,5 +144,22 @@ 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(u_char *src_id, u_char* dest_id, int id_len, int src_port, int dest_port, + enum dccp_pkt_type pkt_type, struct hcon **fwd, struct hcon **rev); +struct connection *add_connection(u_char *src_id, u_char* dest_id, int id_len, + int src_port, int dest_port); +int update_state(struct hcon* hst, enum con_state st); +void cleanup_connections(); + +/*Half Connection/Sequence number functions*/ +u_int32_t initialize_hcon(struct hcon *hcn, d_seq_num initial); +u_int32_t add_new_seq(struct hcon *hcn, d_seq_num num, int size, enum dccp_pkt_type type); +u_int32_t convert_ack(struct hcon *hcn, d_seq_num num, struct hcon *o_hcn); +int acked_packet_size(struct hcon *hcn, d_seq_num num); +unsigned int interp_ack_vect(u_char* hdr); #endif