FreeNOS
NetworkDevice.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_NETWORKDEVICE_H
19 #define __LIB_LIBNET_NETWORKDEVICE_H
20 
21 #include <Types.h>
22 #include <Device.h>
23 #include "Ethernet.h"
24 #include "ARP.h"
25 #include "IPV4.h"
26 #include "ICMP.h"
27 #include "UDP.h"
28 #include "NetworkQueue.h"
29 
41 class NetworkDevice : public Device
42 {
43  public:
44 
51  NetworkDevice(const u32 inode,
52  NetworkServer &server);
53 
57  virtual ~NetworkDevice();
58 
65 
71  const Size getMaximumPacketSize() const;
72 
80  virtual FileSystem::Result getAddress(Ethernet::Address *address) = 0;
81 
89  virtual FileSystem::Result setAddress(const Ethernet::Address *address) = 0;
90 
95 
100 
106  void unregisterSockets(const ProcessID pid);
107 
115  virtual FileSystem::Result transmit(NetworkQueue::Packet *packet) = 0;
116 
125  virtual FileSystem::Result process(const NetworkQueue::Packet *packet,
126  const Size offset = 0);
127 
133  virtual FileSystem::Result startDMA();
134 
135  protected:
136 
139 
141 
143 
145 
147 
149 
151 
153 
155 };
156 
162 #endif /* __LIB_LIBNET_NETWORKDEVICE_H */
Device.h
NetworkDevice::m_eth
Ethernet * m_eth
Definition: NetworkDevice.h:146
NetworkDevice::startDMA
virtual FileSystem::Result startDMA()
Start DMA processing.
Definition: NetworkDevice.cpp:101
NetworkDevice::m_server
NetworkServer & m_server
Definition: NetworkDevice.h:144
NetworkDevice::getMaximumPacketSize
const Size getMaximumPacketSize() const
Get maximum packet size.
Definition: NetworkDevice.cpp:69
Types.h
NetworkDevice::m_udp
UDP * m_udp
Definition: NetworkDevice.h:154
NetworkDevice::NetworkDevice
NetworkDevice(const u32 inode, NetworkServer &server)
Constructor.
Definition: NetworkDevice.cpp:20
UDP.h
NetworkDevice::~NetworkDevice
virtual ~NetworkDevice()
Destructor.
Definition: NetworkDevice.cpp:38
NetworkDevice::m_maximumPacketSize
Size m_maximumPacketSize
Maximum size of each packet.
Definition: NetworkDevice.h:138
Ethernet.h
NetworkDevice
Network Device abstract class.
Definition: NetworkDevice.h:41
UDP
User Datagram Protocol (UDP)
Definition: UDP.h:41
Device
Abstract device class interface.
Definition: Device.h:35
NetworkDevice::m_arp
ARP * m_arp
Definition: NetworkDevice.h:148
ProcessID
u32 ProcessID
Process Identification Number.
Definition: Types.h:140
NetworkQueue.h
NetworkDevice::process
virtual FileSystem::Result process(const NetworkQueue::Packet *packet, const Size offset=0)
Process a received network packet.
Definition: NetworkDevice.cpp:92
NetworkQueue
Networking packet queue implementation.
Definition: NetworkQueue.h:37
Ethernet
Ethernet networking protocol.
Definition: Ethernet.h:42
NetworkDevice::m_ipv4
IPV4 * m_ipv4
Definition: NetworkDevice.h:150
Ethernet::Address
Ethernet network address.
Definition: Ethernet.h:52
NetworkServer
Networking server.
Definition: NetworkServer.h:40
NetworkDevice::getTransmitQueue
NetworkQueue * getTransmitQueue()
Get transmit queue.
Definition: NetworkDevice.cpp:79
NetworkDevice::m_receive
NetworkQueue m_receive
Definition: NetworkDevice.h:140
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
ICMP.h
IPV4.h
NetworkDevice::m_icmp
ICMP * m_icmp
Definition: NetworkDevice.h:152
NetworkDevice::getAddress
virtual FileSystem::Result getAddress(Ethernet::Address *address)=0
Read ethernet address.
IPV4
Internet Protocol Version 4.
Definition: IPV4.h:40
ARP.h
NetworkDevice::getReceiveQueue
NetworkQueue * getReceiveQueue()
Get receive queue.
Definition: NetworkDevice.cpp:74
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
NetworkDevice::transmit
virtual FileSystem::Result transmit(NetworkQueue::Packet *packet)=0
Add a network packet to the transmit queue.
NetworkDevice::setAddress
virtual FileSystem::Result setAddress(const Ethernet::Address *address)=0
Set ethernet address.
NetworkDevice::unregisterSockets
void unregisterSockets(const ProcessID pid)
Remove sockets for a process.
Definition: NetworkDevice.cpp:84
NetworkDevice::m_transmit
NetworkQueue m_transmit
Definition: NetworkDevice.h:142
NetworkQueue::Packet
Represents a network packet.
Definition: NetworkQueue.h:50
ARP
Address Resolution Protocol.
Definition: ARP.h:42
NetworkDevice::initialize
virtual FileSystem::Result initialize()
Initialize the device.
Definition: NetworkDevice.cpp:42
ICMP
Internet Control Message Protocol (ICMP)
Definition: ICMP.h:42