Class AddressMaskReply

java.lang.Object
org.opennms.protocols.icmp.ICMPHeader
org.opennms.protocols.icmp.AddressMaskReply

public final class AddressMaskReply extends ICMPHeader
This is the implementation of an ICMP Address Mask Reply object. The object can be stored in a buffer to send or loaded from a received buffer. The class is marked final since it is not intended to be extended.
Author:
Brian Weaver
  • Constructor Details

    • AddressMaskReply

      public AddressMaskReply()
      Creates a new ICMP Address Mask Request object.
    • AddressMaskReply

      public AddressMaskReply(byte[] buf, int offset)
      Creates a new ICMP Address mask reply from the spcified data at the specific offset.
      Parameters:
      buf - The buffer containing the data.
      offset - The start of the icmp data.
      Throws:
      IndexOutOfBoundsException - Thrown if there is not sufficent data in the buffer.
      IllegalArgumentException - Thrown if the ICMP type is not an Address Mask reply.
  • Method Details

    • computeChecksum

      public final void computeChecksum()
      Computes the ones compliment 16-bit checksum for the ICMP message.
      Overrides:
      computeChecksum in class ICMPHeader
    • storeToBuffer

      public final int storeToBuffer(byte[] buf, int offset)
      Writes the ICMP address mask reply out to the specified buffer at the starting offset. If the buffer does not have sufficent data to store the information then an IndexOutOfBoundsException is thrown.
      Overrides:
      storeToBuffer in class ICMPHeader
      Parameters:
      buf - The storage buffer.
      offset - The location to start in buf.
      Returns:
      The new offset after storing to the buffer.
      Throws:
      IndexOutOfBoundsException - Thrown if the buffer does not have enough storage space.
    • loadFromBuffer

      public final int loadFromBuffer(byte[] buf, int offset)
      Reads the ICMP Address Mask Reqeust from the specified buffer and sets the internal fields equal to the data. If the buffer does not have sufficent data to restore the header then an IndexOutOfBoundsException is thrown by the method. If the buffer does not contain an address mask reqeust then an IllegalArgumentException is thrown.
      Overrides:
      loadFromBuffer in class ICMPHeader
      Parameters:
      buf - The buffer to read the data from.
      offset - The offset to start reading data.
      Returns:
      The new offset after reading the data.
      Throws:
      IndexOutOfBoundsException - Thrown if there is not sufficent data in the buffer.
      IllegalArgumentException - Thrown if the ICMP type is not an Address Mask reply.
    • getAddressMask

      public final int getAddressMask()
      Used to get the IPv4 32-bit address mask.
    • setAddressMask

      public final void setAddressMask(int mask)
      Used to set the IPv4 32-bit address mask.
    • toBytes

      public final byte[] toBytes()
      Converts the object to a stream of bytes.
      Overrides:
      toBytes in class ICMPHeader