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

peerfsm.c File Reference

contains defintions of fsm-like functions to control peer connection protocol control flow. More...

#include "peerfsm.h"
#include "peerfsm_private.h"
#include "peercon.h"
#include "directconn.h"
#include "nethelp.h"
#include "netio.h"
#include "comm.h"
#include "debug.h"
#include "sniff.h"
#include "spoof.h"
#include <time.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

errorcode peer_fsm_start (peer_conn_info_t *info)
 entry point for a peer fsm
errorcode peer_fsm_hello (peer_conn_info_t *info)
 the hello state in the fsm
errorcode peer_fsm_conn_again (peer_conn_info_t *info)
 handles a connect again message
errorcode peer_fsm_check_port_pred (peer_conn_info_t *info)
 handles a port prediction message
errorcode peer_fsm_buddy_alloc (peer_conn_info_t *info)
 handles a buddy alloc message
errorcode peer_fsm_buddy_port (peer_conn_info_t *info)
 handles a buddy port message
errorcode peer_fsm_start_direct_conn (peer_conn_info_t *info)
 handles starting the direct connection process
errorcode peer_fsm_forge_syn_ack (peer_conn_info_t *info)
 handles forging a SYN/ACK and thus completing direct connection
errorcode peer_fsm_start_bday (peer_conn_info_t *info)
 handles starting the bday process (when the peer is the random one)
errorcode peer_fsm_end_bday (peer_conn_info_t *info)
 handles ending the bday process (when the peer is the random one)
errorcode peer_fsm_reply_bday (peer_conn_info_t *info)
 handles starting the reply bday process (when peer is the seq one)
errorcode peer_fsm_bday_synack_flood (peer_conn_info_t *info)
 handles sending the flood of synacks to the buddy


Detailed Description

contains defintions of fsm-like functions to control peer connection protocol control flow.

Author:
Daniel Ferullo (ferullo@cmu.edu)

Bug:
peer_fsm_forge_syn_ack only forges one SYN/ACK. Because network could be lossy, maybe send more than one?

Definition in file peerfsm.c.


Function Documentation

errorcode peer_fsm_bday_synack_flood peer_conn_info_t info  ) 
 

handles sending the flood of synacks to the buddy

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 472 of file peerfsm.c.

References CHECK_FAILED, CHECK_NOT_NULL, COMM_MSG_SYN_ACK_FLOOD_DONE, COMM_MSG_SYN_ACK_FLOOD_SEQ_NUM, comm_msg_syn_ack_flood_seq_num_t, DBG_PROTOCOL, DBG_TIME, DEBUG, ERROR_1, ERROR_CALLED_FUNCTION, ERROR_NETWORK_READ, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, errorcode, peer_sock_desc::helper, peer_conn_info_t, peer_fsm_buddy_port(), readMsg(), sendMsg(), peer_conn_info::socks, and synack_flood().

Referenced by peer_fsm_reply_bday().

errorcode peer_fsm_buddy_alloc peer_conn_info_t info  ) 
 

handles a buddy alloc message

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 177 of file peerfsm.c.

References CHECK_FAILED, CHECK_NOT_NULL, COMM_CONNECTION_SUPPORTED, COMM_MSG_BUDDY_ALLOC, comm_msg_buddy_alloc_t, COMM_MSG_WAITING_FOR_BUDDY_PORT, COMM_PORT_ALLOC_SEQ, DBG_PROTOCOL, DBG_TIME, DBG_VERBOSE, DEBUG, ERROR_CALLED_FUNCTION, ERROR_NETWORK_READ, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, errorcode, peer_sock_desc::helper, peer_conn_info_t, peer_fsm_buddy_port(), readMsg(), sendMsg(), and peer_conn_info::socks.

Referenced by peer_fsm_check_port_pred().

errorcode peer_fsm_buddy_port peer_conn_info_t info  ) 
 

handles a buddy port message

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 213 of file peerfsm.c.

References peer_conn_info::buddy, CHECK_FAILED, CHECK_NOT_NULL, COMM_BDAY_NEEDED, COMM_MSG_BUDDY_PORT, comm_msg_buddy_port_t, DBG_PORT, DBG_PROTOCOL, DBG_TIME, DBG_VERBOSE, DEBUG, ERROR_CALLED_FUNCTION, ERROR_CALLED_FUNCTION_1, ERROR_NETWORK_READ, ERROR_NULL_ARG_1, errorcode, buddy_info::ext_port, peer_sock_desc::helper, port_alloc::method, peer_conn_info_t, peer_fsm_reply_bday(), peer_fsm_start_bday(), peer_fsm_start_direct_conn(), peer_conn_info::port_alloc, readMsg(), and peer_conn_info::socks.

Referenced by peer_fsm_bday_synack_flood(), peer_fsm_buddy_alloc(), and peer_fsm_end_bday().

errorcode peer_fsm_check_port_pred peer_conn_info_t info  ) 
 

handles a port prediction message

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 141 of file peerfsm.c.

References CHECK_FAILED, CHECK_NOT_NULL, COMM_MSG_PORT_PRED, comm_msg_pred_port_t, COMM_MSG_WAITING_FOR_BUDDY_ALLOC, COMM_PORT_ALLOC_SEQ, DBG_PROTOCOL, DBG_TIME, DBG_VERBOSE, DEBUG, ERROR_CALLED_FUNCTION, ERROR_NETWORK_READ, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, errorcode, peer_sock_desc::helper, port_alloc::method, peer_conn_info_t, peer_fsm_buddy_alloc(), peer_conn_info::port_alloc, comm_msg_pred_port::port_alloc, readMsg(), sendMsg(), and peer_conn_info::socks.

Referenced by peer_fsm_conn_again().

errorcode peer_fsm_conn_again peer_conn_info_t info  ) 
 

handles a connect again message

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 99 of file peerfsm.c.

References CHECK_FAILED, CHECK_NOT_NULL, COMM_MSG_CONNECT_AGAIN, COMM_MSG_CONNECTED_AGAIN, DBG_PROTOCOL, DBG_TIME, DEBUG, ERROR_NETWORK_READ, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, ERROR_TCP_CONNECT, errorcode, FAILED, peer_sock_desc::helper, peer_conn_info::helper, peer_sock_desc::helper_pred, helper_info::ip, peer_conn_info_t, peer_fsm_check_port_pred(), helper_info::port, readMsg(), sendMsg(), peer_conn_info::socks, and tcp_connect().

Referenced by peer_fsm_hello().

errorcode peer_fsm_end_bday peer_conn_info_t info  ) 
 

handles ending the bday process (when the peer is the random one)

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 403 of file peerfsm.c.

References peer_conn_info::bday, CHECK_FAILED, COMM_MSG_BDAY_SUCCESS_PORT, comm_msg_bday_success_port_t, COMM_MSG_BUDDY_SYN_ACK_FLOODED, DBG_BDAY, DBG_PORT, DBG_PROTOCOL, DBG_TIME, DBG_VERBOSE, DEBUG, ERROR_1, ERROR_CALLED_FUNCTION, ERROR_NETWORK_READ, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, errorcode, peer_sock_desc::helper, peer_conn_info::peer, peer_conn_info_t, peer_fsm_buddy_port(), comm_msg_bday_success_port::port, bday_peer::port, peer_info::port, readMsg(), sendMsg(), peer_conn_info::socks, and wait_and_join_find_synack().

Referenced by peer_fsm_start_bday().

errorcode peer_fsm_forge_syn_ack peer_conn_info_t info  ) 
 

handles forging a SYN/ACK and thus completing direct connection

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 299 of file peerfsm.c.

References tcp_packet_info::ack_flag, tcp_packet_info::ack_num, peer_conn_info::buddy_syn, peer_conn_info::buddy_syn_ack, CHECK_FAILED, CHECK_NOT_NULL, COMM_MSG_GOODBYE, comm_msg_goodbye_t, COMM_MSG_PEER_SYN_SEQ, comm_msg_peer_syn_seq_t, tcp_packet_info::d_addr, tcp_packet_info::d_port, DBG_PROTOCOL, DBG_TIME, DBG_VERBOSE, DEBUG, peer_conn_info::device, peer_conn_info::direct_conn_status, ERROR_1, ERROR_CALLED_FUNCTION, ERROR_NETWORK_READ, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, errorcode, FLAG_SUCCESS, peer_sock_desc::helper, peer_conn_info_t, readMsg(), tcp_packet_info::s_addr, tcp_packet_info::s_port, sendMsg(), tcp_packet_info::seq_num, SEQ_NUM_ADD, peer_conn_info::socks, spoof(), comm_msg_goodbye::success_or_failure, tcp_packet_info::syn_flag, TTL_OK, wait_for_direct_conn(), and tcp_packet_info::window.

Referenced by peer_fsm_start_direct_conn().

errorcode peer_fsm_hello peer_conn_info_t info  ) 
 

the hello state in the fsm

Parameters:
info a pointer to the connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 63 of file peerfsm.c.

References peer_conn_info::buddy, comm_msg_hello::buddy_ext_ip, comm_msg_hello::buddy_int_ip, comm_msg_hello::buddy_int_port, CHECK_FAILED, CHECK_NOT_NULL, COMM_MSG_HELLO, comm_msg_hello_t, DBG_BDAY, DBG_PORT, DBG_PROTOCOL, DBG_TIME, DEBUG, ERROR_CALLED_FUNCTION, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, errorcode, buddy_info::ext_ip, peer_sock_desc::helper, buddy_info::int_ip, buddy_info::int_port, peer_info::ip, peer_conn_info::peer, peer_conn_info_t, peer_fsm_conn_again(), comm_msg_hello::peer_ip, comm_msg_hello::peer_port, peer_info::port, sendMsg(), and peer_conn_info::socks.

Referenced by peer_fsm_start().

errorcode peer_fsm_reply_bday peer_conn_info_t info  ) 
 

handles starting the reply bday process (when peer is the seq one)

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 450 of file peerfsm.c.

References CHECK_FAILED, CHECK_NOT_NULL, COMM_MSG_WAITING_TO_SYN_ACK_FLOOD, DBG_PROTOCOL, DBG_TIME, DEBUG, ERROR_CALLED_FUNCTION, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, errorcode, peer_sock_desc::helper, peer_conn_info_t, peer_fsm_bday_synack_flood(), sendMsg(), and peer_conn_info::socks.

Referenced by peer_fsm_buddy_port().

errorcode peer_fsm_start peer_conn_info_t info  ) 
 

entry point for a peer fsm

Parameters:
info a pointer to the conn_info_t struct with all the info
Returns:
SUCCESS, errorcode on failure

Definition at line 43 of file peerfsm.c.

References CHECK_FAILED, CHECK_NOT_NULL, DBG_TIME, ERROR_CALLED_FUNCTION, ERROR_NULL_ARG_1, ERROR_TCP_CONNECT, errorcode, peer_conn_info::helper, peer_sock_desc::helper, helper_info::ip, peer_conn_info_t, peer_fsm_hello(), helper_info::port, peer_conn_info::socks, and tcp_connect().

Referenced by natblaster_connect().

errorcode peer_fsm_start_bday peer_conn_info_t info  ) 
 

handles starting the bday process (when the peer is the random one)

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 355 of file peerfsm.c.

References peer_conn_info::buddy, CHECK_FAILED, CHECK_NOT_NULL, COMM_MSG_SYN_FLOODED, comm_msg_syn_flooded_t, tcp_packet_info::d_addr, tcp_packet_info::d_port, DBG_BDAY, DBG_PORT, DBG_PROTOCOL, DBG_TIME, DEBUG, peer_conn_info::device, ERROR_1, ERROR_2, ERROR_CALLED_FUNCTION, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, errorcode, buddy_info::ext_ip, buddy_info::ext_port, flood_syns(), peer_sock_desc::helper, peer_info::ip, peer_conn_info::peer, peer_conn_info_t, peer_fsm_end_bday(), tcp_packet_info::s_addr, sendMsg(), tcp_packet_info::seq_num, comm_msg_syn_flooded::seq_num, peer_conn_info::socks, start_find_synack(), and tcp_packet_info_t.

Referenced by peer_fsm_buddy_port().

errorcode peer_fsm_start_direct_conn peer_conn_info_t info  ) 
 

handles starting the direct connection process

Parameters:
info pointer to the peer connection information
Returns:
SUCCESS, errorcode on failure

Definition at line 266 of file peerfsm.c.

References peer_conn_info::buddy_syn, capture_peer_to_buddy_syn(), CHECK_FAILED, COMM_MSG_BUDDY_SYN_SEQ, comm_msg_buddy_syn_seq_t, DBG_BDAY, DBG_PROTOCOL, DBG_SEQ_NUM, DBG_TIME, DBG_VERBOSE, DEBUG, ERROR_CALLED_FUNCTION_1, ERROR_CALLED_FUNCTION_2, ERROR_CALLED_FUNCTION_3, ERROR_NETWORK_SEND, ERROR_NULL_ARG_1, errorcode, peer_sock_desc::helper, peer_conn_info_t, peer_fsm_forge_syn_ack(), sendMsg(), comm_msg_buddy_syn_seq::seq_num, tcp_packet_info::seq_num, peer_conn_info::socks, and start_direct_conn().

Referenced by peer_fsm_buddy_port().


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