add winpcap 4.0.2 from url http://www.winpcap.org/
[natblaster.git] / src / helper / helperdef.h
blobfc961d7415df8b70e69f508d9658f9ce5788a702
1 /*****************************************************************************
2 * Copyright 2005 Daniel Ferullo *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 *****************************************************************************/
18 /**
19 * @file helperdef.h
20 * @author Daniel Ferullo (ferullo@cmu.edu)
22 * @brief definitions for helper-specific data
24 #ifndef __HELPERDEF_H__
25 #define __HELPERDEF_H__
27 #include "def.h"
29 /**
30 * The timeouts specified below are based on experience on how long it really
31 * takes for natblaster to succeed. They are longer than is probably needed.
32 **/
34 /** @brief the time in seconds to look for buddy info when searching */
35 #define FIND_BUDDY_TIMEOUT 20
37 /** @brief the time in seconds to look for a second connection */
38 #define FIND_CONN2_TIMEOUT 5
40 /** @brief the time in seconds to wait for the buddy port alloc to be set */
41 #define WAIT_FOR_BUDDY_PORT_ALLOC_TIMEOUT 20
43 /** @brief time in seconds to wait for the buddy's external port to be set */
44 #define WAIT_FOR_BUDDY_PORT_KNOWN_TIMEOUT 20
46 /** @brief time in seconds to wait for the buddy's SYN sequence number */
47 #define WAIT_FOR_BUDDY_SEQ_NUM_TIMEOUT 20
49 /** @brief time in seconds to wait for the buddy to send SYN a SYN FLOOD */
50 #define WAIT_FOR_BUDDY_SYN_FLOOD_TIMEOUT 20
52 /** @brief time in seconds to wait for the buddy external port to be set
53 * through use of the birthday paradox */
54 #define WAIT_FOR_BUDDY_BDAY_PORT_TIMEOUT 20
56 /** @brief a structure to hold information about a bday flood */
57 struct bday_helper {
58 /** @brief the sequence number in the SYN packets half of the flood */
59 seq_num_t seq_num;
60 /** @brief a flag indicating if the sequence number has been set */
61 flag_t seq_num_set;
62 /** @brief the port that the successful synack was sent to */
63 port_t port;
64 /** @brief indicates if the port value has been set */
65 flag_t port_set;
66 /** @brief a flag indicating if the bday port prediction failed */
67 flag_t status;
68 } __attribute__((__packed__));
70 /** @brief a typedef for the bday_helper structure */
71 typedef struct bday_helper bday_helper_t;
74 /** @brief a structure to hold the sequence number from a SYN packet */
75 struct buddy_syn_seq_num {
76 /** @brief the sequence number to the buddy */
77 seq_num_t seq_num;
78 /** @brief a flag indicating if the sequence number has been set */
79 flag_t seq_num_set;
80 } __attribute__((__packed__));
82 /** @brief a typedef for teh buddy_syn_seq_num structure */
83 typedef struct buddy_syn_seq_num buddy_syn_seq_num_t;
85 /** @brief structure with all socket descriptors */
86 struct helper_sock_desc {
87 /** @brief the socket used for persistent connection to peer */
88 sock_t peer;
89 }__attribute__((__packed__));
91 /** @brief typedef for the helper_sock_desc structure */
92 typedef struct helper_sock_desc helper_sock_desc_t;
94 /** @brief structure with all the connection information */
95 struct helper_conn_info {
96 /** @brief the peer info */
97 peer_info_t peer;
98 /** @brief the buddy info */
99 buddy_info_t buddy;
100 /** @brief the socket descriptors */
101 helper_sock_desc_t socks;
102 /** @brief the port allocation method */
103 port_alloc_t port_alloc;
104 /** @brief the sequence number to buddy */
105 buddy_syn_seq_num_t buddy_syn;
106 /** @brief information about a bday attempt */
107 bday_helper_t bday;
108 } __attribute__((__packed__));
110 /** @brief typedef for teh helper_conn_info structure */
111 typedef struct helper_conn_info helper_conn_info_t;
113 /** @brief structure to hold observed connection data */
114 struct observed_data {
115 /** @brief the peer's ip */
116 ip_t ip;
117 /** @brief the peer's port */
118 port_t port;
119 } __attribute__((__packed__));
121 /** @brief typedef for the observed_data structure */
122 typedef struct observed_data observed_data_t;
124 #endif /* __HELPERDEF_H__ */