FreeNOS
UDPSocket.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIB_LIBNET_UDPSOCKET_H
19 #define __LIB_LIBNET_UDPSOCKET_H
20 
21 #include <Types.h>
22 #include "NetworkSocket.h"
23 #include "NetworkQueue.h"
24 #include "NetworkClient.h"
25 
26 class UDP;
27 
42 class UDPSocket : public NetworkSocket
43 {
44  public:
45 
49  UDPSocket(const u32 inode,
50  UDP *udp,
51  const ProcessID pid);
52 
56  virtual ~UDPSocket();
57 
63  const u16 getPort() const;
64 
75  virtual FileSystem::Result read(IOBuffer & buffer,
76  Size & size,
77  const Size offset);
78 
89  virtual FileSystem::Result write(IOBuffer & buffer,
90  Size & size,
91  const Size offset);
92 
100  virtual bool canRead() const;
101 
109  virtual FileSystem::Result process(const NetworkQueue::Packet *pkt);
110 
111  private:
112 
115 
118 
121 };
122 
128 #endif /* __LIB_LIBNET_UDPSOCKET_H */
UDPSocket::~UDPSocket
virtual ~UDPSocket()
Destructor.
Definition: UDPSocket.cpp:35
Types.h
UDP
User Datagram Protocol (UDP)
Definition: UDP.h:41
ProcessID
u32 ProcessID
Process Identification Number.
Definition: Types.h:140
NetworkQueue.h
NetworkQueue
Networking packet queue implementation.
Definition: NetworkQueue.h:37
UDPSocket::process
virtual FileSystem::Result process(const NetworkQueue::Packet *pkt)
Process incoming network packet.
Definition: UDPSocket.cpp:159
UDPSocket::m_port
u16 m_port
Local port.
Definition: UDPSocket.h:117
u16
unsigned short u16
Unsigned 16-bit number.
Definition: Types.h:56
IOBuffer
Abstract Input/Output buffer.
Definition: IOBuffer.h:37
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
UDPSocket::write
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Send UDP data.
Definition: UDPSocket.cpp:77
NetworkSocket
Network socket represents a single logical connection on a protocol.
Definition: NetworkSocket.h:37
UDPSocket::UDPSocket
UDPSocket(const u32 inode, UDP *udp, const ProcessID pid)
Constructor.
Definition: UDPSocket.cpp:25
UDPSocket::read
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Receive UDP data.
Definition: UDPSocket.cpp:44
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
UDPSocket::m_queue
NetworkQueue m_queue
Incoming packet queue.
Definition: UDPSocket.h:120
UDPSocket::canRead
virtual bool canRead() const
Check if the File has data ready for reading.
Definition: UDPSocket.cpp:154
NetworkClient.h
NetworkQueue::Packet
Represents a network packet.
Definition: NetworkQueue.h:50
UDPSocket::getPort
const u16 getPort() const
Get associated local port.
Definition: UDPSocket.cpp:39
UDPSocket::m_udp
UDP * m_udp
UDP protocol instance.
Definition: UDPSocket.h:114
UDPSocket
User Datagram Protocol (UDP) socket.
Definition: UDPSocket.h:42
NetworkSocket.h