FreeNOS
|
Internet Protocol Version 4. More...
#include <IPV4.h>
Data Structures | |
struct | Header |
IP network packet header. More... | |
struct | PseudoHeader |
Pseudo Header. More... | |
Public Types | |
enum | Protocol { ICMP = 1, IGMP = 2, UDP = 17, TCP = 6 } |
Protocol types. More... | |
typedef u32 | Address |
IP-address. More... | |
typedef struct IPV4::Header | Header |
IP network packet header. More... | |
typedef struct IPV4::PseudoHeader | PseudoHeader |
Pseudo Header. More... | |
Public Member Functions | |
IPV4 (NetworkServer &server, NetworkDevice &device, NetworkProtocol &parent) | |
Constructor. More... | |
virtual | ~IPV4 () |
Destructor. More... | |
virtual FileSystem::Result | initialize () |
Perform initialization. More... | |
void | setICMP (::ICMP *icmp) |
Set ICMP instance. More... | |
void | setARP (::ARP *arp) |
Set ARP instance. More... | |
void | setUDP (::UDP *udp) |
Set UDP instance. More... | |
virtual FileSystem::Result | getAddress (Address *address) |
Get current IP address. More... | |
virtual FileSystem::Result | setAddress (const Address *address) |
Set current IP address. 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) |
Process incoming network 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... | |
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... | |
Static Public Member Functions | |
static const String | toString (const Address address) |
Convert address to string. More... | |
static const Address | toAddress (const char *address) |
Convert string to IPV4 address. More... | |
static const u16 | checksum (const void *buffer, const Size length) |
Calculate IP checksum. More... | |
Private Member Functions | |
Protocol | getProtocolByIdentifier (const NetworkProtocol::Identifier id) const |
Convert protocol identifier. More... | |
Private Attributes | |
Address | m_address |
Current IP address. More... | |
::ICMP * | m_icmp |
ICMP instance. More... | |
::ARP * | m_arp |
ARP instance. More... | |
::UDP * | m_udp |
UDP instance. More... | |
u16 | m_id |
Packet ID for IPV4. More... | |
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 u32 IPV4::Address |
typedef struct IPV4::Header IPV4::Header |
IP network packet header.
This header is prepended to every IP packet send on the actual physical link.
typedef struct IPV4::PseudoHeader IPV4::PseudoHeader |
enum IPV4::Protocol |
IPV4::IPV4 | ( | NetworkServer & | server, |
NetworkDevice & | device, | ||
NetworkProtocol & | parent | ||
) |
Constructor.
server | Reference to the NetworkServer instance |
device | Reference to the NetworkDevice instance |
parent | Parent upper-layer protocol |
Calculate IP checksum.
buffer | Input buffer for calculating checksum |
length | Number of bytes in the buffer |
Definition at line 184 of file IPV4.cpp.
References length, read16(), and readBe16().
Referenced by getTransmitPacket(), NetPing::icmpPing(), and ICMP::sendPacket().
|
virtual |
Get current IP address.
address | IPV4 address buffer |
Definition at line 70 of file IPV4.cpp.
References m_address, and FileSystem::Success.
Referenced by ARP::process(), IPV4Address::read(), ARP::sendReply(), and ARP::sendRequest().
|
private |
Convert protocol identifier.
id | NetworkProtocol identifier |
Definition at line 120 of file IPV4.cpp.
References NetworkProtocol::ICMP, ICMP, TCP, NetworkProtocol::UDP, and UDP.
Referenced by getTransmitPacket().
|
virtual |
Get a new packet for transmission.
pkt | On output contains a pointer to a Packet |
address | Address of the destination of this packet |
addressSize | Number of bytes of the address |
protocol | Identifier for the protocol to create the packet for |
payloadSize | Number of payload bytes |
Reimplemented from NetworkProtocol.
Definition at line 133 of file IPV4.cpp.
References IPV4::Header::checksum, checksum(), IPV4::Header::destination, ERROR, IPV4::Header::fragmentOffset, getProtocolByIdentifier(), NetworkProtocol::getTransmitPacket(), IPV4::Header::identification, NetworkProtocol::IPV4, IPV4::Header::length, ARP::lookupAddress(), m_address, m_arp, m_id, NetworkProtocol::m_parent, IPV4::Header::protocol, FileSystem::RetryAgain, IPV4::Header::source, FileSystem::Success, IPV4::Header::timeToLive, IPV4::Header::typeOfService, IPV4::Header::versionIHL, writeBe16(), and writeBe32().
|
virtual |
Perform initialization.
Implements NetworkProtocol.
Definition at line 45 of file IPV4.cpp.
References DEBUG, FileSystemServer::getNextInode(), 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 210 of file IPV4.cpp.
References NetworkQueue::Packet::data, DEBUG, IPV4::Header::destination, ICMP, FileSystem::InvalidArgument, m_address, m_icmp, m_udp, FileSystem::NotFound, UDP::process(), ICMP::process(), IPV4::Header::protocol, readBe32(), toString(), and UDP.
Referenced by Ethernet::process().
|
virtual |
Set current IP address.
address | IPV4 address buffer |
Definition at line 76 of file IPV4.cpp.
References m_address, and FileSystem::Success.
Referenced by Loopback::initialize(), and IPV4Address::write().
void IPV4::setARP | ( | ::ARP * | arp | ) |
void IPV4::setICMP | ( | ::ICMP * | icmp | ) |
void IPV4::setUDP | ( | ::UDP * | udp | ) |
|
static |
Convert string to IPV4 address.
address | Input textual IP address in dot notation (xxx.xxx.xxx.xxx) |
Definition at line 94 of file IPV4.cpp.
References List< T >::count(), ListIterator< T >::hasCurrent(), String::split(), String::toLong(), and ZERO.
Referenced by NetPing::arpPing(), NetSend::exec(), NetPing::icmpPing(), NetCat::initialize(), Loopback::initialize(), and IPV4Address::write().
Convert address to string.
address | Input IP address |
Definition at line 82 of file IPV4.cpp.
Referenced by UDP::checksum(), NetSend::exec(), DhcpClient::exec(), ICMP::process(), ARP::process(), process(), DhcpClient::receiveBootResponse(), DhcpClient::sendBootRequest(), UDP::sendPacket(), ICMP::sendPacket(), ARP::sendRequest(), DhcpClient::setIpAddress(), NetCtl::showDevice(), MpiProxy::udpReceive(), DhcpClient::udpReceive(), NetSend::udpSendMultiple(), and IPV4Address::write().
|
private |
Current IP address.
Definition at line 231 of file IPV4.h.
Referenced by getAddress(), getTransmitPacket(), IPV4(), process(), and setAddress().
|
private |
ARP instance.
Definition at line 237 of file IPV4.h.
Referenced by getTransmitPacket(), and setARP().
|
private |
|
private |
Packet ID for IPV4.
Definition at line 243 of file IPV4.h.
Referenced by getTransmitPacket(), and IPV4().
|
private |