1 
2 /* tcpsplit
3  * Mark Allman (mallman@icir.org)
4  *
5  * Copyright (c) 2004--2013 International Computer Science Institute
6  *
7  * Permission is hereby granted, free of charge, to any person
8  * obtaining a copy of this software and associated documentation files
9  * (the "Software"), to deal in the Software without restriction,
10  * including without limitation the rights to use, copy, modify, merge,
11  * publish, distribute, sublicense, and/or sell copies of the Software,
12  * and to permit persons to whom the Software is furnished to do so,
13  * subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * The names and trademarks of copyright holders may not be used in
19  * advertising or publicity pertaining to the software without specific
20  * prior permission. Title to copyright in this software and any
21  * associated documentation will at all times remain with the copyright
22  * holders.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
32  */
33 
34 #include <pcap.h>
35 
36 #define FALSE                  0
37 #define TRUE                   1
38 
39 #define MAX_OUTPUT_FILES       256
40 #define HASH_MULTIPLIER        37
41 #define HASH_TBL_SIZE          48611
42 #define EH_SIZE                14
43 #define EH_TYPE_OFFSET         12
44 #define SLASH24                0xffffff00
45 
46 struct pkt_dump_file
47 {
48     pcap_dumper_t *dp;
49     unsigned long pkts;
50 };
51 
52 struct ip_pair
53 {
54     unsigned int ip1, ip2;
55     unsigned short port1, port2;
56     unsigned short file_num;
57     struct ip_pair *next;
58 };
59 
60 /* balancer.c */
61 
62 unsigned short file_for_new_cnn ();
63 
64 /* ipa_db.c */
65 
66 void init_hash_table ();
67 unsigned short get_file_num ();
68 
69 /* tcpsplit.c */
70 
71 extern unsigned short num_files;
72 extern struct pkt_dump_file out_file [];
73 extern unsigned short deterministic;
74