Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

peercon.h

Go to the documentation of this file.
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 peercon.h
00020  * @author Daniel Ferullo (ferullo@cmu.edu)
00021  *
00022  * @brief functions to help the peer make a direct connection
00023  */
00024 
00025 #ifndef __PEERCON_H__
00026 #define __PEERCON_H__
00027 
00028 #include "errorcodes.h"
00029 #include "def.h"
00030 #include "peerdef.h"
00031 
00032 /**
00033  * @brief waits until the direct connection flag is set to FLAG_SUCCESS or
00034   *       FLAG_FAILED
00035   *
00036   * @param check_flag pointer to the flag to wait on
00037   *
00038   * @return SUCCESS, errorcode on failure
00039   */
00040 errorcode wait_for_direct_conn(flag_t *check_flag);
00041 
00042 /**
00043  * @brief finds a network devide (requires root privledge)
00044  *
00045  * this is basically a wrapper for pcap_lookupdev.  I assume pcap_lookupdev
00046  * uses malloc to allocate the memory for the returned pointer, but I am
00047  * not sure.  This needs to be checked.
00048  *
00049  * @param dev a pointer to a pointer.  When finished, will point to a string
00050  *        with the network device to use.
00051  *
00052  * @return SUCCESS, neg value on failure
00053  */
00054 errorcode findDevice(char **dev);
00055 
00056 /**
00057  * @brief function to do the SYN flooding to buddy
00058  *
00059  * @param tcp_skeleton a skeleton tcp_packet_info_t to base SYN's on.  The
00060  *         d_addr, d_port, s_addr, and seq_num fields will be inspected.
00061  *
00062  * @param device the device to forge SYNs on
00063  *
00064  * @return SUCCESS, errorcode on failure
00065  */
00066 errorcode flood_syns(tcp_packet_info_t tcp_skeleton, char *device);
00067 
00068 /**
00069  * @brief a function to spawn a thread to look for a SYN/ACK with
00070  *
00071  * @param info pointer to the peer's information structure
00072  *
00073  * @return SUCCESS, errorcode on failure
00074  */
00075 errorcode start_find_synack(peer_conn_info_t *info);
00076 
00077 /** @brief the entry point for the thread that looks for the SYN/ACK in a
00078  *  bday flood
00079  *
00080  * @param arg the single pthread arg (should be a pointer to the peer
00081  * information structure)
00082  *
00083  * @return SUCCESS, errorcode on failure
00084  */
00085 void *run_find_synack(void* arg);
00086 
00087 /**
00088  * @brief waits for the find syn ack to finish, within a timeout, and then
00089  *        joins on the thread.
00090  *
00091  * @param info a pointer to the peer_conn_info_t structure
00092  *
00093  * @return SUCCESS, errorcode on failure
00094  */
00095 errorcode wait_and_join_find_synack(peer_conn_info_t *info);
00096 
00097 /**
00098  * @brief sends a bday flood of synacks to the peer
00099  *
00100  * @param info pointer to the peer_conn_info_t structure
00101  * @param seq_num the sequence number used in the SYNs in the other bday flood
00102  *
00103  * @return SUCCESS, errorcode on failure
00104  */
00105 errorcode synack_flood(peer_conn_info_t *info, seq_num_t seq_num);
00106 
00107 #endif /* __PEERCON_H__ */
00108 

Generated on Wed Mar 30 23:20:47 2005 for NATBLASTER by  doxygen 1.3.9.1