FreeNOS
|
User Datagram Protocol (UDP) socket. More...
#include <UDPSocket.h>
Public Member Functions | |
UDPSocket (const u32 inode, UDP *udp, const ProcessID pid) | |
Constructor. More... | |
virtual | ~UDPSocket () |
Destructor. More... | |
const u16 | getPort () const |
Get associated local port. More... | |
virtual FileSystem::Result | read (IOBuffer &buffer, Size &size, const Size offset) |
Receive UDP data. More... | |
virtual FileSystem::Result | write (IOBuffer &buffer, Size &size, const Size offset) |
Send UDP data. More... | |
virtual bool | canRead () const |
Check if the File has data ready for reading. More... | |
virtual FileSystem::Result | process (const NetworkQueue::Packet *pkt) |
Process incoming network packet. More... | |
Public Member Functions inherited from NetworkSocket | |
NetworkSocket (const u32 inode, const Size packetSize, const ProcessID pid) | |
Constructor. More... | |
virtual | ~NetworkSocket () |
Destructor. More... | |
ProcessID | getProcessID () const |
Get owner ProcessID. More... | |
Public Member Functions inherited from File | |
File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO) | |
Constructor function. More... | |
virtual | ~File () |
Destructor function. More... | |
u32 | getInode () const |
Get inode number. More... | |
FileSystem::FileType | getType () const |
Retrieve our filetype. More... | |
virtual FileSystem::Result | status (FileSystem::FileStat &st) |
Retrieve file statistics. More... | |
virtual bool | canWrite () const |
Check if the File can be written to. More... | |
Private Attributes | |
UDP * | m_udp |
UDP protocol instance. More... | |
u16 | m_port |
Local port. More... | |
NetworkQueue | m_queue |
Incoming packet queue. More... | |
Additional Inherited Members | |
Protected Attributes inherited from NetworkSocket | |
const ProcessID | m_pid |
ProcessID which owns this socket. More... | |
NetworkQueue | m_receive |
Receive queue. More... | |
NetworkQueue | m_transmit |
Transmit queue. More... | |
NetworkClient::SocketInfo | m_info |
Socket connection. More... | |
Protected Attributes inherited from File | |
const u32 | m_inode |
Inode number. More... | |
const FileSystem::FileType | m_type |
Type of this file. More... | |
UserID | m_uid |
Owner of the file. More... | |
GroupID | m_gid |
Group of the file. More... | |
FileSystem::FileModes | m_access |
Access permissions. More... | |
Size | m_size |
Size of the file, in bytes. More... | |
User Datagram Protocol (UDP) socket.
UDP sockets accept payloads to send when writing and read payloads when receiving payloads.
Definition at line 42 of file UDPSocket.h.
Constructor.
Definition at line 25 of file UDPSocket.cpp.
|
virtual |
Destructor.
Definition at line 35 of file UDPSocket.cpp.
|
virtual |
Check if the File has data ready for reading.
When this function returns true, it can be read without blocking.
Reimplemented from File.
Definition at line 154 of file UDPSocket.cpp.
References NetworkQueue::hasData(), and m_queue.
const u16 UDPSocket::getPort | ( | ) | const |
Get associated local port.
Definition at line 39 of file UDPSocket.cpp.
References m_port.
|
virtual |
Process incoming network packet.
pkt | Incoming packet pointer |
Implements NetworkSocket.
Definition at line 159 of file UDPSocket.cpp.
References MemoryBlock::copy(), NetworkQueue::Packet::data, DEBUG, ERROR, NetworkQueue::get(), FileSystem::IOError, m_queue, NetworkQueue::push(), NetworkQueue::Packet::size, and FileSystem::Success.
|
virtual |
Receive UDP data.
buffer | Input/Output buffer to output bytes to. |
size | Maximum number of bytes to read on input. On output, the actual number of bytes read. |
offset | Offset inside the file to start reading. |
Reimplemented from File.
Definition at line 44 of file UDPSocket.cpp.
References NetworkClient::SocketInfo::address, NetworkQueue::Packet::data, DEBUG, m_queue, NetworkQueue::pop(), NetworkClient::SocketInfo::port, readBe16(), readBe32(), NetworkQueue::release(), FileSystem::RetryAgain, NetworkQueue::Packet::size, IPV4::Header::source, UDP::Header::sourcePort, FileSystem::Success, and IOBuffer::write().
|
virtual |
Send UDP data.
buffer | Input/Output buffer to input bytes from. |
size | Maximum number of bytes to write on input. On output, the actual number of bytes written. |
offset | Offset inside the file to start writing. |
Reimplemented from File.
Definition at line 77 of file UDPSocket.cpp.
References FileSystemMessage::action, NetworkClient::SocketInfo::action, NetworkClient::SocketInfo::address, NetworkClient::PacketInfo::address, UDP::bind(), FileSystemMessage::buffer, MemoryBlock::copy(), DEBUG, ERROR, ChannelMessage::from, IOBuffer::getMessage(), NetworkClient::Listen, NetworkSocket::m_info, m_udp, NetworkQueue::MaxPackets, Randomizer::next(), FileSystem::NotSupported, PAGESIZE, NetworkQueue::PayloadBufferSize, NetworkClient::SocketInfo::port, IOBuffer::read(), NetworkClient::SendMultiple, UDP::sendPacket(), NetworkClient::SendSingle, IOBuffer::setMessage(), FileSystemMessage::size, NetworkClient::PacketInfo::size, FileSystem::Success, and FileSystem::WriteFile.
|
private |
|
private |
Incoming packet queue.
Definition at line 120 of file UDPSocket.h.
|
private |