]> sjero.net Git - ltp2tcp/blob - ltp2tcp.h
Initial Commit
[ltp2tcp] / ltp2tcp.h
1 /******************************************************************************
2
3 file: ltp2tcp.h
4
5 Author: Samuel Jero
6
7 Date: 12/2010
8
9 Description:  Header file for LTP 2 TCP Conversion
10
11
12 Special Types Used:
13         1)u_char
14         2)u_int32_t
15 ******************************************************************************/
16 #ifndef _LTP2TCP_H_
17 #define _LTP2TCP_H_
18
19 #include <stdlib.h>
20 #include <stdarg.h>
21 #include <string.h>
22 #include <arpa/inet.h>
23 #include <netinet/tcp.h>
24 #include <pcap.h>
25 #include "ltp.h"
26 #include "encap.h"
27
28
29
30
31 extern int debug;                       /*set to 1 to turn on debugging information, see ltp2tcp.c*/
32 extern int MAX_SESSION;         /* max session size, see ltp2tcp.c*/
33
34
35
36
37 /*session table*/
38 struct session{
39         int             max;            /*max used session*/
40         struct tbl      *table;         /*session table */
41         int             size;           /*session table size */
42 };
43
44 /*session table structure*/
45 struct tbl{
46         int             num;            /*LTP session num */
47         u_int32_t       start;          /*start sequence number*/
48         int                     acked;          /* length of session that has been acked */
49         int                     length;         /* length of session */
50         int                     seq_id;         /*sequential Session id*/
51         struct cl*      a_lst;          /*list of claims*/
52 };
53
54 /*claim structure*/
55 struct cl{
56         struct cl*      next;           /*pointer to next claim*/
57         int             offset;         /*offset for this data piece*/
58         int             length;         /*length of this data peice*/
59 };
60
61 /*converter state*/
62 struct conversion_state{
63         int                             seq_num;        /* Largest TCP sequence Number used*/
64         int                             ack_num;        /* Largest TCP acknowledgment Number used*/
65         int                             win;            /* Largest TCP window used*/
66         int                             started;        /* 1 if we have found any LTP so far, 0 otherwise*/
67         int                                     sender_id;      /* LTP sender ID for this connection*/
68         int                                     seq_ses_id; /* Number of LTP sessions in this connection so far*/
69         struct session          ses;            /* Session Table Structure*/
70         void*                           en_priv;        /* Pointer for Encapsulation data*/
71         struct encap_ops*       en_ops;         /* Pointer to encapsulation operations*/
72         pcap_t*                         in;                     /*libpcap input file discriptor*/
73         pcap_dumper_t*          out;            /*libpcap output file discriptor*/
74         int                                     ses_min;        /*session filtering: low*/
75         int                                     ses_max;        /*session filtering: high*/
76 };
77 struct conversion_state state;
78
79 #define MAX_PACKET      1600            /*Maximum size of TCP packet*/
80 #define WIN_FACTOR      10000           /*Size of TCP window*/
81 #define TBL_SZ          10000           /*Size of Session Table*/
82
83
84
85 /*debug printf
86  * Levels:
87  *      0) Always print even if debug isn't specified
88  *  1) Errors and warnings... Don't overload the screen with too much output
89  *  2) Notes and per-packet processing info... as verbose as needed
90  */
91 void dbgprintf(int level, const char *fmt, ...);
92
93
94 #endif