FreeNOS
Public Member Functions | Protected Types | Protected Attributes
NetworkProtocol Class Referenceabstract

Network protocol abstraction class. More...

#include <NetworkProtocol.h>

Inheritance diagram for NetworkProtocol:
Directory File ARP Ethernet ICMP IPV4 UDP

Public Member Functions

 NetworkProtocol (NetworkServer &server, NetworkDevice &device, NetworkProtocol &parent)
 Constructor. More...
 
virtual ~NetworkProtocol ()
 Destructor. More...
 
virtual const Size getMaximumPacketSize () const
 Get maximum packet size. More...
 
virtual FileSystem::Result initialize ()=0
 Perform initialization. More...
 
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. More...
 
virtual FileSystem::Result process (const NetworkQueue::Packet *pkt, const Size offset)=0
 Process incoming network packet. More...
 
- Public Member Functions inherited from Directory
 Directory (const u32 inode)
 Constructor. More...
 
virtual ~Directory ()
 Destructor. More...
 
virtual FileSystem::Result read (IOBuffer &buffer, Size &size, const Size offset)
 Read directory entries. More...
 
virtual Filelookup (const char *name)
 Retrieve a File from storage. More...
 
void insert (FileSystem::FileType type, const char *name)
 Insert a new directory entry. More...
 
void remove (const char *name)
 Remove a directory entry. More...
 
void clear ()
 Clears the internal list of entries. 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 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 Types

enum  Identifier {
  Ethernet = 1, IPV4, ARP, ICMP,
  UDP, TCP
}
 List of known network protocol identifiers. More...
 

Protected Attributes

NetworkServerm_server
 Network server instance. More...
 
NetworkDevicem_device
 Network device instance. More...
 
NetworkProtocolm_parent
 Parent upper-layer protocol instance. 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 protocol abstraction class.

Definition at line 39 of file NetworkProtocol.h.

Member Enumeration Documentation

◆ Identifier

List of known network protocol identifiers.

Enumerator
Ethernet 
IPV4 
ARP 
ICMP 
UDP 
TCP 

Definition at line 46 of file NetworkProtocol.h.

Constructor & Destructor Documentation

◆ NetworkProtocol()

NetworkProtocol::NetworkProtocol ( NetworkServer server,
NetworkDevice device,
NetworkProtocol parent 
)

Constructor.

Parameters
serverReference to the NetworkServer instance
deviceReference to the NetworkDevice instance
parentParent upper-layer protocol (or use this for no parent)

Definition at line 22 of file NetworkProtocol.cpp.

◆ ~NetworkProtocol()

NetworkProtocol::~NetworkProtocol ( )
virtual

Destructor.

Definition at line 32 of file NetworkProtocol.cpp.

Member Function Documentation

◆ getMaximumPacketSize()

const Size NetworkProtocol::getMaximumPacketSize ( ) const
virtual

Get maximum packet size.

Returns
Packet size in bytes

Definition at line 36 of file NetworkProtocol.cpp.

References NetworkDevice::getMaximumPacketSize(), and m_device.

Referenced by UDP::sendPacket(), and ICMP::sendPacket().

◆ getTransmitPacket()

FileSystem::Result NetworkProtocol::getTransmitPacket ( NetworkQueue::Packet **  pkt,
const void *  address,
const Size  addressSize,
const Identifier  protocol,
const Size  payloadSize 
)
virtual

Get a new packet for transmission.

Parameters
pktOn output contains a pointer to a Packet
addressAddress of the destination of this packet
addressSizeNumber of bytes of the address
protocolIdentifier for the protocol to create the packet for
payloadSizeNumber of payload bytes
Returns
Result code

Reimplemented in IPV4, and Ethernet.

Definition at line 41 of file NetworkProtocol.cpp.

References FileSystem::NotSupported.

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

◆ initialize()

virtual FileSystem::Result NetworkProtocol::initialize ( )
pure virtual

Perform initialization.

Returns
Result code

Implemented in ARP, IPV4, Ethernet, ICMP, and UDP.

◆ process()

virtual FileSystem::Result NetworkProtocol::process ( const NetworkQueue::Packet pkt,
const Size  offset 
)
pure virtual

Process incoming network packet.

Parameters
pktIncoming packet pointer
offsetOffset for processing
Returns
Result code

Implemented in IPV4, ARP, Ethernet, ICMP, and UDP.

Field Documentation

◆ m_device

NetworkDevice& NetworkProtocol::m_device
protected

◆ m_parent

NetworkProtocol& NetworkProtocol::m_parent
protected

Parent upper-layer protocol instance.

Definition at line 126 of file NetworkProtocol.h.

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

◆ m_server

NetworkServer& NetworkProtocol::m_server
protected

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