org.opennms.netmgt.ping
Class Reply

java.lang.Object
  extended by org.opennms.netmgt.ping.Reply

public final class Reply
extends Object

This class is use to encapsulate an ICMP reply that conforms to the packetclass. The reply must be of type ICMP Echo Reply and be the correct length.

When constructed by the create method the returned reply encapsulates the sender's address and the received packet as final, non-mutable values for the instance.

Author:
Brian Weaver , Sowmya , OpenNMS

Constructor Summary
Reply(InetAddress addr, org.opennms.protocols.icmp.ICMPEchoPacket pkt)
          Constructs a new reply with the passed address and packet as the contents of the reply.
 
Method Summary
static Reply create(DatagramPacket packet)
           Creates a new instance of the class using the passed datagram as the data source.
 InetAddress getAddress()
          Returns the internet address of the host that sent the reply.
 short getIdentity()
          Returns the identity of the packet.
 org.opennms.protocols.icmp.ICMPEchoPacket getPacket()
          Returns the ICMP packet for the reply.
 boolean isEchoReply()
          Returns true if the recovered packet is an echo reply.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Reply

public Reply(InetAddress addr,
             org.opennms.protocols.icmp.ICMPEchoPacket pkt)
Constructs a new reply with the passed address and packet as the contents of the reply.

Parameters:
addr - The address of the ICMP sender.
pkt - The received packet.
Method Detail

isEchoReply

public boolean isEchoReply()
Returns true if the recovered packet is an echo reply.


getIdentity

public final short getIdentity()
Returns the identity of the packet.


getAddress

public final InetAddress getAddress()
Returns the internet address of the host that sent the reply.


getPacket

public final org.opennms.protocols.icmp.ICMPEchoPacket getPacket()
Returns the ICMP packet for the reply.


create

public static Reply create(DatagramPacket packet)

Creates a new instance of the class using the passed datagram as the data source. The address and ping packet are extracted from the datagram and returned as a new instance of the class. In addition to extracting the packet, the packet's received time is updated to the current time.

If the received datagram is not an echo reply or an incorrect length then an exception is generated to alert the caller.

Parameters:
packet - The packet with the ICMP datagram.
Throws:
IllegalArgumentException - Throw if the datagram is not the correct length or type.
IndexOutOfBoundsException - Thrown if the datagram does not contain sufficent data.


Copyright ? 2008. All Rights Reserved.