![]() |
Max OS 0.3
|
Handles the UDP protocol. More...
#include <udp.h>
Public Member Functions | |
| UserDatagramProtocolHandler (InternetProtocolHandler *internet_protocol_handler, common::OutputStream *error_messages) | |
| Construct a new User Datagram 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 recivement of an UDP packet. | |
| UDPSocket * | connect (uint32_t ip, uint16_t port) |
| UDPSocket * | listen (uint16_t port) |
| Listens for incoming packets on the port. | |
| void | disconnect (UDPSocket *socket) |
| Disconnects the socket from the remote IP and port. | |
| void | send (UDPSocket *socket, const uint8_t *data, uint16_t size) |
| Sends a packet to the remote IP and port. | |
Static Public Member Functions | |
| static UDPSocket * | connect (const string &address) |
| Connects to a remote host through the UDP protocol. | |
| static void | bind (UDPSocket *socket, UDPPayloadHandler *udp_payload_handler) |
| Binds a handler to the socket. | |
Protected Attributes | |
| common::Vector< UDPSocket * > | sockets |
| The list of UDP sockets. | |
| common::OutputStream * | errorMessages |
| Where to write error messages. | |
Static Protected Attributes | |
| static UserDatagramProtocolPort | free_ports = 0x8000 |
| The next free port number. | |
| UserDatagramProtocolHandler::UserDatagramProtocolHandler | ( | InternetProtocolHandler * | internet_protocol_handler, |
| common::OutputStream * | error_messages | ||
| ) |
Construct a new User Datagram Protocol Handler object.
| internet_protocol_handler | The Internet protocol handler |
| error_messages | Where to write error messages |
Definition at line 112 of file udp.cpp.
References errorMessages.
|
static |
Binds a handler to the socket.
| socket | The socket to bind the handler to |
| udp_payload_handler | The handler to bind |
Definition at line 308 of file udp.cpp.
References MaxOS::common::EventManager< EventType >::m_handlers.
Connects to a remote host through the UDP protocol.
| address | The address to connect to in the form "IP:PORT" |
Definition at line 211 of file udp.cpp.
Connects the socket to the remote IP and port
| ip | The remote IP address in big endian |
| port | The remote port |
Definition at line 181 of file udp.cpp.
References free_ports, MaxOS::net::InternetProtocolHandler::get_internet_protocol_address(), MaxOS::net::IPV4PayloadHandler::internet_protocol_handler, MaxOS::memory::MemoryManager::kmalloc(), and sockets.
Disconnects the socket from the remote IP and port.
| socket | The socket to disconnect |
Definition at line 248 of file udp.cpp.
References MaxOS::memory::MemoryManager::kfree(), and sockets.
Referenced by MaxOS::net::UDPSocket::disconnect().
|
overridevirtual |
Handle the recivement of an UDP packet.
| source_ip | The source IP address in big endian |
| destination_ip | The destination IP address in big endian |
| payload_data | The UDP payload |
| size | The size of the UDP payload |
Reimplemented from MaxOS::net::IPV4PayloadHandler.
Definition at line 129 of file udp.cpp.
References MaxOS::net::UDPSocket::handle_user_datagram_protocol_payload(), MaxOS::net::UDPSocket::listening, MaxOS::net::UDPSocket::remote_ip, MaxOS::net::UDPSocket::remote_port, and sockets.
Listens for incoming packets on the port.
| port | The port to listen on |
Definition at line 222 of file udp.cpp.
References MaxOS::net::InternetProtocolHandler::get_internet_protocol_address(), MaxOS::net::IPV4PayloadHandler::internet_protocol_handler, MaxOS::memory::MemoryManager::kmalloc(), and sockets.
Sends a packet to the remote IP and port.
| socket | The socket to send the packet from |
| data | The data to send |
| size | The size of the data |
Definition at line 269 of file udp.cpp.
References MaxOS::memory::MemoryManager::kfree(), MaxOS::memory::MemoryManager::kmalloc(), MaxOS::net::UDPSocket::remote_ip, and MaxOS::net::IPV4PayloadHandler::send().
Referenced by MaxOS::net::UDPSocket::send().
|
protected |
Where to write error messages.
Definition at line 117 of file udp.h.
Referenced by UserDatagramProtocolHandler().
|
staticprotected |
|
protected |
The list of UDP sockets.
Definition at line 115 of file udp.h.
Referenced by connect(), disconnect(), handle_internet_protocol_payload(), and listen().