18#include <FreeNOS/System.h>
31 , m_queue(udp->getMaximumPacketSize())
66 buffer.
write(&info,
sizeof(info));
69 Size sz = size > payloadSize ? payloadSize : size;
70 buffer.
write(udpHdr+1, sz,
sizeof(info));
72 size = sz +
sizeof(info);
85 buffer.
read(&dest,
sizeof(dest));
112 Size packetOffset = 0;
119 buffer.
read(&packetInfo,
sizeof(packetInfo),
sizeof(dest));
132 buffer.
read(&packetInfo,
sizeof(packetInfo), i);
134 "] size = " << packetInfo.
size <<
" offset = " << packetOffset);
139 ERROR(
"failed to send packet: result = " << (
int) r);
166 ERROR(
"udp socket queue full");
ProcessID from
Source process of the message.
Abstract Input/Output buffer.
void setMessage(const FileSystemMessage *msg)
Set filesystem message.
FileSystem::Result read(void *buffer, const Size size, const Size offset=ZERO)
Read bytes from the I/O buffer.
FileSystem::Result write(const void *buffer, const Size size, const Size offset=ZERO)
Write bytes to the I/O buffer.
const FileSystemMessage * getMessage() const
Get filesystem message.
static Size copy(void *dest, const void *src, Size count)
Copy memory from one place to another.
Packet * pop()
Retrieve packet with data.
static const Size PayloadBufferSize
Size of payload memory buffer.
bool hasData() const
Check if data packets are available.
Packet * get()
Get unused packet.
void release(Packet *packet)
Put unused packet back.
void push(Packet *packet)
Enqueue packet with data.
static const Size MaxPackets
Maximum number of packets available.
Network socket represents a single logical connection on a protocol.
NetworkClient::SocketInfo m_info
Socket connection.
Produces random integers using the Linear congruential generator algorithm.
ulong next()
Get next randomized value.
UDPSocket(const u32 inode, UDP *udp, const ProcessID pid)
Constructor.
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Send UDP data.
const u16 getPort() const
Get associated local port.
virtual bool canRead() const
Check if the File has data ready for reading.
UDP * m_udp
UDP protocol instance.
virtual ~UDPSocket()
Destructor.
NetworkQueue m_queue
Incoming packet queue.
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Receive UDP data.
virtual FileSystem::Result process(const NetworkQueue::Packet *pkt)
Process incoming network packet.
User Datagram Protocol (UDP)
FileSystem::Result sendPacket(const NetworkClient::SocketInfo *src, const NetworkClient::SocketInfo *dest, IOBuffer &buffer, const Size size, const Size offset)
Send packet.
FileSystem::Result bind(UDPSocket *sock, const u16 port)
Bind to UDP port.
#define PAGESIZE
ARM uses 4K pages.
u32 ProcessID
Process Identification Number.
unsigned int u32
Unsigned 32-bit number.
#define ERROR(msg)
Output an error message.
const u16 readBe16(const void *data)
Read 16-bit big endian integer.
const u32 readBe32(const void *data)
Read 32-bit big endian integer.
unsigned short u16
Unsigned 16-bit number.
unsigned int Size
Any sane size indicator cannot go negative.
#define DEBUG(msg)
Output a debug message to standard output.
Result
Result code for filesystem Actions.
char * buffer
Points to a buffer for I/O.
FileSystem::Action action
Action to perform.
Size size
Size of the buffer.
Describes a single packet.
Represents a network packet.