FreeNOS
Public Member Functions | Private Attributes
ICMPSocket Class Reference

Internet Control Message Protocol (ICMP) socket. More...

#include <ICMPSocket.h>

Inheritance diagram for ICMPSocket:
NetworkSocket File

Public Member Functions

 ICMPSocket (const u32 inode, ICMP *icmp, const ProcessID pid)
 Constructor. More...
 
virtual ~ICMPSocket ()
 Destructor. More...
 
const IPV4::Address getAddress () const
 Get associated IP host. More...
 
virtual FileSystem::Result read (IOBuffer &buffer, Size &size, const Size offset)
 Read ICMP response. More...
 
virtual FileSystem::Result write (IOBuffer &buffer, Size &size, const Size offset)
 Send ICMP request. More...
 
virtual FileSystem::Result process (const NetworkQueue::Packet *pkt)
 Process incoming network packet. More...
 
void setReply (const ICMP::Header *reply)
 Set ICMP reply. More...
 
- Public Member Functions inherited from NetworkSocket
 NetworkSocket (const u32 inode, const Size packetSize, const ProcessID pid)
 Constructor. More...
 
virtual ~NetworkSocket ()
 Destructor. More...
 
ProcessID getProcessID () const
 Get owner ProcessID. 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 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

ICMPm_icmp
 ICMP protocol instance. More...
 
ICMP::Header m_reply
 Reply. More...
 
bool m_gotReply
 

Additional Inherited Members

- Protected Attributes inherited from NetworkSocket
const ProcessID m_pid
 ProcessID which owns this socket. More...
 
NetworkQueue m_receive
 Receive queue. More...
 
NetworkQueue m_transmit
 Transmit queue. More...
 
NetworkClient::SocketInfo m_info
 Socket connection. 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) socket.

ICMP sockets are associated with one IP-host and receive packets from that host and allow sending packets to that host.

Definition at line 42 of file ICMPSocket.h.

Constructor & Destructor Documentation

◆ ICMPSocket()

ICMPSocket::ICMPSocket ( const u32  inode,
ICMP icmp,
const ProcessID  pid 
)

Constructor.

Parameters
inodeInode number
icmpICMP object pointer
pidProcessID owning this socket

Definition at line 25 of file ICMPSocket.cpp.

References m_gotReply, m_icmp, NetworkSocket::m_info, and MemoryBlock::set().

◆ ~ICMPSocket()

ICMPSocket::~ICMPSocket ( )
virtual

Destructor.

Definition at line 35 of file ICMPSocket.cpp.

Member Function Documentation

◆ getAddress()

const IPV4::Address ICMPSocket::getAddress ( ) const

Get associated IP host.

Returns
IPV4::Address of the connected host

Definition at line 39 of file ICMPSocket.cpp.

References NetworkClient::SocketInfo::address, and NetworkSocket::m_info.

Referenced by ICMP::process().

◆ process()

FileSystem::Result ICMPSocket::process ( const NetworkQueue::Packet pkt)
virtual

Process incoming network packet.

Parameters
pktIncoming packet pointer
Returns
Result code

Implements NetworkSocket.

Definition at line 82 of file ICMPSocket.cpp.

References DEBUG, and FileSystem::Success.

◆ read()

FileSystem::Result ICMPSocket::read ( IOBuffer buffer,
Size size,
const Size  offset 
)
virtual

Read ICMP response.

Parameters
bufferInput/Output buffer to output bytes to.
sizeMaximum number of bytes to read on input. On output, the actual number of bytes read.
offsetOffset inside the file to start reading.
Returns
Result code

Reimplemented from File.

Definition at line 44 of file ICMPSocket.cpp.

References DEBUG, m_gotReply, m_reply, FileSystem::RetryAgain, FileSystem::Success, and IOBuffer::write().

◆ setReply()

void ICMPSocket::setReply ( const ICMP::Header reply)

Set ICMP reply.

Parameters
replyICMP reply header

Definition at line 89 of file ICMPSocket.cpp.

References MemoryBlock::copy(), DEBUG, header, m_gotReply, and m_reply.

Referenced by ICMP::process().

◆ write()

FileSystem::Result ICMPSocket::write ( IOBuffer buffer,
Size size,
const Size  offset 
)
virtual

Send ICMP request.

Parameters
bufferInput/Output buffer to input bytes from.
sizeMaximum number of bytes to write on input. On output, the actual number of bytes written.
offsetOffset inside the file to start writing.
Returns
Result code

Reimplemented from File.

Definition at line 61 of file ICMPSocket.cpp.

References NetworkClient::SocketInfo::address, DEBUG, header, m_icmp, NetworkSocket::m_info, IOBuffer::read(), ICMP::sendPacket(), FileSystem::Success, and ZERO.

Field Documentation

◆ m_gotReply

bool ICMPSocket::m_gotReply
private

Definition at line 120 of file ICMPSocket.h.

Referenced by ICMPSocket(), read(), and setReply().

◆ m_icmp

ICMP* ICMPSocket::m_icmp
private

ICMP protocol instance.

Definition at line 116 of file ICMPSocket.h.

Referenced by ICMPSocket(), and write().

◆ m_reply

ICMP::Header ICMPSocket::m_reply
private

Reply.

Definition at line 119 of file ICMPSocket.h.

Referenced by read(), and setReply().


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