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

Address Resolution Protocol. More...

#include <ARP.h>

Inheritance diagram for ARP:
NetworkProtocol Directory File

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 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 Types

typedef struct ARP::ARPCache ARPCache
 ARP table cache entry. More...
 

Private Member Functions

ARPCacheinsertCacheEntry (const IPV4::Address ipAddr)
 Insert a new entry to the ARP cache. More...
 
ARPCachegetCacheEntry (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

ARPSocketm_sock
 The single ARP socket. More...
 
::IPV4m_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
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

Address Resolution Protocol.

Definition at line 42 of file ARP.h.

Member Typedef Documentation

◆ ARPCache

typedef struct ARP::ARPCache ARP::ARPCache
private

ARP table cache entry.

◆ Header

typedef struct ARP::Header ARP::Header

ARP network packet header.

This header is prepended to every ARP packet send on the actual physical link.

Member Enumeration Documentation

◆ HardwareType

ARP hardware types.

Enumerator
Ethernet 

Definition at line 66 of file ARP.h.

◆ Operation

ARP message types (operation codes)

Enumerator
Request 
Reply 

Definition at line 82 of file ARP.h.

◆ ProtocolType

ARP inter-network protocol types.

Enumerator
IPV4 

Definition at line 74 of file ARP.h.

Constructor & Destructor Documentation

◆ ARP()

ARP::ARP ( 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 25 of file ARP.cpp.

References m_ip.

◆ ~ARP()

ARP::~ARP ( )
virtual

Destructor.

Definition at line 33 of file ARP.cpp.

References HashIterator< K, V >::hasCurrent(), and m_cache.

Member Function Documentation

◆ getCacheEntry()

ARP::ARPCache * ARP::getCacheEntry ( const IPV4::Address  ipAddr)
private

Retrieve cache entry by IP.

Parameters
ipAddrIP address to lookup
Returns
ARPCache object pointer or ZERO if not found

Definition at line 55 of file ARP.cpp.

References entry, insertCacheEntry(), and m_cache.

Referenced by lookupAddress(), sendRequest(), and updateCacheEntry().

◆ initialize()

FileSystem::Result ARP::initialize ( )
virtual

◆ insertCacheEntry()

ARP::ARPCache * ARP::insertCacheEntry ( const IPV4::Address  ipAddr)
private

Insert a new entry to the ARP cache.

Parameters
ipAddrIP address to add
Returns
ARPCache object pointer

Definition at line 64 of file ARP.cpp.

References entry, m_cache, and MemoryBlock::set().

Referenced by getCacheEntry().

◆ lookupAddress()

FileSystem::Result ARP::lookupAddress ( const IPV4::Address ipAddr,
Ethernet::Address ethAddr 
)

◆ process()

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

◆ sendReply()

FileSystem::Result ARP::sendReply ( const Ethernet::Address ethaddr,
const IPV4::Address  ipAddr 
)

◆ sendRequest()

FileSystem::Result ARP::sendRequest ( const IPV4::Address  address)

◆ setIP()

void ARP::setIP ( ::IPV4 ip)

Set IPV4 instance.

Parameters
ipIPV4 instance

Definition at line 50 of file ARP.cpp.

References m_ip.

Referenced by NetworkDevice::initialize().

◆ updateCacheEntry()

void ARP::updateCacheEntry ( const IPV4::Address  ipAddr,
const Ethernet::Address ethAddr 
)
private

Update cache entry.

Parameters
ipAddrIP address for update
ethAddrEthernet address for update

Definition at line 75 of file ARP.cpp.

References MemoryBlock::copy(), entry, and getCacheEntry().

Referenced by process().

Field Documentation

◆ m_cache

HashTable<IPV4::Address, ARPCache *> ARP::m_cache
private

Contains a cached mapping from IP to Ethernet addresses.

Definition at line 222 of file ARP.h.

Referenced by getCacheEntry(), insertCacheEntry(), and ~ARP().

◆ m_ip

::IPV4* ARP::m_ip
private

IPV4 instance object.

Definition at line 219 of file ARP.h.

Referenced by ARP(), process(), sendReply(), sendRequest(), and setIP().

◆ m_kernelTimer

KernelTimer ARP::m_kernelTimer
private

Provides access to the kernel timer.

Definition at line 225 of file ARP.h.

Referenced by lookupAddress(), and sendRequest().

◆ m_sock

ARPSocket* ARP::m_sock
private

The single ARP socket.

Definition at line 216 of file ARP.h.

Referenced by initialize(), and process().

◆ MaxRetries

const Size ARP::MaxRetries = 3
staticprivate

Maximum number of retries for ARP lookup.

Definition at line 47 of file ARP.h.

Referenced by sendRequest().


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