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

peercon.c File Reference

functions to assist the peer in making a direct connection More...

#include "peercon.h"
#include "util.h"
#include "peerdef.h"
#include <time.h>
#include <stdlib.h>
#include "spoof.h"
#include "sniff.h"
#include "debug.h"

Go to the source code of this file.

Functions

errorcode wait_for_direct_conn (flag_t *check_flag)
 waits until the direct connection flag is set to FLAG_SUCCESS or FLAG_FAILED
errorcode findDevice (char **dev)
 finds a network devide (requires root privledge)
errorcode flood_syns (tcp_packet_info_t tcp_skeleton, char *device)
 function to do the SYN flooding to buddy
errorcode start_find_synack (peer_conn_info_t *info)
 a function to spawn a thread to look for a SYN/ACK with
void * run_find_synack (void *arg)
 the entry point for the thread that looks for the SYN/ACK in a bday flood
errorcode wait_and_join_find_synack (peer_conn_info_t *info)
 waits for the find syn ack to finish, within a timeout, and then joins on the thread.
errorcode synack_flood (peer_conn_info_t *info, seq_num_t seq_num)
 sends a bday flood of synacks to the peer


Detailed Description

functions to assist the peer in making a direct connection

Author:
Daniel Ferullo (ferullo@cmu.edu)

Definition in file peercon.c.


Function Documentation

errorcode findDevice char **  dev  ) 
 

finds a network devide (requires root privledge)

this is basically a wrapper for pcap_lookupdev. I assume pcap_lookupdev uses malloc to allocate the memory for the returned pointer, but I am not sure. This needs to be checked.

Parameters:
dev a pointer to a pointer. When finished, will point to a string with the network device to use.
Returns:
SUCCESS, neg value on failure

Definition at line 48 of file peercon.c.

References CHECK_NOT_NULL, ERROR_NULL_ARG_1, and errorcode.

Referenced by natblaster_connect().

errorcode flood_syns tcp_packet_info_t  tcp_skeleton,
char *  device
 

function to do the SYN flooding to buddy

Parameters:
tcp_skeleton a skeleton tcp_packet_info_t to base SYN's on. The d_addr, d_port, s_addr, and seq_num fields will be inspected.
device the device to forge SYNs on
Returns:
SUCCESS, errorcode on failure

Definition at line 65 of file peercon.c.

References tcp_packet_info::ack_flag, tcp_packet_info::ack_num, CHECK_FAILED, CHECK_NOT_NULL, tcp_packet_info::d_port, DBG_BDAY, DBG_PORT, DEBUG, ERROR_CALLED_FUNCTION, ERROR_NULL_ARG_1, errorcode, tcp_packet_info::s_port, spoof(), tcp_packet_info::syn_flag, tcp_packet_info_t, TTL_TOO_LOW, and tcp_packet_info::window.

Referenced by peer_fsm_start_bday().

void* run_find_synack void *  arg  ) 
 

the entry point for the thread that looks for the SYN/ACK in a bday flood

Parameters:
arg the single pthread arg (should be a pointer to the peer information structure)
Returns:
SUCCESS, errorcode on failure

Definition at line 113 of file peercon.c.

References peer_conn_info::bday, capture_flooded_synack(), CHECK_NOT_NULL, ERROR_NULL_ARG_1, errorcode, FAILED, bday_peer::find_synack_done, and peer_conn_info_t.

Referenced by start_find_synack().

errorcode start_find_synack peer_conn_info_t info  ) 
 

a function to spawn a thread to look for a SYN/ACK with

Parameters:
info pointer to the peer's information structure
Returns:
SUCCESS, errorcode on failure

Definition at line 95 of file peercon.c.

References peer_conn_info::bday, CHECK_NOT_NULL, ERROR_NULL_ARG_1, errorcode, bday_peer::find_synack_done, bday_peer::find_synack_tid, peer_conn_info_t, bday_peer::port_set, run_find_synack(), and bday_peer::stop_synack_find.

Referenced by peer_fsm_start_bday().

errorcode synack_flood peer_conn_info_t info,
seq_num_t  seq_num
 

sends a bday flood of synacks to the peer

Parameters:
info pointer to the peer_conn_info_t structure
seq_num the sequence number used in the SYNs in the other bday flood
Returns:
SUCCESS, errorcode on failure

Definition at line 166 of file peercon.c.

References tcp_packet_info::ack_flag, tcp_packet_info::ack_num, peer_conn_info::buddy, CHECK_FAILED, CHECK_NOT_NULL, tcp_packet_info::d_addr, tcp_packet_info::d_port, peer_conn_info::device, ERROR_1, ERROR_NULL_ARG_1, errorcode, buddy_info::ext_ip, peer_info::ip, peer_conn_info::peer, peer_conn_info_t, peer_info::port, port_t, tcp_packet_info::s_addr, tcp_packet_info::s_port, tcp_packet_info::seq_num, SEQ_NUM_ADD, spoof(), tcp_packet_info::syn_flag, tcp_packet_info_t, TTL_OK, and tcp_packet_info::window.

Referenced by peer_fsm_bday_synack_flood().

errorcode wait_and_join_find_synack peer_conn_info_t info  ) 
 

waits for the find syn ack to finish, within a timeout, and then joins on the thread.

Parameters:
info a pointer to the peer_conn_info_t structure
Returns:
SUCCESS, errorcode on failure

Definition at line 134 of file peercon.c.

References peer_conn_info::bday, CHECK_NOT_NULL, DBG_TIME, ERROR_NULL_ARG_1, errorcode, FAILED, FIND_SYN_ACK_TIMEOUT, bday_peer::find_synack_done, bday_peer::find_synack_tid, FLAG_SET, peer_conn_info_t, bday_peer::stop_synack_find, and wait_for_flag().

Referenced by peer_fsm_end_bday().

errorcode wait_for_direct_conn flag_t check_flag  ) 
 

waits until the direct connection flag is set to FLAG_SUCCESS or FLAG_FAILED

Parameters:
check_flag pointer to the flag to wait on
Returns:
SUCCESS, errorcode on failure

Definition at line 34 of file peercon.c.

References CHECK_FAILED, CHECK_NOT_NULL, DIRECT_CONNECTION_TIMEOUT, ERROR_1, ERROR_NULL_ARG_1, errorcode, FLAG_FAILED, FLAG_SUCCESS, and wait_for_flag().

Referenced by peer_fsm_forge_syn_ack().


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