]> sjero.net Git - ltp2tcp/blob - ltp2tcp.h
Checksum Computation!!
[ltp2tcp] / ltp2tcp.h
1 /******************************************************************************
2 Utility to convert a LTP flow to a TCP flow for LTP analysis via tcptrace.
3
4 Copyright (C) 2013  Samuel Jero <sj323707@ohio.edu>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 Author: Samuel Jero <sj323707@ohio.edu>
20 Date: 06/2013
21
22 Notes:
23         1)Only handles one LTP "connection". There isn't a good way to separate
24                 different LTP "connections" from new sessions of the same "connection".
25                 Use Tcpdump filters to separate connections. Libpcap filtering could also
26                 be added in ltp2tcp.
27         2)Uses some special types from Linux (u_char, u_int32_t)
28 ******************************************************************************/
29 #ifndef _LTP2TCP_H_
30 #define _LTP2TCP_H_
31
32 #include <stdlib.h>
33 #include <stdarg.h>
34 #include <string.h>
35 #include <arpa/inet.h>
36 #include <netinet/tcp.h>
37 #include <pcap.h>
38 #include "ltp.h"
39 #include "encap.h"
40
41
42
43
44 extern int debug;                       /*set to 1 to turn on debugging information, see ltp2tcp.c*/
45 extern int MAX_SESSION;         /* max session size, see ltp2tcp.c*/
46
47
48
49
50 /*session table*/
51 struct session{
52         int             max;            /*max used session*/
53         struct tbl      *table;         /*session table */
54         int             size;           /*session table size */
55 };
56
57 /*session table structure*/
58 struct tbl{
59         int             num;            /*LTP session num */
60         u_int32_t       start;          /*start sequence number*/
61         int                     acked;          /* length of session that has been acked */
62         int                     length;         /* length of session */
63         int                     seq_id;         /*sequential Session id*/
64         struct cl*      a_lst;          /*list of claims*/
65 };
66
67 /*claim structure*/
68 struct cl{
69         struct cl*      next;           /*pointer to next claim*/
70         int             offset;         /*offset for this data piece*/
71         int             length;         /*length of this data peice*/
72 };
73
74 /*converter state*/
75 struct conversion_state{
76         int                             seq_num;        /* Largest TCP sequence Number used*/
77         int                             ack_num;        /* Largest TCP acknowledgment Number used*/
78         int                             win;            /* Largest TCP window used*/
79         int                             started;        /* 1 if we have found any LTP so far, 0 otherwise*/
80         int                                     sender_id;      /* LTP sender ID for this connection*/
81         int                                     seq_ses_id; /* Number of LTP sessions in this connection so far*/
82         struct session          ses;            /* Session Table Structure*/
83         void*                           en_priv;        /* Pointer for Encapsulation data*/
84         struct encap_ops*       en_ops;         /* Pointer to encapsulation operations*/
85         pcap_t*                         in;                     /*libpcap input file discriptor*/
86         pcap_dumper_t*          out;            /*libpcap output file discriptor*/
87         int                                     ses_min;        /*session filtering: low*/
88         int                                     ses_max;        /*session filtering: high*/
89 };
90 struct conversion_state state;
91
92 #define MAX_PACKET      1600            /*Maximum size of TCP packet*/
93 #define WIN_FACTOR      10000           /*Size of TCP window*/
94 #define TBL_SZ          10000           /*Size of Session Table*/
95
96
97
98 /*debug printf
99  * Levels:
100  *      0) Always print even if debug isn't specified
101  *  1) Errors and warnings... Don't overload the screen with too much output
102  *  2) Notes and per-packet processing info... as verbose as needed
103  */
104 void dbgprintf(int level, const char *fmt, ...);
105
106
107 #endif