FreeNOS
|
Internet Control Message Protocol (ICMP) More...
#include <ICMP.h>
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... | |
ICMPSocket * | createSocket (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 File * | lookup (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 | |
ICMPFactory * | m_factory |
Index< ICMPSocket, MaxIcmpSockets > | m_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 | |
NetworkServer & | m_server |
Network server instance. More... | |
NetworkDevice & | m_device |
Network device instance. More... | |
NetworkProtocol & | m_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... | |
typedef struct ICMP::Header ICMP::Header |
Packet header format.
enum ICMP::Type |
ICMP::ICMP | ( | NetworkServer & | server, |
NetworkDevice & | device, | ||
NetworkProtocol & | parent | ||
) |
Constructor.
server | Reference to the NetworkServer instance |
device | Reference to the NetworkDevice instance |
parent | Parent upper-layer protocol |
ICMPSocket * ICMP::createSocket | ( | String & | path, |
const ProcessID | pid | ||
) |
Creates an ICMP socket.
Definition at line 87 of file ICMP.cpp.
References DEBUG, ERROR, FileSystemServer::getMountPath(), FileSystemServer::getNextInode(), Index< T, N >::insert(), NetworkProtocol::m_server, m_sockets, FileSystemServer::registerFile(), Index< T, N >::remove(), FileSystem::Success, and ZERO.
Referenced by ICMPFactory::read().
|
virtual |
Perform initialization.
Implements NetworkProtocol.
Definition at line 37 of file ICMP.cpp.
References DEBUG, FileSystemServer::getNextInode(), m_factory, NetworkProtocol::m_server, FileSystemServer::registerDirectory(), FileSystemServer::registerFile(), and FileSystem::Success.
Referenced by NetworkDevice::initialize().
|
virtual |
Process incoming network packet.
pkt | Incoming packet pointer |
offset | Offset for processing |
Implements NetworkProtocol.
Definition at line 48 of file ICMP.cpp.
References ICMP::Header::code, MemoryBlock::copy(), NetworkQueue::Packet::data, DEBUG, EchoReply, EchoRequest, Index< T, N >::get(), ICMPSocket::getAddress(), ICMP::Header::id, m_sockets, readBe32(), sendPacket(), ICMPSocket::setReply(), NetworkQueue::Packet::size, Index< T, N >::size(), IPV4::Header::source, FileSystem::Success, IPV4::toString(), and ICMP::Header::type.
Referenced by IPV4::process().
FileSystem::Result ICMP::sendPacket | ( | const IPV4::Address | ip, |
const Header * | header, | ||
const void * | payload, | ||
const Size | payloadSize | ||
) |
Send packet.
ip | Destination IP address |
header | ICMP packet header |
payload | ICMP packet payload |
payloadSize | Payload size in bytes |
Definition at line 148 of file ICMP.cpp.
References IPV4::checksum(), MemoryBlock::copy(), NetworkQueue::Packet::data, DEBUG, ERROR, NetworkProtocol::getMaximumPacketSize(), NetworkProtocol::getTransmitPacket(), header, NetworkProtocol::ICMP, ICMP::Header::id, NetworkProtocol::m_device, NetworkProtocol::m_parent, readBe16(), FileSystem::RetryAgain, ICMP::Header::sequence, NetworkQueue::Packet::size, FileSystem::Success, IPV4::toString(), NetworkDevice::transmit(), ICMP::Header::type, and write16().
Referenced by process(), and ICMPSocket::write().
void ICMP::setIP | ( | ::IPV4 * | ip | ) |
Set IP object.
void ICMP::unregisterSockets | ( | const ProcessID | pid | ) |
Remove sockets for a process.
pid | ProcessID 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().
|
private |
Definition at line 147 of file ICMP.h.
Referenced by initialize().
|
private |
Definition at line 149 of file ICMP.h.
Referenced by createSocket(), process(), and unregisterSockets().
|
staticprivate |
Definition at line 46 of file ICMP.h.
Referenced by unregisterSockets().