FreeNOS
Public Member Functions | Protected Attributes
NetworkDevice Class Referenceabstract

Network Device abstract class. More...

#include <NetworkDevice.h>

Inheritance diagram for NetworkDevice:
Device File Loopback Sun8iEmac

Public Member Functions

 NetworkDevice (const u32 inode, NetworkServer &server)
 Constructor. More...
 
virtual ~NetworkDevice ()
 Destructor. More...
 
virtual FileSystem::Result initialize ()
 Initialize the device. More...
 
const Size getMaximumPacketSize () const
 Get maximum packet size. More...
 
virtual FileSystem::Result getAddress (Ethernet::Address *address)=0
 Read ethernet address. More...
 
virtual FileSystem::Result setAddress (const Ethernet::Address *address)=0
 Set ethernet address. More...
 
NetworkQueuegetReceiveQueue ()
 Get receive queue. More...
 
NetworkQueuegetTransmitQueue ()
 Get transmit queue. More...
 
void unregisterSockets (const ProcessID pid)
 Remove sockets for a process. More...
 
virtual FileSystem::Result transmit (NetworkQueue::Packet *packet)=0
 Add a network packet to the transmit queue. More...
 
virtual FileSystem::Result process (const NetworkQueue::Packet *packet, const Size offset=0)
 Process a received network packet. More...
 
virtual FileSystem::Result startDMA ()
 Start DMA processing. More...
 
- Public Member Functions inherited from Device
 Device (const u32 inode, const FileSystem::FileType type)
 Constructor. More...
 
virtual ~Device ()
 Destructor. More...
 
virtual const StringgetIdentifier () const
 Get unique device identifier. More...
 
virtual FileSystem::Result interrupt (const Size vector)
 Called when an interrupt has been triggered for this device. More...
 
- Public Member Functions inherited from File
 File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO)
 Constructor function. More...
 
virtual ~File ()
 Destructor function. More...
 
u32 getInode () const
 Get inode number. More...
 
FileSystem::FileType getType () const
 Retrieve our filetype. More...
 
virtual FileSystem::Result read (IOBuffer &buffer, Size &size, const Size offset)
 Read bytes from the file. More...
 
virtual FileSystem::Result write (IOBuffer &buffer, Size &size, const Size offset)
 Write bytes to the file. More...
 
virtual FileSystem::Result status (FileSystem::FileStat &st)
 Retrieve file statistics. More...
 
virtual bool canRead () const
 Check if the File has data ready for reading. More...
 
virtual bool canWrite () const
 Check if the File can be written to. More...
 

Protected Attributes

Size m_maximumPacketSize
 Maximum size of each packet. More...
 
NetworkQueue m_receive
 
NetworkQueue m_transmit
 
NetworkServerm_server
 
Ethernetm_eth
 
ARPm_arp
 
IPV4m_ipv4
 
ICMPm_icmp
 
UDPm_udp
 
- Protected Attributes inherited from Device
String m_identifier
 Unique identifier for this Device. More...
 
- Protected Attributes inherited from File
const u32 m_inode
 Inode number. More...
 
const FileSystem::FileType m_type
 Type of this file. More...
 
UserID m_uid
 Owner of the file. More...
 
GroupID m_gid
 Group of the file. More...
 
FileSystem::FileModes m_access
 Access permissions. More...
 
Size m_size
 Size of the file, in bytes. More...
 

Detailed Description

Network Device abstract class.

Definition at line 41 of file NetworkDevice.h.

Constructor & Destructor Documentation

◆ NetworkDevice()

NetworkDevice::NetworkDevice ( const u32  inode,
NetworkServer server 
)

Constructor.

Parameters
inodeInode number
serverNetworkServer reference

Definition at line 20 of file NetworkDevice.cpp.

References m_arp, m_eth, m_icmp, m_ipv4, m_server, and m_udp.

◆ ~NetworkDevice()

NetworkDevice::~NetworkDevice ( )
virtual

Destructor.

Definition at line 38 of file NetworkDevice.cpp.

Member Function Documentation

◆ getAddress()

virtual FileSystem::Result NetworkDevice::getAddress ( Ethernet::Address address)
pure virtual

Read ethernet address.

Parameters
addressEthernet address reference for output
Returns
Result code

Implemented in Sun8iEmac, and Loopback.

Referenced by Ethernet::initialize().

◆ getMaximumPacketSize()

const Size NetworkDevice::getMaximumPacketSize ( ) const

Get maximum packet size.

Returns
Maximum packet size

Definition at line 69 of file NetworkDevice.cpp.

References m_maximumPacketSize.

Referenced by NetworkProtocol::getMaximumPacketSize().

◆ getReceiveQueue()

NetworkQueue * NetworkDevice::getReceiveQueue ( )

Get receive queue.

Definition at line 74 of file NetworkDevice.cpp.

References m_receive.

◆ getTransmitQueue()

NetworkQueue * NetworkDevice::getTransmitQueue ( )

Get transmit queue.

Definition at line 79 of file NetworkDevice.cpp.

References m_transmit.

Referenced by Ethernet::getTransmitPacket().

◆ initialize()

FileSystem::Result NetworkDevice::initialize ( )
virtual

◆ process()

FileSystem::Result NetworkDevice::process ( const NetworkQueue::Packet packet,
const Size  offset = 0 
)
virtual

Process a received network packet.

Parameters
packetNetwork packet received by the device
offsetNetwork packet payload offset
Returns
Result code

Definition at line 92 of file NetworkDevice.cpp.

References DEBUG, m_eth, and Ethernet::process().

Referenced by Sun8iEmac::receive(), and Loopback::transmit().

◆ setAddress()

virtual FileSystem::Result NetworkDevice::setAddress ( const Ethernet::Address address)
pure virtual

Set ethernet address.

Parameters
addressNew ethernet address to set
Returns
Result code

Implemented in Sun8iEmac, and Loopback.

Referenced by Ethernet::setAddress().

◆ startDMA()

FileSystem::Result NetworkDevice::startDMA ( )
virtual

Start DMA processing.

Returns
Result code

Reimplemented in Sun8iEmac.

Definition at line 101 of file NetworkDevice.cpp.

References DEBUG, and FileSystem::Success.

Referenced by NetworkServer::retryRequests().

◆ transmit()

virtual FileSystem::Result NetworkDevice::transmit ( NetworkQueue::Packet packet)
pure virtual

Add a network packet to the transmit queue.

Parameters
packetPointer to the packet to transmit
Returns
Result code

Implemented in Sun8iEmac, and Loopback.

Referenced by UDP::sendPacket(), ICMP::sendPacket(), ARP::sendReply(), and ARP::sendRequest().

◆ unregisterSockets()

void NetworkDevice::unregisterSockets ( const ProcessID  pid)

Remove sockets for a process.

Parameters
pidProcessID to remove sockets for

Definition at line 84 of file NetworkDevice.cpp.

References DEBUG, m_icmp, m_udp, UDP::unregisterSockets(), and ICMP::unregisterSockets().

Referenced by NetworkServer::onProcessTerminated().

Field Documentation

◆ m_arp

ARP* NetworkDevice::m_arp
protected

Definition at line 148 of file NetworkDevice.h.

Referenced by initialize(), and NetworkDevice().

◆ m_eth

Ethernet* NetworkDevice::m_eth
protected

Definition at line 146 of file NetworkDevice.h.

Referenced by initialize(), NetworkDevice(), and process().

◆ m_icmp

ICMP* NetworkDevice::m_icmp
protected

Definition at line 152 of file NetworkDevice.h.

Referenced by initialize(), NetworkDevice(), and unregisterSockets().

◆ m_ipv4

IPV4* NetworkDevice::m_ipv4
protected

Definition at line 150 of file NetworkDevice.h.

Referenced by Loopback::initialize(), initialize(), and NetworkDevice().

◆ m_maximumPacketSize

Size NetworkDevice::m_maximumPacketSize
protected

Maximum size of each packet.

Definition at line 138 of file NetworkDevice.h.

Referenced by getMaximumPacketSize(), and Sun8iEmac::resetReceive().

◆ m_receive

NetworkQueue NetworkDevice::m_receive
protected

Definition at line 140 of file NetworkDevice.h.

Referenced by getReceiveQueue(), and Sun8iEmac::resetReceive().

◆ m_server

NetworkServer& NetworkDevice::m_server
protected

Definition at line 144 of file NetworkDevice.h.

Referenced by NetworkDevice().

◆ m_transmit

NetworkQueue NetworkDevice::m_transmit
protected

Definition at line 142 of file NetworkDevice.h.

Referenced by getTransmitQueue(), Sun8iEmac::interrupt(), and Loopback::transmit().

◆ m_udp

UDP* NetworkDevice::m_udp
protected

Definition at line 154 of file NetworkDevice.h.

Referenced by initialize(), NetworkDevice(), and unregisterSockets().


The documentation for this class was generated from the following files: