OpenNMS API 1.2.3

org.opennms.netmgt.ping
Class Reply

java.lang.Object
  extended byorg.opennms.netmgt.ping.Reply

public final class Reply
extends java.lang.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

Field Summary
private  java.net.InetAddress m_address
          The sender's address.
private  Packet m_packet
          The received packet.
 
Constructor Summary
private Reply(java.net.InetAddress addr, Packet pkt)
          Constructs a new reply with the passed address and packet as the contents of the reply.
 
Method Summary
(package private) static Reply create(java.net.DatagramPacket packet)
           Creates a new instance of the class using the passed datagram as the data source.
 java.net.InetAddress getAddress()
          Returns the internet address of the host that sent the reply.
 short getIdentity()
          Returns the identity of the packet.
 Packet 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
 

Field Detail

m_address

private final java.net.InetAddress m_address
The sender's address.


m_packet

private final Packet m_packet
The received packet.

Constructor Detail

Reply

private Reply(java.net.InetAddress addr,
              Packet 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 java.net.InetAddress getAddress()
Returns the internet address of the host that sent the reply.


getPacket

public final Packet getPacket()
Returns the ICMP packet for the reply.


create

static Reply create(java.net.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:
java.lang.IllegalArgumentException - Throw if the datagram is not the correct length or type.
java.lang.IndexOutOfBoundsException - Thrown if the datagram does not contain sufficent data.

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.