FreeNOS
NetworkProtocol.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_NETWORKPROTOCOL_H
19 #define __LIB_LIBNET_NETWORKPROTOCOL_H
20 
21 #include <Directory.h>
22 #include <Types.h>
23 #include "NetworkQueue.h"
24 
25 class NetworkServer;
26 class NetworkDevice;
27 
39 class NetworkProtocol : public Directory
40 {
41  protected:
42 
47  {
48  Ethernet = 1,
50  ARP,
52  UDP,
54  };
55 
56  public:
57 
66  NetworkDevice &device,
67  NetworkProtocol &parent);
68 
72  virtual ~NetworkProtocol();
73 
74 
80  virtual const Size getMaximumPacketSize() const;
81 
87  virtual FileSystem::Result initialize() = 0;
88 
101  const void *address,
102  const Size addressSize,
103  const Identifier protocol,
104  const Size payloadSize);
105 
115  const Size offset) = 0;
116 
117  protected:
118 
121 
124 
127 };
128 
134 #endif /* __LIB_LIBNET_NETWORKPROTOCOL_H */
NetworkProtocol
Network protocol abstraction class.
Definition: NetworkProtocol.h:39
NetworkProtocol::~NetworkProtocol
virtual ~NetworkProtocol()
Destructor.
Definition: NetworkProtocol.cpp:32
Types.h
NetworkDevice
Network Device abstract class.
Definition: NetworkDevice.h:41
Directory
Directory File functionality.
Definition: Directory.h:59
NetworkProtocol::m_parent
NetworkProtocol & m_parent
Parent upper-layer protocol instance.
Definition: NetworkProtocol.h:126
NetworkQueue.h
NetworkProtocol::UDP
@ UDP
Definition: NetworkProtocol.h:52
NetworkProtocol::IPV4
@ IPV4
Definition: NetworkProtocol.h:49
Ethernet
Ethernet networking protocol.
Definition: Ethernet.h:42
NetworkProtocol::m_device
NetworkDevice & m_device
Network device instance.
Definition: NetworkProtocol.h:123
NetworkServer
Networking server.
Definition: NetworkServer.h:40
NetworkProtocol::getMaximumPacketSize
virtual const Size getMaximumPacketSize() const
Get maximum packet size.
Definition: NetworkProtocol.cpp:36
NetworkProtocol::initialize
virtual FileSystem::Result initialize()=0
Perform initialization.
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
NetworkProtocol::NetworkProtocol
NetworkProtocol(NetworkServer &server, NetworkDevice &device, NetworkProtocol &parent)
Constructor.
Definition: NetworkProtocol.cpp:22
NetworkProtocol::TCP
@ TCP
Definition: NetworkProtocol.h:53
NetworkProtocol::ICMP
@ ICMP
Definition: NetworkProtocol.h:51
NetworkProtocol::getTransmitPacket
virtual FileSystem::Result getTransmitPacket(NetworkQueue::Packet **pkt, const void *address, const Size addressSize, const Identifier protocol, const Size payloadSize)
Get a new packet for transmission.
Definition: NetworkProtocol.cpp:41
NetworkProtocol::m_server
NetworkServer & m_server
Network server instance.
Definition: NetworkProtocol.h:120
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
NetworkProtocol::process
virtual FileSystem::Result process(const NetworkQueue::Packet *pkt, const Size offset)=0
Process incoming network packet.
NetworkProtocol::ARP
@ ARP
Definition: NetworkProtocol.h:50
Directory.h
NetworkQueue::Packet
Represents a network packet.
Definition: NetworkQueue.h:50
NetworkProtocol::Identifier
Identifier
List of known network protocol identifiers.
Definition: NetworkProtocol.h:46