00001 /***************************************************************************** 00002 * Copyright 2005 Daniel Ferullo * 00003 * * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); * 00005 * you may not use this file except in compliance with the License. * 00006 * You may obtain a copy of the License at * 00007 * * 00008 * http://www.apache.org/licenses/LICENSE-2.0 * 00009 * * 00010 * Unless required by applicable law or agreed to in writing, software * 00011 * distributed under the License is distributed on an "AS IS" BASIS, * 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00013 * See the License for the specific language governing permissions and * 00014 * limitations under the License. * 00015 * * 00016 *****************************************************************************/ 00017 00018 /** 00019 * @file helperdef.h 00020 * @author Daniel Ferullo (ferullo@cmu.edu) 00021 * 00022 * @brief definitions for helper-specific data 00023 */ 00024 #ifndef __HELPERDEF_H__ 00025 #define __HELPERDEF_H__ 00026 00027 #include "def.h" 00028 00029 /** 00030 * The timeouts specified below are based on experience on how long it really 00031 * takes for natblaster to succeed. They are longer than is probably needed. 00032 **/ 00033 00034 /** @brief the time in seconds to look for buddy info when searching */ 00035 #define FIND_BUDDY_TIMEOUT 20 00036 00037 /** @brief the time in seconds to look for a second connection */ 00038 #define FIND_CONN2_TIMEOUT 5 00039 00040 /** @brief the time in seconds to wait for the buddy port alloc to be set */ 00041 #define WAIT_FOR_BUDDY_PORT_ALLOC_TIMEOUT 20 00042 00043 /** @brief time in seconds to wait for the buddy's external port to be set */ 00044 #define WAIT_FOR_BUDDY_PORT_KNOWN_TIMEOUT 20 00045 00046 /** @brief time in seconds to wait for the buddy's SYN sequence number */ 00047 #define WAIT_FOR_BUDDY_SEQ_NUM_TIMEOUT 20 00048 00049 /** @brief time in seconds to wait for the buddy to send SYN a SYN FLOOD */ 00050 #define WAIT_FOR_BUDDY_SYN_FLOOD_TIMEOUT 20 00051 00052 /** @brief time in seconds to wait for the buddy external port to be set 00053 * through use of the birthday paradox */ 00054 #define WAIT_FOR_BUDDY_BDAY_PORT_TIMEOUT 20 00055 00056 /** @brief a structure to hold information about a bday flood */ 00057 struct bday_helper { 00058 /** @brief the sequence number in the SYN packets half of the flood */ 00059 seq_num_t seq_num; 00060 /** @brief a flag indicating if the sequence number has been set */ 00061 flag_t seq_num_set; 00062 /** @brief the port that the successful synack was sent to */ 00063 port_t port; 00064 /** @brief indicates if the port value has been set */ 00065 flag_t port_set; 00066 /** @brief a flag indicating if the bday port prediction failed */ 00067 flag_t status; 00068 } __attribute__((__packed__)); 00069 00070 /** @brief a typedef for the bday_helper structure */ 00071 typedef struct bday_helper bday_helper_t; 00072 00073 00074 /** @brief a structure to hold the sequence number from a SYN packet */ 00075 struct buddy_syn_seq_num { 00076 /** @brief the sequence number to the buddy */ 00077 seq_num_t seq_num; 00078 /** @brief a flag indicating if the sequence number has been set */ 00079 flag_t seq_num_set; 00080 } __attribute__((__packed__)); 00081 00082 /** @brief a typedef for teh buddy_syn_seq_num structure */ 00083 typedef struct buddy_syn_seq_num buddy_syn_seq_num_t; 00084 00085 /** @brief structure with all socket descriptors */ 00086 struct helper_sock_desc { 00087 /** @brief the socket used for persistent connection to peer */ 00088 sock_t peer; 00089 }__attribute__((__packed__)); 00090 00091 /** @brief typedef for the helper_sock_desc structure */ 00092 typedef struct helper_sock_desc helper_sock_desc_t; 00093 00094 /** @brief structure with all the connection information */ 00095 struct helper_conn_info { 00096 /** @brief the peer info */ 00097 peer_info_t peer; 00098 /** @brief the buddy info */ 00099 buddy_info_t buddy; 00100 /** @brief the socket descriptors */ 00101 helper_sock_desc_t socks; 00102 /** @brief the port allocation method */ 00103 port_alloc_t port_alloc; 00104 /** @brief the sequence number to buddy */ 00105 buddy_syn_seq_num_t buddy_syn; 00106 /** @brief information about a bday attempt */ 00107 bday_helper_t bday; 00108 } __attribute__((__packed__)); 00109 00110 /** @brief typedef for teh helper_conn_info structure */ 00111 typedef struct helper_conn_info helper_conn_info_t; 00112 00113 /** @brief structure to hold observed connection data */ 00114 struct observed_data { 00115 /** @brief the peer's ip */ 00116 ip_t ip; 00117 /** @brief the peer's port */ 00118 port_t port; 00119 } __attribute__((__packed__)); 00120 00121 /** @brief typedef for the observed_data structure */ 00122 typedef struct observed_data observed_data_t; 00123 00124 #endif /* __HELPERDEF_H__ */ 00125