![]() |
Max OS 0.3
|
Handles TCP packets and manages TCP sockets. More...
#include <tcp.h>
Public Member Functions | |
| TransmissionControlProtocolHandler (InternetProtocolHandler *internet_protocol_handler, common::OutputStream *error_messages) | |
| Construct a new Transmission Control Protocol Handler object. | |
| bool | handle_internet_protocol_payload (net::InternetProtocolAddress source_ip, net::InternetProtocolAddress destination_ip, uint8_t *payload_data, uint32_t size) override |
| Handle the TCP message (provider end) | |
| TCPSocket * | connect (InternetProtocolAddress ip, TransmissionControlProtocolPort port) |
| connect to a remote host through the TCP protocol | |
| void | disconnect (TCPSocket *socket) |
| Begin the disconnect process. | |
| virtual TCPSocket * | listen (uint16_t port) |
| Begin listening on a port. | |
| virtual void | bind (TCPSocket *socket, TCPPayloadHandler *handler) |
| bind a data handler to this socket | |
Static Public Member Functions | |
| static TCPSocket * | connect (const string &address) |
| connect to a remote host through the TCP protocol | |
Protected Member Functions | |
| void | send_transmission_control_protocol_packet (TCPSocket *socket, const uint8_t *data, uint16_t size, uint16_t flags=0) |
| send a packet (Throught the provider) | |
Protected Attributes | |
| common::OutputStream * | error_messages |
| Where to write error messages. | |
| common::Vector< TCPSocket * > | sockets |
| The list of connected sockets. | |
Static Protected Attributes | |
| static TransmissionControlProtocolPort | free_ports = 0x8000 |
| The next free port to use for new sockets. | |
Friends | |
| class | TCPSocket |
| TransmissionControlProtocolHandler::TransmissionControlProtocolHandler | ( | InternetProtocolHandler * | internet_protocol_handler, |
| common::OutputStream * | error_messages | ||
| ) |
Construct a new Transmission Control Protocol Handler object.
| internet_protocol_handler | The Internet protocol handler |
| error_messages | Where to write error messages |
Definition at line 160 of file tcp.cpp.
References error_messages.
|
virtual |
bind a data handler to this socket
| socket | The socket to bind the handler to |
| handler | The handler to bind |
Definition at line 581 of file tcp.cpp.
References MaxOS::common::EventManager< EventType >::connect_event_handler().
connect to a remote host through the TCP protocol
| address | The address to connect to in the form "IP:PORT" |
Definition at line 527 of file tcp.cpp.
| TCPSocket * TransmissionControlProtocolHandler::connect | ( | InternetProtocolAddress | ip, |
| TransmissionControlProtocolPort | port | ||
| ) |
connect to a remote host through the TCP protocol
| ip | The IP of the remote host |
| port | The port of the remote host |
Definition at line 484 of file tcp.cpp.
References free_ports, MaxOS::net::InternetProtocolHandler::get_internet_protocol_address(), MaxOS::net::IPV4PayloadHandler::internet_protocol_handler, MaxOS::memory::MemoryManager::kmalloc(), MaxOS::net::TCPSocket::remotePort, send_transmission_control_protocol_packet(), and sockets.
Begin the disconnect process.
| socket | The socket to disconnect |
Definition at line 537 of file tcp.cpp.
References send_transmission_control_protocol_packet(), MaxOS::net::TCPSocket::sequence_number, and MaxOS::net::TCPSocket::state.
Referenced by MaxOS::net::TCPSocket::disconnect().
|
overridevirtual |
Handle the TCP message (provider end)
| source_ip | The source IP address |
| destination_ip | The destination IP address |
| payload_data | The payload |
| size | The size of the payload |
Reimplemented from MaxOS::net::IPV4PayloadHandler.
Definition at line 201 of file tcp.cpp.
References MaxOS::net::TCPSocket::acknowledgement_number, big_endian_16(), big_endian_32(), MaxOS::net::TCPSocket::connected(), MaxOS::net::TCPSocket::disconnected(), error_messages, MaxOS::net::TCPSocket::handle_transmission_control_protocol_payload(), MaxOS::net::TCPSocket::remote_ip, MaxOS::net::TCPSocket::remotePort, send_transmission_control_protocol_packet(), MaxOS::net::TCPSocket::sequence_number, sockets, MaxOS::net::TCPSocket::state, and MaxOS::common::OutputStream::write().
Begin listening on a port.
| port | The port to listen on |
Definition at line 551 of file tcp.cpp.
References MaxOS::net::InternetProtocolHandler::get_internet_protocol_address(), MaxOS::net::IPV4PayloadHandler::internet_protocol_handler, MaxOS::memory::MemoryManager::kmalloc(), sockets, and MaxOS::net::TCPSocket::state.
|
protected |
send a packet (Throught the provider)
| socket | The socket to send the packet from |
| data | The data to send |
| size | The size of the data |
| flags | The flags to send |
Definition at line 420 of file tcp.cpp.
References MaxOS::net::TCPSocket::acknowledgement_number, big_endian_16(), big_endian_32(), MaxOS::net::InternetProtocolHandler::checksum(), MaxOS::memory::MemoryManager::kfree(), MaxOS::memory::MemoryManager::kmalloc(), MaxOS::net::TCPSocket::local_ip, MaxOS::net::TCPSocket::local_port, MaxOS::net::TCPSocket::remote_ip, MaxOS::net::TCPSocket::remotePort, MaxOS::net::IPV4PayloadHandler::send(), and MaxOS::net::TCPSocket::sequence_number.
Referenced by connect(), disconnect(), handle_internet_protocol_payload(), and MaxOS::net::TCPSocket::send().
|
protected |
Where to write error messages.
Definition at line 210 of file tcp.h.
Referenced by handle_internet_protocol_payload(), and TransmissionControlProtocolHandler().
|
staticprotected |
|
protected |
The list of connected sockets.
Definition at line 211 of file tcp.h.
Referenced by connect(), handle_internet_protocol_payload(), and listen().