|
FreeNOS
|
Address Resolution Protocol. More...
#include <ARP.h>
Data Structures | |
| struct | ARPCache |
| ARP table cache entry. More... | |
| struct | Header |
| ARP network packet header. More... | |
Public Types | |
| enum | HardwareType { Ethernet = 1 } |
| ARP hardware types. More... | |
| enum | ProtocolType { IPV4 = 0x0800 } |
| ARP inter-network protocol types. More... | |
| enum | Operation { Request = 1, Reply = 2 } |
| ARP message types (operation codes) More... | |
| typedef struct ARP::Header | Header |
| ARP network packet header. More... | |
Public Member Functions | |
| ARP (NetworkServer &server, NetworkDevice &device, NetworkProtocol &parent) | |
| Constructor. More... | |
| virtual | ~ARP () |
| Destructor. More... | |
| virtual FileSystem::Result | initialize () |
| Perform initialization. More... | |
| void | setIP (::IPV4 *ip) |
| Set IPV4 instance. More... | |
| FileSystem::Result | lookupAddress (const IPV4::Address *ipAddr, Ethernet::Address *ethAddr) |
| Lookup Ethernet address for an IP. More... | |
| FileSystem::Result | sendRequest (const IPV4::Address address) |
| Send ARP request. More... | |
| FileSystem::Result | sendReply (const Ethernet::Address *ethaddr, const IPV4::Address ipAddr) |
| Send ARP reply. 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... | |
| 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 Types | |
| typedef struct ARP::ARPCache | ARPCache |
| ARP table cache entry. More... | |
Private Member Functions | |
| ARPCache * | insertCacheEntry (const IPV4::Address ipAddr) |
| Insert a new entry to the ARP cache. More... | |
| ARPCache * | getCacheEntry (const IPV4::Address ipAddr) |
| Retrieve cache entry by IP. More... | |
| void | updateCacheEntry (const IPV4::Address ipAddr, const Ethernet::Address *ethAddr) |
| Update cache entry. More... | |
Private Attributes | |
| ARPSocket * | m_sock |
| The single ARP socket. More... | |
| ::IPV4 * | m_ip |
| IPV4 instance object. More... | |
| HashTable< IPV4::Address, ARPCache * > | m_cache |
| Contains a cached mapping from IP to Ethernet addresses. More... | |
| KernelTimer | m_kernelTimer |
| Provides access to the kernel timer. More... | |
Static Private Attributes | |
| static const Size | MaxRetries = 3 |
| Maximum number of retries for ARP lookup. 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... | |
|
private |
ARP table cache entry.
| typedef struct ARP::Header ARP::Header |
| enum ARP::HardwareType |
| enum ARP::Operation |
| enum ARP::ProtocolType |
| ARP::ARP | ( | NetworkServer & | server, |
| NetworkDevice & | device, | ||
| NetworkProtocol & | parent | ||
| ) |
Constructor.
| server | Reference to the NetworkServer instance |
| device | Reference to the NetworkDevice instance |
| parent | Parent upper-layer protocol |
Definition at line 25 of file ARP.cpp.
References m_ip.
|
virtual |
Destructor.
Definition at line 33 of file ARP.cpp.
References HashIterator< K, V >::hasCurrent(), and m_cache.
|
private |
Retrieve cache entry by IP.
| ipAddr | IP address to lookup |
Definition at line 55 of file ARP.cpp.
References entry, insertCacheEntry(), and m_cache.
Referenced by lookupAddress(), sendRequest(), and updateCacheEntry().
|
virtual |
Perform initialization.
Implements NetworkProtocol.
Definition at line 41 of file ARP.cpp.
References FileSystemServer::getNextInode(), NetworkProtocol::m_server, m_sock, FileSystemServer::registerDirectory(), FileSystemServer::registerFile(), and FileSystem::Success.
Referenced by NetworkDevice::initialize().
|
private |
Insert a new entry to the ARP cache.
| ipAddr | IP address to add |
Definition at line 64 of file ARP.cpp.
References entry, m_cache, and MemoryBlock::set().
Referenced by getCacheEntry().
| FileSystem::Result ARP::lookupAddress | ( | const IPV4::Address * | ipAddr, |
| Ethernet::Address * | ethAddr | ||
| ) |
Lookup Ethernet address for an IP.
| ipAddr | Input IP address to lookup |
| ethAddr | Output Ethernet address when found |
Definition at line 86 of file ARP.cpp.
References MemoryBlock::copy(), DEBUG, entry, ERROR, Timer::Info::frequency, getCacheEntry(), Timer::getCurrent(), Timer::isExpired(), m_kernelTimer, NetworkProtocol::m_server, FileSystem::RetryAgain, sendRequest(), MemoryBlock::set(), ChannelServer< Base, MsgType >::setTimeout(), FileSystem::Success, KernelTimer::tick(), and Timer::Info::ticks.
Referenced by IPV4::getTransmitPacket(), ARPSocket::read(), and ARPSocket::write().
|
virtual |
Process incoming network packet.
| pkt | Incoming packet pointer |
| offset | Offset for processing |
Implements NetworkProtocol.
Definition at line 246 of file ARP.cpp.
References NetworkQueue::Packet::data, DEBUG, ARP::Header::etherSender, ARP::Header::etherTarget, IPV4::getAddress(), FileSystem::InvalidArgument, ARP::Header::ipSender, ARP::Header::ipTarget, m_ip, m_sock, ARP::Header::operation, ARPSocket::process(), readBe16(), readBe32(), Reply, Request, sendReply(), Ethernet::Header::source, FileSystem::Success, IPV4::toString(), and updateCacheEntry().
Referenced by Ethernet::process().
| FileSystem::Result ARP::sendReply | ( | const Ethernet::Address * | ethaddr, |
| const IPV4::Address | ipAddr | ||
| ) |
Send ARP reply.
| ethaddr | Ethernet address to send reply to |
| ipAddr | IP address of the origin |
Definition at line 197 of file ARP.cpp.
References NetworkProtocol::ARP, MemoryBlock::copy(), NetworkQueue::Packet::data, DEBUG, Ethernet::Header::destination, ERROR, Ethernet, ARP::Header::etherSender, ARP::Header::etherTarget, IPV4::getAddress(), NetworkProtocol::getTransmitPacket(), ARP::Header::hardwareLength, ARP::Header::hardwareType, FileSystem::InvalidArgument, ARP::Header::ipSender, ARP::Header::ipTarget, IPV4, NetworkProtocol::m_device, m_ip, NetworkProtocol::m_parent, ARP::Header::operation, ARP::Header::protocolLength, ARP::Header::protocolType, Reply, FileSystem::RetryAgain, NetworkQueue::Packet::size, Ethernet::Header::source, FileSystem::Success, NetworkDevice::transmit(), writeBe16(), and writeBe32().
Referenced by process().
| FileSystem::Result ARP::sendRequest | ( | const IPV4::Address | address | ) |
Send ARP request.
| address | IPV4 address to lookup |
Definition at line 133 of file ARP.cpp.
References NetworkProtocol::ARP, MemoryBlock::copy(), NetworkQueue::Packet::data, DEBUG, Ethernet::Header::destination, entry, ERROR, Ethernet, ARP::Header::etherSender, ARP::Header::etherTarget, IPV4::getAddress(), getCacheEntry(), Timer::getCurrent(), NetworkProtocol::getTransmitPacket(), ARP::Header::hardwareLength, ARP::Header::hardwareType, ARP::Header::ipSender, ARP::Header::ipTarget, IPV4, NetworkProtocol::m_device, m_ip, m_kernelTimer, NetworkProtocol::m_parent, MaxRetries, FileSystem::NotFound, ARP::Header::operation, ARP::Header::protocolLength, ARP::Header::protocolType, Request, FileSystem::RetryAgain, MemoryBlock::set(), NetworkQueue::Packet::size, Ethernet::Header::source, FileSystem::Success, KernelTimer::tick(), IPV4::toString(), NetworkDevice::transmit(), writeBe16(), and writeBe32().
Referenced by lookupAddress().
| void ARP::setIP | ( | ::IPV4 * | ip | ) |
|
private |
Update cache entry.
| ipAddr | IP address for update |
| ethAddr | Ethernet address for update |
Definition at line 75 of file ARP.cpp.
References MemoryBlock::copy(), entry, and getCacheEntry().
Referenced by process().
|
private |
Contains a cached mapping from IP to Ethernet addresses.
Definition at line 222 of file ARP.h.
Referenced by getCacheEntry(), insertCacheEntry(), and ~ARP().
|
private |
IPV4 instance object.
Definition at line 219 of file ARP.h.
Referenced by ARP(), process(), sendReply(), sendRequest(), and setIP().
|
private |
Provides access to the kernel timer.
Definition at line 225 of file ARP.h.
Referenced by lookupAddress(), and sendRequest().
|
private |
The single ARP socket.
Definition at line 216 of file ARP.h.
Referenced by initialize(), and process().
|
staticprivate |
Maximum number of retries for ARP lookup.
Definition at line 47 of file ARP.h.
Referenced by sendRequest().
1.8.17