1 /******************************************************************************
2 Utility to convert a LTP flow to a TCP flow for LTP analysis via tcptrace.
4 Copyright (C) 2013 Samuel Jero <sj323707@ohio.edu>
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.
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.
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/>.
19 Author: Samuel Jero <sj323707@ohio.edu>
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
27 2)Uses some special types from Linux (u_char, u_int32_t)
28 ******************************************************************************/
35 #include <arpa/inet.h>
36 #include <netinet/tcp.h>
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*/
52 int max; /*max used session*/
53 struct tbl *table; /*session table */
54 int size; /*session table size */
57 /*session table structure*/
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*/
69 struct cl* next; /*pointer to next claim*/
70 int offset; /*offset for this data piece*/
71 int length; /*length of this data peice*/
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*/
90 struct conversion_state state;
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*/
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
104 void dbgprintf(int level, const char *fmt, ...);