|
xorp
|
A base class for I/O TCP/UDP socket communication. More...
#include <io_tcpudp_socket.hh>
Public Member Functions | |
| IoTcpUdpSocket (FeaDataPlaneManager &fea_data_plane_manager, const IfTree &iftree, int family, bool is_tcp) | |
| Constructor for a given address family. | |
| virtual | ~IoTcpUdpSocket () |
| Virtual destructor. | |
| int | start (string &error_msg) |
| Start operation. | |
| int | stop (string &error_msg) |
| Stop operation. | |
| int | tcp_open (string &error_msg) |
| Open a TCP socket. | |
| int | udp_open (string &error_msg) |
| Open an UDP socket. | |
| int | tcp_open_and_bind (const IPvX &local_addr, uint16_t local_port, string &error_msg) |
| Create a bound TCP socket. | |
| int | udp_open_and_bind (const IPvX &local_addr, uint16_t local_port, const string &local_dev, int reuse, string &error_msg) |
| Create a bound UDP socket. | |
| 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) |
| Create a bound UDP multicast socket. | |
| int | tcp_open_bind_connect (const IPvX &local_addr, uint16_t local_port, const IPvX &remote_addr, uint16_t remote_port, string &error_msg) |
| Create a bound and connected TCP socket. | |
| int | udp_open_bind_connect (const IPvX &local_addr, uint16_t local_port, const IPvX &remote_addr, uint16_t remote_port, string &error_msg) |
| Create a bound and connected UDP socket. | |
| 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) |
| Create a bound, and optionally connected, UDP broadcast socket. | |
| int | bind (const IPvX &local_addr, uint16_t local_port, string &error_msg) |
| Bind a socket. | |
| int | udp_join_group (const IPvX &mcast_addr, const IPvX &join_if_addr, string &error_msg) |
| Join multicast group on already bound socket. | |
| int | udp_leave_group (const IPvX &mcast_addr, const IPvX &leave_if_addr, string &error_msg) |
| Leave multicast group on already bound socket. | |
| int | close (string &error_msg) |
| Close socket. | |
| int | tcp_listen (uint32_t backlog, string &error_msg) |
| Listen for inbound connections on socket. | |
| int | udp_enable_recv (string &error_msg) |
| Enable a UDP socket for datagram reception. | |
| int | send (const vector< uint8_t > &data, string &error_msg) |
| Send data on socket. | |
| int | send_to (const IPvX &remote_addr, uint16_t remote_port, const vector< uint8_t > &data, string &error_msg) |
| Send data on socket to a given destination. | |
| 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 data on socket to a given multicast group from a given interface. | |
| int | set_socket_option (const string &optname, uint32_t optval, string &error_msg) |
| Set a named socket option with an integer value. | |
| int | set_socket_option (const string &optname, const string &optval, string &error_msg) |
| Set a named socket option with a text value. | |
| int | accept_connection (bool is_accepted, string &error_msg) |
| Accept or reject a pending connection. | |
Protected Member Functions | |
| void | set_socket_fd (XorpFd fd) |
| Set the file descriptor of the socket. | |
Private Member Functions | |
| int | enable_data_recv (string &error_msg) |
| Enable receiving of data. | |
| int | enable_recv_pktinfo (bool is_enabled, string &error_msg) |
| Enable/disable receiving information about a packet received on the protocol socket. | |
| void | accept_io_cb (XorpFd fd, IoEventType io_event_type) |
| I/O event callback: new connection is ready to be accepted. | |
| void | connect_io_cb (XorpFd fd, IoEventType io_event_type) |
| I/O event callback: connection opening to the peer has completed. | |
| void | data_io_cb (XorpFd fd, IoEventType io_event_type) |
| I/O event callback: data is received. | |
| void | send_completed_cb (AsyncFileWriter::Event event, const uint8_t *buffer, size_t buffer_bytes, size_t offset) |
| Data transmission completed callback. | |
| void | disconnect_io_cb (XorpFd fd, IoEventType io_event_type) |
| I/O event callback: the peer has closed the connection. | |
Private Attributes | |
| XorpFd | _socket_fd |
| IPvX | _peer_address |
| uint16_t | _peer_port |
| AsyncFileWriter * | _async_writer |
| bool | _limited_broadcast_enabled |
| IPvX | _network_broadcast_address |
A base class for I/O TCP/UDP socket communication.
| IoTcpUdpSocket::IoTcpUdpSocket | ( | FeaDataPlaneManager & | fea_data_plane_manager, |
| const IfTree & | iftree, | ||
| int | family, | ||
| bool | is_tcp | ||
| ) |
| int IoTcpUdpSocket::accept_connection | ( | bool | is_accepted, |
| string & | error_msg | ||
| ) | [virtual] |
| void IoTcpUdpSocket::accept_io_cb | ( | XorpFd | fd, |
| IoEventType | io_event_type | ||
| ) | [private] |
| int IoTcpUdpSocket::bind | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| string & | error_msg | ||
| ) | [virtual] |
| int IoTcpUdpSocket::close | ( | string & | error_msg | ) | [virtual] |
| void IoTcpUdpSocket::connect_io_cb | ( | XorpFd | fd, |
| IoEventType | io_event_type | ||
| ) | [private] |
| void IoTcpUdpSocket::data_io_cb | ( | XorpFd | fd, |
| IoEventType | io_event_type | ||
| ) | [private] |
| void IoTcpUdpSocket::disconnect_io_cb | ( | XorpFd | fd, |
| IoEventType | io_event_type | ||
| ) | [private] |
| int IoTcpUdpSocket::enable_data_recv | ( | string & | error_msg | ) | [private] |
Enable receiving of data.
| error_msg | the error message (if error). |
| int IoTcpUdpSocket::enable_recv_pktinfo | ( | bool | is_enabled, |
| string & | error_msg | ||
| ) | [private] |
Enable/disable receiving information about a packet received on the protocol socket.
If enabled, values such as interface index will be received as well.
| is_enabled | if true, set the option, otherwise reset it. |
| error_msg | the error message (if error). |
| int IoTcpUdpSocket::send | ( | const vector< uint8_t > & | data, |
| string & | error_msg | ||
| ) | [virtual] |
| void IoTcpUdpSocket::send_completed_cb | ( | AsyncFileWriter::Event | event, |
| const uint8_t * | buffer, | ||
| size_t | buffer_bytes, | ||
| size_t | offset | ||
| ) | [private] |
| int IoTcpUdpSocket::send_to | ( | const IPvX & | remote_addr, |
| uint16_t | remote_port, | ||
| const vector< uint8_t > & | data, | ||
| string & | error_msg | ||
| ) | [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). |
Implements IoTcpUdp.
| void IoTcpUdpSocket::set_socket_fd | ( | XorpFd | fd | ) | [inline, protected] |
| int IoTcpUdpSocket::set_socket_option | ( | const string & | optname, |
| const string & | optval, | ||
| string & | error_msg | ||
| ) | [virtual] |
| int IoTcpUdpSocket::set_socket_option | ( | const string & | optname, |
| uint32_t | optval, | ||
| string & | error_msg | ||
| ) | [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). |
Implements IoTcpUdp.
| int IoTcpUdpSocket::start | ( | string & | error_msg | ) | [virtual] |
| int IoTcpUdpSocket::stop | ( | string & | error_msg | ) | [virtual] |
| int IoTcpUdpSocket::tcp_listen | ( | uint32_t | backlog, |
| string & | error_msg | ||
| ) | [virtual] |
| int IoTcpUdpSocket::tcp_open | ( | string & | error_msg | ) | [virtual] |
| int IoTcpUdpSocket::tcp_open_and_bind | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| string & | error_msg | ||
| ) | [virtual] |
| int IoTcpUdpSocket::tcp_open_bind_connect | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| const IPvX & | remote_addr, | ||
| uint16_t | remote_port, | ||
| string & | error_msg | ||
| ) | [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). |
Implements IoTcpUdp.
| int IoTcpUdpSocket::udp_enable_recv | ( | string & | error_msg | ) | [virtual] |
| int IoTcpUdpSocket::udp_open | ( | string & | error_msg | ) | [virtual] |
| int IoTcpUdpSocket::udp_open_and_bind | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| const string & | local_dev, | ||
| int | reuse, | ||
| string & | error_msg | ||
| ) | [virtual] |
| int IoTcpUdpSocket::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 | ||
| ) | [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). |
Implements IoTcpUdp.
| int IoTcpUdpSocket::udp_open_bind_connect | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| const IPvX & | remote_addr, | ||
| uint16_t | remote_port, | ||
| string & | error_msg | ||
| ) | [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). |
Implements IoTcpUdp.
| int IoTcpUdpSocket::udp_open_bind_join | ( | const IPvX & | local_addr, |
| uint16_t | local_port, | ||
| const IPvX & | mcast_addr, | ||
| uint8_t | ttl, | ||
| bool | reuse, | ||
| string & | error_msg | ||
| ) | [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). |
Implements IoTcpUdp.