|
xorp
|
A base class for I/O TCP/UDP communication. More...
#include <io_tcpudp.hh>
Public Member Functions | |
| IoTcpUdp (FeaDataPlaneManager &fea_data_plane_manager, const IfTree &iftree, int family, bool is_tcp) | |
| Constructor for a given address family. | |
| virtual | ~IoTcpUdp () |
| Virtual destructor. | |
| IoTcpUdpManager & | io_tcpudp_manager () |
| Get the IoTcpUdpManager instance. | |
| FeaDataPlaneManager & | fea_data_plane_manager () |
| Get the FeaDataPlaneManager instance. | |
| virtual bool | is_running () const |
| Test whether this instance is running. | |
| EventLoop & | eventloop () |
| Get the event loop. | |
| const IfTree & | iftree () const |
| Get the interface tree. | |
| virtual int | family () const |
| Get the address family. | |
| virtual bool | is_tcp () const |
| Test whether this is TCP entry. | |
| IoTcpUdpReceiver * | io_tcpudp_receiver () |
| Get the registered receiver. | |
| virtual void | register_io_tcpudp_receiver (IoTcpUdpReceiver *io_tcpudp_receiver) |
| Register the I/O TCP/UDP data receiver. | |
| virtual void | unregister_io_tcpudp_receiver () |
| Unregister the I/O TCP/UDP data receiver. | |
| virtual int | start (string &error_msg)=0 |
| Start operation. | |
| virtual int | stop (string &error_msg)=0 |
| Stop operation. | |
| virtual int | tcp_open (string &error_msg)=0 |
| Open a TCP socket. | |
| virtual int | udp_open (string &error_msg)=0 |
| Open an UDP socket. | |
| virtual int | tcp_open_and_bind (const IPvX &local_addr, uint16_t local_port, string &error_msg)=0 |
| Create a bound TCP socket. | |
| virtual int | udp_open_and_bind (const IPvX &local_addr, uint16_t local_port, const string &local_dev, int reuse, string &error_msg)=0 |
| Create a bound UDP socket. | |
| virtual 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)=0 |
| Create a bound UDP multicast socket. | |
| virtual int | tcp_open_bind_connect (const IPvX &local_addr, uint16_t local_port, const IPvX &remote_addr, uint16_t remote_port, string &error_msg)=0 |
| Create a bound and connected TCP socket. | |
| virtual int | udp_open_bind_connect (const IPvX &local_addr, uint16_t local_port, const IPvX &remote_addr, uint16_t remote_port, string &error_msg)=0 |
| Create a bound and connected UDP socket. | |
| virtual 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)=0 |
| Create a bound, and optionally connected, UDP broadcast socket. | |
| virtual int | bind (const IPvX &local_addr, uint16_t local_port, string &error_msg)=0 |
| Bind a socket. | |
| virtual int | udp_join_group (const IPvX &mcast_addr, const IPvX &join_if_addr, string &error_msg)=0 |
| Join multicast group on already bound socket. | |
| virtual int | udp_leave_group (const IPvX &mcast_addr, const IPvX &leave_if_addr, string &error_msg)=0 |
| Leave multicast group on already bound socket. | |
| virtual int | close (string &error_msg)=0 |
| Close socket. | |
| virtual int | tcp_listen (uint32_t backlog, string &error_msg)=0 |
| Listen for inbound connections on socket. | |
| virtual int | udp_enable_recv (string &error_msg)=0 |
| Enable a UDP socket for datagram reception. | |
| virtual int | send (const vector< uint8_t > &data, string &error_msg)=0 |
| Send data on socket. | |
| virtual int | send_to (const IPvX &remote_addr, uint16_t remote_port, const vector< uint8_t > &data, string &error_msg)=0 |
| Send data on socket to a given destination. | |
| virtual int | send_from_multicast_if (const IPvX &group_addr, uint16_t group_port, const IPvX &ifaddr, const vector< uint8_t > &data, string &error_msg)=0 |
| Send data on socket to a given multicast group from a given interface. | |
| virtual int | set_socket_option (const string &optname, uint32_t optval, string &error_msg)=0 |
| Set a named socket option with an integer value. | |
| virtual int | set_socket_option (const string &optname, const string &optval, string &error_msg)=0 |
| Set a named socket option with a string value. | |
| virtual int | accept_connection (bool is_accepted, string &error_msg)=0 |
| Accept or reject a pending connection. | |
Protected Member Functions | |
| virtual void | recv_event (const string &if_name, const string &vif_name, const IPvX &src_host, uint16_t src_port, const vector< uint8_t > &data) |
| Data received event. | |
| virtual void | inbound_connect_event (const IPvX &src_host, uint16_t src_port, IoTcpUdp *new_io_tcpudp) |
| Inbound connection request received event. | |
| virtual void | outgoing_connect_event () |
| Outgoing connection request completed event. | |
| virtual void | error_event (const string &error, bool fatal) |
| Error occured event. | |
| virtual void | disconnect_event () |
| Connection closed by peer event. | |
Protected Attributes | |
| bool | _is_running |
Private Attributes | |
| IoTcpUdpManager & | _io_tcpudp_manager |
| FeaDataPlaneManager & | _fea_data_plane_manager |
| EventLoop & | _eventloop |
| const IfTree & | _iftree |
| const int | _family |
| const bool | _is_tcp |
| IoTcpUdpReceiver * | _io_tcpudp_receiver |
A base class for I/O TCP/UDP communication.
| IoTcpUdp::IoTcpUdp | ( | FeaDataPlaneManager & | fea_data_plane_manager, |
| const IfTree & | iftree, | ||
| int | family, | ||
| bool | is_tcp | ||
| ) |
| virtual int IoTcpUdp::accept_connection | ( | bool | is_accepted, |
| string & | error_msg | ||
| ) | [pure virtual] |
Accept or reject a pending connection.
| is_accepted | if true, the connection is accepted, otherwise is rejected. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::bind | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Bind a socket.
| local_addr | the interface address to bind socket to. |
| local_port | the port to bind socket to. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::close | ( | string & | error_msg | ) | [pure virtual] |
Close socket.
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| void IoTcpUdp::disconnect_event | ( | ) | [protected, virtual] |
| void IoTcpUdp::error_event | ( | const string & | error, |
| bool | fatal | ||
| ) | [protected, virtual] |
Error occured event.
| error | a textual description of the error. |
| fatal | indication of whether socket is shutdown because of error. |
| virtual int IoTcpUdp::family | ( | ) | const [inline, virtual] |
| FeaDataPlaneManager& IoTcpUdp::fea_data_plane_manager | ( | ) | [inline] |
Get the FeaDataPlaneManager instance.
| const IfTree& IoTcpUdp::iftree | ( | ) | const [inline] |
| IoTcpUdpManager& IoTcpUdp::io_tcpudp_manager | ( | ) | [inline] |
Get the IoTcpUdpManager instance.
| IoTcpUdpReceiver* IoTcpUdp::io_tcpudp_receiver | ( | ) | [inline] |
| virtual bool IoTcpUdp::is_running | ( | ) | const [inline, virtual] |
Test whether this instance is running.
| virtual bool IoTcpUdp::is_tcp | ( | ) | const [inline, virtual] |
Test whether this is TCP entry.
| void IoTcpUdp::outgoing_connect_event | ( | ) | [protected, virtual] |
Outgoing connection request completed event.
It applies only to TCP sockets.
| void IoTcpUdp::recv_event | ( | const string & | if_name, |
| const string & | vif_name, | ||
| const IPvX & | src_host, | ||
| uint16_t | src_port, | ||
| const vector< uint8_t > & | data | ||
| ) | [protected, virtual] |
Data received event.
| 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 IoTcpUdp::register_io_tcpudp_receiver | ( | IoTcpUdpReceiver * | io_tcpudp_receiver | ) | [virtual] |
| virtual int IoTcpUdp::send | ( | const vector< uint8_t > & | data, |
| string & | error_msg | ||
| ) | [pure virtual] |
Send data on socket.
| data | block of data to be sent. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::send_from_multicast_if | ( | const IPvX & | group_addr, |
| uint16_t | group_port, | ||
| const IPvX & | ifaddr, | ||
| const vector< uint8_t > & | data, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Send data on socket to a given multicast group from a given interface.
| group_addr | destination address for data. |
| group_port | destination port for data. |
| ifaddr | interface address. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::send_to | ( | const IPvX & | remote_addr, |
| uint16_t | remote_port, | ||
| const vector< uint8_t > & | data, | ||
| string & | error_msg | ||
| ) | [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.
| 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). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::set_socket_option | ( | const string & | optname, |
| const string & | optval, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Set a named socket option with a string value.
| 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). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::set_socket_option | ( | const string & | optname, |
| uint32_t | optval, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Set a named socket option with an integer value.
| 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). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::start | ( | string & | error_msg | ) | [pure virtual] |
Start operation.
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::stop | ( | string & | error_msg | ) | [pure virtual] |
Stop operation.
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::tcp_listen | ( | uint32_t | backlog, |
| string & | error_msg | ||
| ) | [pure virtual] |
Listen for inbound connections on socket.
When a connection request is received the socket creator will receive notification.
| backlog | the maximum number of pending connections. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::tcp_open | ( | string & | error_msg | ) | [pure virtual] |
Open a TCP socket.
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::tcp_open_and_bind | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Create a bound TCP socket.
| local_addr | the interface address to bind socket to. |
| local_port | the port to bind socket to. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::tcp_open_bind_connect | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| const IPvX & | remote_addr, | ||
| uint16_t | remote_port, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Create a bound and connected TCP socket.
| 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). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::udp_enable_recv | ( | string & | error_msg | ) | [pure virtual] |
Enable a UDP socket for datagram reception.
When a connection request is received the socket creator will receive notification.
| backlog | the maximum number of pending connections. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::udp_join_group | ( | const IPvX & | mcast_addr, |
| const IPvX & | join_if_addr, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Join multicast group on already bound socket.
| mcast_addr | group to join. |
| join_if_addr | interface address to perform join on. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::udp_leave_group | ( | const IPvX & | mcast_addr, |
| const IPvX & | leave_if_addr, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Leave multicast group on already bound socket.
| mcast_addr | group to leave. |
| leave_if_addr | interface address to perform leave on. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::udp_open | ( | string & | error_msg | ) | [pure virtual] |
Open an UDP socket.
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::udp_open_and_bind | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| const string & | local_dev, | ||
| int | reuse, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Create a bound UDP socket.
| local_addr | the interface address to bind socket to. |
| local_port | the port to bind socket to. |
| error_msg | the error message (if error). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::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 | ||
| ) | [pure virtual] |
Create a bound, and optionally connected, UDP broadcast socket.
| 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). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::udp_open_bind_connect | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| const IPvX & | remote_addr, | ||
| uint16_t | remote_port, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Create a bound and connected UDP socket.
| 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). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.
| virtual int IoTcpUdp::udp_open_bind_join | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| const IPvX & | mcast_addr, | ||
| uint8_t | ttl, | ||
| bool | reuse, | ||
| string & | error_msg | ||
| ) | [pure virtual] |
Create a bound UDP multicast socket.
| 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). |
Implemented in IoTcpUdpDummy, and IoTcpUdpSocket.