Class fi.hut.tcm.jacob.tcpip.arp.ArpTable
java.lang.Object
|
+--fi.hut.tcm.jacob.tcpip.arp.ArpTable
- public class ArpTable
- extends java.lang.Object
ArpTable
The ARP table works as a cache memory of recently used IP addresses and
their corresponding hardware addresses in
order to prevent unnecessary ARP broadcasts for frequently used IP
addresses. When the ARP protocol receives an
outgoing data packet from a higher-level protocol, it consults the ARP
table to see if the needed hardware address is
already known.
Method Summary
|
boolean
|
deleteEntry(int ipAddr)
Deletes an entry from the ARP table using the IP address as the
key. |
long
|
getEtherAddr(int ipAddr)
Returns the corresponding ethernet address in the given EtherAddr
argument and the status for the requested IP
address. |
boolean
|
insertEntry(int ipAddr,
long etherAddr,
byte statusFlag)
Inserts an entry into the ARP table. |
boolean
|
insertEntry(int ipAddr,
long etherAddr,
byte statusFlag,
byte ImmutableFlag)
Inserts an entry into the ARP table. |
void
|
showTable()
Prints the ARP table, for debugging and direct user access. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
ipAddrArr
protected int[] ipAddrArr
etherAddrArr
protected long[] etherAddrArr
birthTimeArr
protected java.util.Date[] birthTimeArr
lastUsedArr
protected java.util.Date[] lastUsedArr
statusFlagArr
protected byte[] statusFlagArr
immutableFlagArr
protected byte[] immutableFlagArr
usedArr
protected boolean[] usedArr
ArpTable
public ArpTable()
insertEntry
public boolean insertEntry(int ipAddr,
long etherAddr,
byte statusFlag)
- Inserts an entry into the ARP table. It is allowed to insert an
entry for an IP address
that already exists in the ARP table: the old entry will be
overwritten.
- Parameters:
ipAddr
- The IP address of the new entry.
etherAddr
- The ethernet address of the new entry.
statusFlag
- A status flag for the entry.- Returns:
- An indicator that shows if the insertion was successful.
insertEntry
public boolean insertEntry(int ipAddr,
long etherAddr,
byte statusFlag,
byte ImmutableFlag)
- Inserts an entry into the ARP table. The immutable flag is
optional. It is allowed to insert an entry for an IP address
that already exists in the ARP table: the old entry will be
overwritten.
- Parameters:
ipAddr
- The IP address of the new entry.
etherAddr
- The ethernet address of the new entry.
statusFlag
- A status flag for the entry.
ImmutableFlag
- Permanent status yes/no- Returns:
- An indicator that shows if the insertion was successful.
showTable
public void showTable()
- Prints the ARP table, for debugging and direct user access. The
following information is shown for each entry that is
not too old: IP address, hardware address, status flag and
immutable flag.
deleteEntry
public boolean deleteEntry(int ipAddr)
- Deletes an entry from the ARP table using the IP address as the
key. Returns true on success, and false if some error
occurred.
- Parameters:
ipAddr
- The IP address of the entry to be deleted- Returns:
- An indicator that shows if the delete was successful.
getEtherAddr
public long getEtherAddr(int ipAddr)
- Returns the corresponding ethernet address in the given EtherAddr
argument and the status for the requested IP
address. If the IP address is not in the ARP table, or is too old,
the returned value is NotInTable. Otherwise one of OK,
or ARPFailure is returned. The contents of the EtherAddr argument
are guaranteed to be valid only when the status
code is OK.
- Parameters:
ipAddr
- The IP address of the desired Ethernet address.- Returns:
- The desired Ethernet address.