FreeNOS
Data Structures | Public Types | Public Member Functions | Private Attributes | Static Private Attributes
ICMP Class Reference

Internet Control Message Protocol (ICMP) More...

#include <ICMP.h>

Inheritance diagram for ICMP:
NetworkProtocol Directory File

Data Structures

struct  Header
 Packet header format. More...
 

Public Types

enum  Type { EchoReply = 0, DestinationUnreachable = 3, Redirect = 5, EchoRequest = 8 }
 Packet types. More...
 
typedef struct ICMP::Header Header
 Packet header format. More...
 

Public Member Functions

 ICMP (NetworkServer &server, NetworkDevice &device, NetworkProtocol &parent)
 Constructor. More...
 
virtual ~ICMP ()
 Destructor. More...
 
void setIP (::IPV4 *ip)
 Set IP object. More...
 
virtual FileSystem::Result initialize ()
 Perform initialization. More...
 
ICMPSocketcreateSocket (String &path, const ProcessID pid)
 Creates an ICMP socket. More...
 
void unregisterSockets (const ProcessID pid)
 Remove sockets for a process. More...
 
virtual FileSystem::Result process (const NetworkQueue::Packet *pkt, const Size offset)
 Process incoming network packet. More...
 
FileSystem::Result sendPacket (const IPV4::Address ip, const Header *header, const void *payload, const Size payloadSize)
 Send packet. More...
 
- Public Member Functions inherited from NetworkProtocol
 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 getTransmitPacket (NetworkQueue::Packet **pkt, const void *address, const Size addressSize, const Identifier protocol, const Size payloadSize)
 Get a new packet for transmission. 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...
 

Private Attributes

ICMPFactorym_factory
 
Index< ICMPSocket, MaxIcmpSocketsm_sockets
 

Static Private Attributes

static const Size MaxIcmpSockets = 128u
 

Additional Inherited Members

- Protected Types inherited from NetworkProtocol
enum  Identifier {
  Ethernet = 1, IPV4, ARP, ICMP,
  UDP, TCP
}
 List of known network protocol identifiers. More...
 
- Protected Attributes inherited from NetworkProtocol
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

Internet Control Message Protocol (ICMP)

Definition at line 42 of file ICMP.h.

Member Typedef Documentation

◆ Header

typedef struct ICMP::Header ICMP::Header

Packet header format.

Member Enumeration Documentation

◆ Type

enum ICMP::Type

Packet types.

Enumerator
EchoReply 
DestinationUnreachable 
Redirect 
EchoRequest 

Definition at line 53 of file ICMP.h.

Constructor & Destructor Documentation

◆ ICMP()

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

Constructor.

Parameters
serverReference to the NetworkServer instance
deviceReference to the NetworkDevice instance
parentParent upper-layer protocol

Definition at line 26 of file ICMP.cpp.

◆ ~ICMP()

ICMP::~ICMP ( )
virtual

Destructor.

Definition at line 33 of file ICMP.cpp.

Member Function Documentation

◆ createSocket()

ICMPSocket * ICMP::createSocket ( String path,
const ProcessID  pid 
)

◆ initialize()

FileSystem::Result ICMP::initialize ( )
virtual

◆ process()

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

◆ sendPacket()

FileSystem::Result ICMP::sendPacket ( const IPV4::Address  ip,
const Header header,
const void *  payload,
const Size  payloadSize 
)

◆ setIP()

void ICMP::setIP ( ::IPV4 ip)

Set IP object.

◆ unregisterSockets()

void ICMP::unregisterSockets ( const ProcessID  pid)

Remove sockets for a process.

Parameters
pidProcessID to remove sockets for

Definition at line 126 of file ICMP.cpp.

References DEBUG, ERROR, NetworkSocket::getProcessID(), NetworkProtocol::m_server, m_sockets, MaxIcmpSockets, Index< T, N >::remove(), FileSystem::Success, FileSystemServer::unregisterFile(), and ZERO.

Referenced by NetworkDevice::unregisterSockets().

Field Documentation

◆ m_factory

ICMPFactory* ICMP::m_factory
private

Definition at line 147 of file ICMP.h.

Referenced by initialize().

◆ m_sockets

Index<ICMPSocket, MaxIcmpSockets> ICMP::m_sockets
private

Definition at line 149 of file ICMP.h.

Referenced by createSocket(), process(), and unregisterSockets().

◆ MaxIcmpSockets

const Size ICMP::MaxIcmpSockets = 128u
staticprivate

Definition at line 46 of file ICMP.h.

Referenced by unregisterSockets().


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