|
|
IoTcpUdp (FeaDataPlaneManager& fea_data_plane_manager, const IfTree& iftree,
int family, bool is_tcp)
| IoTcpUdp |
Constructor for a given address family.
Parameters:
fea_data_plane_manager | the corresponding data plane manager (FeaDataPlaneManager). |
iftree | the interface tree to use. |
family | the address family (AF_INET or AF_INET6 for IPv4 and IPv6 respectively). |
is_tcp | if true this is TCP entry, otherwise UDP. |
~IoTcpUdp ()
| ~IoTcpUdp |
[virtual]
IoTcpUdpManager& io_tcpudp_manager ()
| io_tcpudp_manager |
Get the IoTcpUdpManager instance.
Returns: the IoTcpUdpManager instance.
FeaDataPlaneManager& fea_data_plane_manager ()
| fea_data_plane_manager |
Get the FeaDataPlaneManager instance.
Returns: the FeaDataPlaneManager instance.
bool is_running ()
| is_running |
[const virtual]
Test whether this instance is running.
Returns: true if the instance is running, otherwise false.
EventLoop& eventloop ()
| eventloop |
Get the event loop.
Returns: the event loop.
const IfTree& iftree ()
| iftree |
[const]
Get the interface tree.
Returns: the interface tree.
int family ()
| family |
[const virtual]
Get the address family.
Returns: the address family.
bool is_tcp ()
| is_tcp |
[const virtual]
Test whether this is TCP entry.
Returns: true if this is TCP entry, otherwise false (i.e., UDP).
IoTcpUdpReceiver* io_tcpudp_receiver ()
| io_tcpudp_receiver |
Get the registered receiver.
Returns: the registered receiver.
void register_io_tcpudp_receiver (IoTcpUdpReceiver* io_tcpudp_receiver)
| register_io_tcpudp_receiver |
[virtual]
Register the I/O TCP/UDP data receiver.
Parameters:
io_tcpudp_receiver | the receiver to register. |
void unregister_io_tcpudp_receiver ()
| unregister_io_tcpudp_receiver |
[virtual]
Unregister the I/O TCP/UDP data receiver.
int start (string& error_msg)
| start |
[pure virtual]
Start operation.
Parameters:
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int stop (string& error_msg)
| stop |
[pure virtual]
Stop operation.
Parameters:
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int tcp_open (string& error_msg)
| tcp_open |
[pure virtual]
Open a TCP socket.
Parameters:
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int udp_open (string& error_msg)
| udp_open |
[pure virtual]
Open an UDP socket.
Parameters:
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int tcp_open_and_bind (const IPvX& local_addr, uint16_t local_port,
string& error_msg)
| tcp_open_and_bind |
[pure virtual]
Create a bound TCP socket.
Parameters:
local_addr | the interface address to bind socket to. |
local_port | the port to bind socket to. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int udp_open_and_bind (const IPvX& local_addr, uint16_t local_port,
string& error_msg)
| udp_open_and_bind |
[pure virtual]
Create a bound UDP socket.
Parameters:
local_addr | the interface address to bind socket to. |
local_port | the port to bind socket to. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int udp_open_bind_join (const IPvX& local_addr, uint16_t local_port,
const IPvX& mcast_addr, uint8_t ttl,
bool reuse, string& error_msg)
| udp_open_bind_join |
[pure virtual]
Create a bound UDP multicast socket.
Parameters:
local_addr | the interface address to bind socket to. |
local_port | the port to bind socket to. |
mcast_addr | the multicast group address to join. |
ttl | the TTL to use for this multicast socket. |
reuse | allow other sockets to bind to same multicast group. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int tcp_open_bind_connect (const IPvX& local_addr,
uint16_t local_port,
const IPvX& remote_addr,
uint16_t remote_port,
string& error_msg)
| tcp_open_bind_connect |
[pure virtual]
Create a bound and connected TCP socket.
Parameters:
local_addr | the interface address to bind socket to. |
local_port | the port to bind socket to. |
remote_addr | the address to connect to. |
remote_port | the remote port to connect to. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int udp_open_bind_connect (const IPvX& local_addr,
uint16_t local_port,
const IPvX& remote_addr,
uint16_t remote_port,
string& error_msg)
| udp_open_bind_connect |
[pure virtual]
Create a bound and connected UDP socket.
Parameters:
local_addr | the interface address to bind socket to. |
local_port | the port to bind socket to. |
remote_addr | the address to connect to. |
remote_port | the remote port to connect to. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int udp_open_bind_broadcast (const string& ifname,
const string& vifname,
uint16_t local_port,
uint16_t remote_port,
bool reuse,
bool limited,
bool connected,
string& error_msg)
| udp_open_bind_broadcast |
[pure virtual]
Create a bound, and optionally connected, UDP broadcast socket.
Parameters:
ifname | the interface name to bind socket to. |
vifname | the vif to bind socket to. |
local_port | the port to bind socket to. |
remote_port | the remote port to connect to. |
reuse | allow other sockets to bind to same port. |
limited | set the socket up for transmission to the limited broadcast address 255.255.255.255. |
connected | connect the socket for use with send() not sendto(). |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int bind (const IPvX& local_addr, uint16_t local_port,
string& error_msg)
| bind |
[pure virtual]
Bind a socket.
Parameters:
local_addr | the interface address to bind socket to. |
local_port | the port to bind socket to. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int udp_join_group (const IPvX& mcast_addr,
const IPvX& join_if_addr,
string& error_msg)
| udp_join_group |
[pure virtual]
Join multicast group on already bound socket.
Parameters:
mcast_addr | group to join. |
join_if_addr | interface address to perform join on. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int udp_leave_group (const IPvX& mcast_addr,
const IPvX& leave_if_addr,
string& error_msg)
| udp_leave_group |
[pure virtual]
Leave multicast group on already bound socket.
Parameters:
mcast_addr | group to leave. |
leave_if_addr | interface address to perform leave on. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int close (string& error_msg)
| close |
[pure virtual]
Close socket.
Parameters:
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int tcp_listen (uint32_t backlog, string& error_msg)
| tcp_listen |
[pure virtual]
Listen for inbound connections on socket.
When a connection request is received the socket creator will receive notification.
Parameters:
backlog | the maximum number of pending connections. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int udp_enable_recv (string& error_msg)
| udp_enable_recv |
[pure virtual]
Enable a UDP socket for datagram reception.
When a connection request is received the socket creator will receive notification.
Parameters:
backlog | the maximum number of pending connections. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int send (const vector<uint8_t>& data, string& error_msg)
| send |
[pure virtual]
Send data on socket.
Parameters:
data | block of data to be sent. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int send_to (const IPvX& remote_addr, uint16_t remote_port,
const vector<uint8_t>& data, string& error_msg)
| send_to |
[pure virtual]
Send data on socket to a given destination.
The packet is not routed as the forwarding engine sending the packet may not have access to the full routing table.
Parameters:
remote_addr | destination address for data. |
remote_port | destination port for data. |
data | block of data to be sent. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int send_from_multicast_if (const IPvX& group_addr,
uint16_t group_port,
const IPvX& ifaddr,
const vector<uint8_t>& data,
string& error_msg)
| send_from_multicast_if |
[pure virtual]
Send data on socket to a given multicast group from a given interface.
Parameters:
group_addr | destination address for data. |
group_port | destination port for data. |
ifaddr | interface address. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int set_socket_option (const string& optname, uint32_t optval,
string& error_msg)
| set_socket_option |
[pure virtual]
Set a named socket option with an integer value.
Parameters:
optname | name of option to be set. Valid values are: "onesbcast" (IPv4 only) "receive_broadcast" (IPv4 only) "reuseport" "send_broadcast" (IPv4 only) "tos" (IPv4 only) "ttl" "multicast_loopback" "multicast_ttl" |
optval | value of option to be set. If value is logically boolean then zero represents false and any non-zero value true. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int set_socket_option (const string& optname,
const string& optval,
string& error_msg)
| set_socket_option |
[pure virtual]
Set a named socket option with a string value.
Parameters:
optname | name of option to be set. Valid values are: "bindtodevice" |
optval | value of option to be set. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
int accept_connection (bool is_accepted, string& error_msg)
| accept_connection |
[pure virtual]
Accept or reject a pending connection.
Parameters:
is_accepted | if true, the connection is accepted, otherwise is rejected. |
error_msg | the error message (if error). |
Returns: XORP_OK on success, otherwise XORP_ERROR.
void recv_event (const string& if_name,
const string& vif_name,
const IPvX& src_host,
uint16_t src_port,
const vector<uint8_t>& data)
| recv_event |
[protected virtual]
Data received event.
Parameters:
if_name | the interface name the packet arrived on, if known. If unknown, then it is an empty string. |
vif_name | the vif name the packet arrived on, if known. If unknown, then it is an empty string. |
src_host | the originating host IP address. |
src_port | the originating host port number. |
data | the data received. |
void inbound_connect_event (const IPvX& src_host,
uint16_t src_port,
IoTcpUdp* new_io_tcpudp)
| inbound_connect_event |
[protected virtual]
Inbound connection request received event.
It applies only to TCP sockets.
Parameters:
src_host | the originating host IP address. |
src_port | the originating host port number. |
new_io_tcpudp | the handler for the new connection. |
void outgoing_connect_event ()
| outgoing_connect_event |
[protected virtual]
Outgoing connection request completed event.
It applies only to TCP sockets.
void error_event (const string& error,
bool fatal)
| error_event |
[protected virtual]
Error occured event.
Parameters:
error | a textual description of the error. |
fatal | indication of whether socket is shutdown because of error. |
void disconnect_event ()
| disconnect_event |
[protected virtual]
Connection closed by peer event.
It applies only to TCP sockets. This method is not called if the socket is gracefully closed through close().
bool _is_running | _is_running |
[protected]