X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=dccp2tcp.h;h=d8615c2173e7b6ff7e066aed09f0257e6534f469;hb=5e3bc5722d048a5b9581cbe27c64de5048d444b0;hp=e737a3fb431c1171b8323ad49bac42c2224bd0d9;hpb=afe4574b894da1c172ae694503b323c599bc67dc;p=dccp2tcp diff --git a/dccp2tcp.h b/dccp2tcp.h index e737a3f..d8615c2 100644 --- a/dccp2tcp.h +++ b/dccp2tcp.h @@ -2,7 +2,7 @@ Utility to convert a DCCP flow to a TCP flow for DCCP analysis via tcptrace. -Copyright (C) 2012 Samuel Jero +Copyright (C) 2013 Samuel Jero 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 @@ -18,14 +18,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . Author: Samuel Jero -Date: 11/2012 +Date: 02/2013 Notes: - 1)CCID2 ONLY - 2)DCCP MUST use 48 bit sequence numbers - 3)Checksums are not computed (they are zeroed) - 4)DCCP DATA packets are not implemented (Linux doesn't use them) - 5)DCCP Ack packets show up as TCP packets containing one byte + 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 @@ -53,13 +50,17 @@ Notes: #include #include #include +#include "checksums.h" #define MAX_PACKET 1600 /*Maximum size of TCP packet */ #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{ @@ -69,6 +70,7 @@ struct packet{ 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*/ @@ -79,6 +81,7 @@ struct const_packet{ 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*/ @@ -86,29 +89,40 @@ enum con_state{ INIT, OPEN, CLOSE, + DEAD, + IGNORE, +}; + +/*Connection Types (i.e. CCID)*/ +enum con_type{ + UNKNOWN, + CCID2, + CCID3, }; -/*Host---half of a connection*/ -struct host{ +/*Half Connection structure*/ +struct hcon{ int id_len; /*Length of ID*/ u_char *id; /*Host ID*/ - __be16 port; /*Host DCCP port*/ + 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 host A; /*Host A*/ - struct host B; /*Host B*/ + struct hcon A; /*Host A*/ + struct hcon B; /*Host B*/ }; /*sequence number table structure */ struct tbl{ - __be32 old; /*DCCP sequence number */ + 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*/ @@ -122,7 +136,6 @@ extern int sack; /*add TCP SACKS*/ extern struct connection *chead;/*connection list*/ - /*debug printf * Levels: * 0) Always print even if debug isn't specified @@ -136,10 +149,17 @@ 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, - struct host **fwd, struct host **rev); + 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 host* hst, enum con_state st); +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