xorp

TestSocket4TCPServer Class Reference

Inheritance diagram for TestSocket4TCPServer:
TestSocket4TCP XrlTestSocket4TargetBase

List of all members.

Public Member Functions

 TestSocket4TCPServer (EventLoop &e, const string &fea_target_name, IPv4 finder_host, uint16_t finder_port)
bool server_closed () const
bool client_closed () const
bool bind (IPv4 addr, uint16_t port)
 Bind to interface and port.
bool listen (uint32_t backlog)
 Listen on the server socket.
bool close_server ()
 Request closure of the server socket.
bool close_client ()
 Request closure of the client socket (request a disconnect of the client).
bool send_data (uint32_t bytes)
 Send data to the connected client, through the client socket.
void start_sending (uint32_t bytes, uint32_t ipg_ms)
 Start sending packets.

Protected Member Functions

void bind_cb (const XrlError &e, const string *psockid)
void listen_cb (const XrlError &e)
void close_server_cb (const XrlError &e)
void close_client_cb (const XrlError &e)
void send_data_cb (const XrlError &e)
XrlCmdError socket4_user_0_1_recv_event (const string &sockid, const string &if_name, const string &vif_name, const IPv4 &src_host, const uint32_t &src_port, const vector< uint8_t > &data)
 Pure-virtual function that needs to be implemented to:
XrlCmdError socket4_user_0_1_inbound_connect_event (const string &sockid, const IPv4 &src_host, const uint32_t &src_port, const string &new_sockid, bool &accept)
 Pure-virtual function that needs to be implemented to:
XrlCmdError socket4_user_0_1_outgoing_connect_event (const string &sockid)
 Pure-virtual function that needs to be implemented to:
XrlCmdError socket4_user_0_1_error_event (const string &sockid, const string &error, const bool &fatal)
 Pure-virtual function that needs to be implemented to:
XrlCmdError socket4_user_0_1_disconnect_event (const string &sockid)
 Pure-virtual function that needs to be implemented to:

Private Attributes

string _server_sockid
string _client_sockid
bool _server_closed
bool _client_closed

Member Function Documentation

bool TestSocket4TCPServer::bind ( IPv4  addr,
uint16_t  port 
) [inline]

Bind to interface and port.

This is an asynchronous request. If the request is successfully queued for dispatch then true is returned.

Subsequently, if the request is successful _server_sockid is set to a valid socket identifier, and _server_closed set to false. If unsuccessful the number of xrl errors is bumped by one.

bool TestSocket4TCPServer::close_client ( ) [inline]

Request closure of the client socket (request a disconnect of the client).

This is an asychronous request. If the request is successfully queued for dispatch then true is returned.

On success _client_sockid is cleared. On failure the number xrl errors is bumped by one.

bool TestSocket4TCPServer::close_server ( ) [inline]

Request closure of the server socket.

This is an asychronous request. If the request is successfully queued for dispatch then true is returned.

On success _server_sockid is cleared. On failure the number xrl errors is bumped by one.

bool TestSocket4TCPServer::listen ( uint32_t  backlog) [inline]

Listen on the server socket.

This is an asynchronous request. If the request is successfully queued for dispatch then true is returned.

bool TestSocket4TCPServer::send_data ( uint32_t  bytes) [inline, virtual]

Send data to the connected client, through the client socket.

For implementation, see TestSocket4TCP::send_data.

Implements TestSocket4TCP.

XrlCmdError TestSocket4TCPServer::socket4_user_0_1_disconnect_event ( const string &  sockid) [inline, protected, virtual]

Pure-virtual function that needs to be implemented to:

Method invoked by target implementing socket4/0.1 when the peer has closed the connection. It applies only to TCP sockets. Note that the socket itself is left open and must be explicitly closed.

Parameters:
sockidthe identifier associated with socket where the event occurred.

Implements TestSocket4TCP.

XrlCmdError TestSocket4TCPServer::socket4_user_0_1_error_event ( const string &  sockid,
const string &  error,
const bool &  fatal 
) [inline, protected, virtual]

Pure-virtual function that needs to be implemented to:

Method invoked by target implementing socket4/0.1 when an error occurs.

Parameters:
sockidthe identifier associated with socket where the event occurred.
errora textual description of the error.
fatalindication of whether socket is shutdown because of error.

Implements TestSocket4TCP.

XrlCmdError TestSocket4TCPServer::socket4_user_0_1_inbound_connect_event ( const string &  sockid,
const IPv4 src_host,
const uint32_t &  src_port,
const string &  new_sockid,
bool &  accept 
) [inline, protected, virtual]

Pure-virtual function that needs to be implemented to:

Method invoked by target implementing socket4/0.1 when a connection request is received from an IPv4 source. It applies only to TCP sockets.

Parameters:
sockidthe identifier associated with socket where the event occurred.
src_hostthe connecting host.
src_portthe connecting IP port.
new_sockidthe identifier associated with the new socket that has been created to handle the new connection.
acceptif true, the connection request has been accepted, otherwise it has been rejected.

Implements TestSocket4TCP.

XrlCmdError TestSocket4TCPServer::socket4_user_0_1_outgoing_connect_event ( const string &  sockid) [inline, protected, virtual]

Pure-virtual function that needs to be implemented to:

Method invoked by target implementing socket4/0.1 when an outgoing connection request originated by the local host is completed. It applies only to TCP sockets. Note that if the connection failed, the error_event will be dispatched instead.

Parameters:
sockidthe identifier associated with socket where the event occurred.

Implements TestSocket4TCP.

XrlCmdError TestSocket4TCPServer::socket4_user_0_1_recv_event ( const string &  sockid,
const string &  if_name,
const string &  vif_name,
const IPv4 src_host,
const uint32_t &  src_port,
const vector< uint8_t > &  data 
) [inline, protected, virtual]

Pure-virtual function that needs to be implemented to:

Method invoked by target implementing socket4/0.1 when a packet arrives from an IPv4 source.

Parameters:
sockidthe identifier associated with socket where the event occurred.
if_namethe interface name the packet arrived on, if known. If unknown, then it is an empty string.
vif_namethe vif name the packet arrived on, if known. If unknown, then it is an empty string.
src_hostthe originating host.
src_portthe originating IP port.
datathe data received.

Implements TestSocket4TCP.

void TestSocket4TCPServer::start_sending ( uint32_t  bytes,
uint32_t  ipg_ms 
) [inline, virtual]

Start sending packets.

Parameters:
bytessize of each packet.
ipg_msinterpacket gap in milliseconds.

Implements TestSocket4TCP.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations