xorp

TestSocket4UDP Class Reference

Inheritance diagram for TestSocket4UDP:
XrlTestSocket4TargetBase

List of all members.

Public Member Functions

 TestSocket4UDP (EventLoop &e, const string &fea_target_name, IPv4 finder_host, uint16_t finder_port)
uint32_t bytes_received () const
uint32_t bytes_sent () const
uint32_t packets_received () const
uint32_t packets_sent () const
uint32_t xrl_errors () const
bool closed () const
bool bind (IPv4 addr, uint16_t port)
 Bind to interface and port.
bool close ()
 Request closure of socket.
void start_sending (IPv4 host, uint16_t port, uint32_t bytes, uint32_t ipg_ms)
 Start sending packets.
void stop_sending ()
 Stop sending packets.

Protected Member Functions

bool send_data (IPv4 host, uint16_t port, uint32_t bytes)
void send_data_cb (const XrlError &e)
void bind_cb (const XrlError &e, const string *psockid)
void close_cb (const XrlError &e)
XrlCmdError common_0_1_get_target_name (string &name)
 Pure-virtual function that needs to be implemented to:
XrlCmdError common_0_1_get_version (string &version)
 Pure-virtual function that needs to be implemented to:
XrlCmdError common_0_1_get_status (uint32_t &status, string &reason)
 Pure-virtual function that needs to be implemented to:
XrlCmdError common_0_1_shutdown ()
 Pure-virtual function that needs to be implemented to:
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 &, const IPv4 &, const uint32_t &, const string &, bool &)
 Pure-virtual function that needs to be implemented to:
XrlCmdError socket4_user_0_1_outgoing_connect_event (const string &)
 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

EventLoop_e
XrlRouter_r
string _fea_target_name
string _sockid
uint32_t _p_snd
uint32_t _p_rcv
uint32_t _b_snd
uint32_t _b_rcv
uint32_t _x_err
bool _closed
XorpTimer _t_snd

Member Function Documentation

bool TestSocket4UDP::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 _sockid is set to a valid socket identifier, and if unsuccessful the number of xrl errors is bumped by one.

bool TestSocket4UDP::close ( ) [inline]

Request closure of socket.

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

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

XrlCmdError TestSocket4UDP::common_0_1_get_status ( uint32_t &  status,
string &  reason 
) [inline, protected, virtual]

Pure-virtual function that needs to be implemented to:

Get status of Xrl Target

Implements XrlTestSocket4TargetBase.

XrlCmdError TestSocket4UDP::common_0_1_get_target_name ( string &  name) [inline, protected, virtual]

Pure-virtual function that needs to be implemented to:

Get name of Xrl Target

Implements XrlTestSocket4TargetBase.

XrlCmdError TestSocket4UDP::common_0_1_get_version ( string &  version) [inline, protected, virtual]

Pure-virtual function that needs to be implemented to:

Get version string from Xrl Target

Implements XrlTestSocket4TargetBase.

XrlCmdError TestSocket4UDP::common_0_1_shutdown ( ) [inline, protected, virtual]

Pure-virtual function that needs to be implemented to:

Request clean shutdown of Xrl Target

Implements XrlTestSocket4TargetBase.

XrlCmdError TestSocket4UDP::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 XrlTestSocket4TargetBase.

XrlCmdError TestSocket4UDP::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 XrlTestSocket4TargetBase.

XrlCmdError TestSocket4UDP::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 XrlTestSocket4TargetBase.

XrlCmdError TestSocket4UDP::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 XrlTestSocket4TargetBase.

XrlCmdError TestSocket4UDP::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 XrlTestSocket4TargetBase.

void TestSocket4UDP::start_sending ( IPv4  host,
uint16_t  port,
uint32_t  bytes,
uint32_t  ipg_ms 
) [inline]

Start sending packets.

Parameters:
hostaddress to send data to.
portto send data to.
bytessize of each packet.
ipg_msinterpacket gap in milliseconds.

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