]> sjero.net Git - dccp2tcp/blob - dccp2tcp.h
Update Changelog, Release Notes, and File Headers for release 1.5
[dccp2tcp] / dccp2tcp.h
1 /******************************************************************************
2 Author: Samuel Jero
3
4 Date: 11/2011
5
6 Description: Header file for program to convert a DCCP flow to a TCP flow for DCCP
7                  analysis via tcptrace.
8
9 Notes:
10         1)CCID2 ONLY
11         2)DCCP MUST use 48 bit sequence numbers
12         3)Checksums are not computed (they are zeroed)
13         4)DCCP DATA packets are not implemented (Linux doesn't use them)
14         5)DCCP Ack packets show up as TCP packets containing one byte
15 ******************************************************************************/
16 #ifndef _DCCP2TCP_H
17 #define _DCCP2TCP_H
18
19 #include <stdarg.h>
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <strings.h>
24 #include <sys/types.h>
25 #include <unistd.h>
26 #include <time.h>
27 #include <sys/time.h>
28 #include <sys/socket.h>
29 #include <net/if.h>
30 #include <netinet/in.h>
31 #include <netinet/in_systm.h>
32 #include <arpa/inet.h>
33 #include <netinet/if_ether.h>
34 #include <netinet/ip.h>
35 #include <netinet/tcp.h>
36 #include <netinet/tcp.h>
37 #include <netinet/udp.h>
38 #include <netdb.h>
39 #include <ctype.h>
40 #include <pcap.h>
41 #include <linux/dccp.h>
42
43
44 #define MAX_PACKET      1600    /*Maximum size of TCP packet */
45 #define TBL_SZ          40000   /*Size of Sequence Number Table*/
46
47
48
49
50 /*Packet structure*/
51 struct packet{
52         struct pcap_pkthdr      *h;             /*libpcap header*/
53         u_char                          *data;  /*Packet Data*/
54         int                                     length; /*Packet length*/
55         uint32_t                        src_id; /*Source ID of packet*/
56         uint32_t                        dest_id; /*Destination ID of packet*/
57 };
58
59 /*Constant Packet structure*/
60 struct const_packet{
61         const struct pcap_pkthdr *h;    /*libpcap header*/
62         const u_char                    *data;  /*Packet Data*/
63         int                                             length; /*Packet length*/
64         uint32_t                                src_id; /*Source ID of packet*/
65         uint32_t                                dest_id;/*Destination ID of packet*/
66 };
67
68 /*Connection states*/
69 enum con_state{
70         INIT,
71         OPEN,
72         CLOSE,
73 };
74
75 /*Host---half of a connection*/
76 struct host{
77         uint32_t                        id;             /*Host ID*/
78         __be16                          port;   /*Host DCCP port*/
79         struct tbl                      *table; /*Host Sequence Number Table*/
80         int                                     size;   /*Size of Sequence Number Table*/
81         int                                     cur;    /*Current TCP Sequence Number*/
82         enum con_state          state;  /*Connection state*/
83 };
84
85 /*Connection structure*/
86 struct connection{
87         struct connection       *next;  /*List pointer*/
88         struct host                     A;              /*Host A*/
89         struct host                     B;              /*Host B*/
90 };
91
92 /*sequence number table structure */
93 struct tbl{
94         __be32                          old;    /*DCCP sequence number */
95         u_int32_t                       new;    /*TCP sequence number */
96         int                                     size;   /*packet size*/
97         enum dccp_pkt_type      type;   /*packet type*/
98 };
99
100 /*Option flags*/
101 extern int debug;               /*set to 1 to turn on debugging information*/
102 extern int yellow;              /*tcptrace yellow line as currently acked packet*/
103 extern int green;               /*tcptrace green line as currently acked packet*/
104 extern int sack;                /*add TCP SACKS*/
105
106 extern struct connection *chead;/*connection list*/
107
108
109 /*debug printf
110  * Levels:
111  *      0) Always print even if debug isn't specified
112  *  1) Errors and warnings... Don't overload the screen with too much output
113  *  2) Notes and per-packet processing info... as verbose as needed
114  */
115 void dbgprintf(int level, const char *fmt, ...);
116
117 /*Function to parse encapsulation*/
118 int do_encap(int link, struct packet *new, const struct const_packet *old);
119
120 /*Connection functions*/
121 int get_host(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port, struct host **fwd, struct host **rev);
122 struct connection *add_connection(uint32_t src_id, uint32_t dest_id, int src_port, int dest_port);
123 int update_state(struct host* hst, enum con_state st);
124 void cleanup_connections();
125
126 #endif