Go to the documentation of this file.
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");
virtual ~UDPSocket()
Destructor.
static Size copy(void *dest, const void *src, Size count)
Copy memory from one place to another.
Describes a single packet.
const u32 readBe32(const void *data)
Read 32-bit big endian integer.
struct UDP::Header Header
Packet header format.
FileSystem::Result sendPacket(const NetworkClient::SocketInfo *src, const NetworkClient::SocketInfo *dest, IOBuffer &buffer, const Size size, const Size offset)
Send packet.
const u16 readBe16(const void *data)
Read 16-bit big endian integer.
char * buffer
Points to a buffer for I/O.
const FileSystemMessage * getMessage() const
Get filesystem message.
Packet * pop()
Retrieve packet with data.
#define PAGESIZE
ARM uses 4K pages.
static const Size MaxPackets
Maximum number of packets available.
User Datagram Protocol (UDP)
u32 ProcessID
Process Identification Number.
void release(Packet *packet)
Put unused packet back.
struct IPV4::Header Header
IP network packet header.
bool hasData() const
Check if data packets are available.
Packet * get()
Get unused packet.
virtual FileSystem::Result process(const NetworkQueue::Packet *pkt)
Process incoming network packet.
void setMessage(const FileSystemMessage *msg)
Set filesystem message.
#define DEBUG(msg)
Output a debug message to standard output.
void push(Packet *packet)
Enqueue packet with data.
NetworkClient::SocketInfo m_info
Socket connection.
unsigned short u16
Unsigned 16-bit number.
Abstract Input/Output buffer.
ulong next()
Get next randomized value.
unsigned int u32
Unsigned 32-bit number.
unsigned int Size
Any sane size indicator cannot go negative.
FileSystem::Result bind(UDPSocket *sock, const u16 port)
Bind to UDP port.
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Send UDP data.
Produces random integers using the Linear congruential generator algorithm.
Network socket represents a single logical connection on a protocol.
UDPSocket(const u32 inode, UDP *udp, const ProcessID pid)
Constructor.
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Receive UDP data.
#define ERROR(msg)
Output an error message.
Result
Result code for filesystem Actions.
NetworkQueue m_queue
Incoming packet queue.
ProcessID from
Source process of the message.
FileSystem::Action action
Action to perform.
static const Size PayloadBufferSize
Size of payload memory buffer.
virtual bool canRead() const
Check if the File has data ready for reading.
FileSystem::Result read(void *buffer, const Size size, const Size offset=ZERO)
Read bytes from the I/O buffer.
struct Ethernet::Header Header
Ethernet network packet header.
FileSystem::Result write(const void *buffer, const Size size, const Size offset=ZERO)
Write bytes to the I/O buffer.
Represents a network packet.
const u16 getPort() const
Get associated local port.
UDP * m_udp
UDP protocol instance.
Size size
Size of the buffer.