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
41class 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
81
89 virtual FileSystem::Result setAddress(const Ethernet::Address *address) = 0;
90
95
100
106 void unregisterSockets(const ProcessID pid);
107
116
125 virtual FileSystem::Result process(const NetworkQueue::Packet *packet,
126 const Size offset = 0);
127
134
135 protected:
136
139
141
143
145
147
149
151
153
155};
156
162#endif /* __LIB_LIBNET_NETWORKDEVICE_H */
Address Resolution Protocol.
Definition ARP.h:43
Abstract device class interface.
Definition Device.h:36
Ethernet networking protocol.
Definition Ethernet.h:43
Internet Control Message Protocol (ICMP)
Definition ICMP.h:43
Internet Protocol Version 4.
Definition IPV4.h:41
Network Device abstract class.
NetworkQueue m_receive
virtual FileSystem::Result transmit(NetworkQueue::Packet *packet)=0
Add a network packet to the transmit queue.
Ethernet * m_eth
virtual FileSystem::Result setAddress(const Ethernet::Address *address)=0
Set ethernet address.
Size m_maximumPacketSize
Maximum size of each packet.
virtual FileSystem::Result process(const NetworkQueue::Packet *packet, const Size offset=0)
Process a received network packet.
virtual ~NetworkDevice()
Destructor.
virtual FileSystem::Result startDMA()
Start DMA processing.
NetworkQueue * getTransmitQueue()
Get transmit queue.
virtual FileSystem::Result initialize()
Initialize the device.
const Size getMaximumPacketSize() const
Get maximum packet size.
NetworkQueue m_transmit
NetworkQueue * getReceiveQueue()
Get receive queue.
NetworkServer & m_server
virtual FileSystem::Result getAddress(Ethernet::Address *address)=0
Read ethernet address.
void unregisterSockets(const ProcessID pid)
Remove sockets for a process.
Networking packet queue implementation.
Networking server.
User Datagram Protocol (UDP)
Definition UDP.h:42
u32 ProcessID
Process Identification Number.
Definition Types.h:140
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
Ethernet network address.
Definition Ethernet.h:53
Represents a network packet.