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 peerdef.h 00020 * @author Daniel Ferullo (ferullo@cmu.edu) 00021 * 00022 * @brief definitions for peer-specific data 00023 */ 00024 #ifndef __PEERDEF_H__ 00025 #define __PEERDEF_H__ 00026 00027 #include "def.h" 00028 #include <pcap.h> 00029 #include <pthread.h> 00030 00031 /** @brief macro for the TTL value that is too low to reach the buddy. In a 00032 * complete implementation this value would be auto-detected. Here it is set 00033 * to a known OK value. */ 00034 #define TTL_TOO_LOW 2 00035 00036 /** @brief macro for the TTL value that is high enough to reach the buddy */ 00037 #define TTL_OK 64 00038 00039 /** @brief timeout time in seconds to wait for a direct connection flag */ 00040 #define DIRECT_CONNECTION_TIMEOUT 180 00041 00042 /** @brief the number of SYNs to send in a SYN flood */ 00043 #define SYN_FLOOD_COUNT 502 00044 00045 /** @brief the number of SYN/ACKs to send in a SYN/ACK flood */ 00046 #define SYN_ACK_FLOOD_COUNT 502 00047 00048 /** @brief time in seconds to timeout looking for a SYN/ACK flooded packet */ 00049 #define FIND_SYN_ACK_TIMEOUT 20 00050 00051 /** @brief struture to hold information pertaining to the birthday paradox */ 00052 struct bday_peer { 00053 /** @brief a flag to indicate whether or not to stop looking for 00054 * a synack */ 00055 flag_t stop_synack_find; 00056 /** @brief the port that the synack came in on */ 00057 port_t port; 00058 /** @brief indicates if the port has been set */ 00059 flag_t port_set; 00060 /** @brief the synack has been found, or an error occured */ 00061 flag_t find_synack_done; 00062 /** @brief the thread id of the thread started to find the synack */ 00063 pthread_t find_synack_tid; 00064 } __attribute__((__packed__)); 00065 00066 /** @brief typedef for the bday structure */ 00067 typedef struct bday_peer bday_peer_t; 00068 00069 /** @brief structure with helper connection info */ 00070 struct helper_conn { 00071 /** @brief the port used for the persistent helper connection */ 00072 port_t persistent_port; 00073 /** @brief the port used for the port prediction second connection */ 00074 port_t prediction_port; 00075 } __attribute__((__packed__)); 00076 00077 /** @brief typedef for the helper_conn structure */ 00078 typedef struct helper_conn helper_conn_t; 00079 00080 /** @brief structure with all socket descriptors */ 00081 struct peer_sock_desc { 00082 /** @brief the socket used for persistent connection to helper */ 00083 sock_t helper; 00084 /** @brief the socket used for the pport prediction connection */ 00085 sock_t helper_pred; 00086 /** @brief the socket created for the connection to buddy */ 00087 sock_t buddy; 00088 } __attribute__((__packed__)); 00089 00090 /** @brief typedef for the peer_sock_desc structure */ 00091 typedef struct peer_sock_desc peer_sock_desc_t; 00092 00093 /** @brief structure with all the connection information */ 00094 struct peer_conn_info { 00095 /** @brief the helper info */ 00096 helper_info_t helper; 00097 /** @brief the peer info */ 00098 peer_info_t peer; 00099 /** @brief the buddy info */ 00100 buddy_info_t buddy; 00101 /** @brief the socket descriptors */ 00102 peer_sock_desc_t socks; 00103 /** @brief the helper connection info */ 00104 helper_conn_t helper_conn; 00105 /** @brief the port allocation type */ 00106 port_alloc_t port_alloc; 00107 /** @brief the device to connect on (used for libpcap/libnet) */ 00108 char *device; 00109 /** @brief the syn sent to the buddy */ 00110 tcp_packet_info_t buddy_syn; 00111 /** @brief the syn/ack to send to the buddy */ 00112 tcp_packet_info_t buddy_syn_ack; 00113 /** @brief a flag to indicate if the connection attempt to the buddy 00114 * has failed */ 00115 flag_t direct_conn_status; 00116 /** @brief information about the birthday paradox SYN and SYN/ACK 00117 * floods */ 00118 bday_peer_t bday; 00119 } __attribute__((__packed__)); 00120 00121 /** @brief typedef for the peer_conn_info structure */ 00122 typedef struct peer_conn_info peer_conn_info_t; 00123 00124 #endif /* __PEERDEF_H__ */ 00125