OpenNMS API 1.2.9

## org.opennms.protocols.icmp
Class ErrorMessage

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

public class ErrorMessage
extends ICMPHeader

Defines the default error handler object for processing ICMP error messages. All error messages follow the same format. The first 8 bytes is the ICMP header. Immediantly after the ICMP header is the IP packet in error, including any option data. After the IP header is the first 8 bytes of protocol data. This is enough to hold a UDP header or the first 8 bytes of a TCP header.

Author:
  Brian Weaver

Field Summary
`private IPHeader` `m_iphdr`
`private byte[]` `m_protoData`

Fields inherited from class org.opennms.protocols.icmp.ICMPHeader

`CODE_BAD_IP_HEADER, CODE_COMMUNICATIONS_ADMIN_PROHIBITIED, CODE_DESTINATION_HOST_ADMIN_PROHIBITED, CODE_DESTINATION_HOST_UNKNOWN, CODE_DESTINATION_NETWORK_ADMIN_PROHIBITED, CODE_DESTINATION_NETWORK_UNKNOWN, CODE_FRAGMENTATION_NEEDED, CODE_HOST_PRECEDENCE_VIOLATION, CODE_HOST_UNREACHABLE, CODE_HOST_UNREACHABLE_FOR_TOS, CODE_NETWORK_UNREACHABLE, CODE_NETWORK_UNREACHABLE_FOR_TOS, CODE_PORT_UNREACHABLE, CODE_PRECEDENCE_CUTOFF_IN_EFFECT, CODE_PROTOCOL_UNREACHABLE, CODE_REDIRECT_FOR_HOST, CODE_REDIRECT_FOR_NETWORK, CODE_REDIRECT_FOR_TYPE_OF_SERVICE_AND_HOST, CODE_REDIRECT_FOR_TYPE_OF_SERVICE_AND_NETWORK, CODE_REQUIRED_OPTION_MISSING, CODE_SOURCE_HOST_ISOLATED, CODE_SOURCE_ROUTE_FAILED, CODE_TTL_EQ_ZERO_IN_REASSEMBLY, CODE_TTL_EQ_ZERO_IN_TRANSIT, TYPE_ADDRESS_MASK_REPLY, TYPE_ADDRESS_MASK_REQUEST, TYPE_DESTINATION_UNREACHABLE, TYPE_ECHO_REPLY, TYPE_ECHO_REQUEST, TYPE_INFORMATION_REPLY, TYPE_INFORMATION_REQUEST, TYPE_PARAMETER_PROBLEM, TYPE_REDIRECT, TYPE_ROUTER_ADVERTISEMENT, TYPE_ROUTER_SOLICITATION, TYPE_SOURCE_QUENCH, TYPE_TIME_EXCEEDED, TYPE_TIMESTAMP_REPLY, TYPE_TIMESTAMP_REQUEST`

Constructor Summary
`` `ErrorMessage(byte[] buf, int offset)` Creates a new ICMP timestamp reply from the spcified data at the specific offset.
`protected` `ErrorMessage(byte type, byte code)` Creates a new ICMP Error Message object.

Method Summary
`IPHeader` `getIPHeader()` Used to access the IP Header that caused the ICMP error message to be generated.
`byte[]` `getProtocolData()` Retreives the 8 bytes of protocol data that caused the error.
`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.
`protected void` `setIPHeader(IPHeader hdr)` Sets the IP header in error.
`protected void` `setProtocolData(byte[] pd)` Sets the protocol data that caused the error.

Methods inherited from class org.opennms.protocols.icmp.ICMPHeader
`byteToInt, byteToShort, computeChecksum, computeChecksum, getChecksum, getCode, getIdentity, getNetworkSize, getSequenceId, getType, isEchoReply, isEchoRequest, nextSequenceId, setChecksum, setCode, setIdentity, setNextSequenceId, setSequenceId, setType, storeToBuffer, toBytes`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m_iphdr

    private IPHeader m_iphdr

### m_protoData

    private byte[] m_protoData

Constructor Detail

### ErrorMessage

    protected ErrorMessage(byte type,
                           byte code)

  Creates a new ICMP Error Message object.

Parameters:
  `type` - The ICMP type.
  `code` - The specific code for the message.

### ErrorMessage

    public ErrorMessage(byte[] buf,
                        int offset)

  Creates a new ICMP timestamp reply from the spcified data at the specific offset.

Parameters:
  `buf` - The buffer containing the data.
  `offset` - The start of the icmp data.
Throws:
  `java.lang.IndexOutOfBoundsException` - Thrown if there is not sufficent data in the buffer.

Method Detail

### 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:
    `java.lang.IndexOutOfBoundsException` - Thrown if there is not sufficent data in the buffer.

### getIPHeader

    public final IPHeader getIPHeader()

  Used to access the IP Header that caused the ICMP error message to be generated.

  Returns:
    The IP Header in error.

### setIPHeader

    protected void setIPHeader(IPHeader hdr)

  Sets the IP header in error.

  Parameters:
    `hdr` - The IP header in error

### getProtocolData

    public final byte[] getProtocolData()

  Retreives the 8 bytes of protocol data that caused the error.

  Returns:
    The first 8 bytes of the packet in error.

### setProtocolData

    protected void setProtocolData(byte[] pd)

  Sets the protocol data that caused the error.

  Parameters:
    `pd` - The 8 bytes of protocol data.
  Throws:
    `java.lang.IndexOutOfBoundsException` - Thrown when pd.length is less than 8.
    `java.lang.IllegalArgumentException` - Thrown when pd.length is greater than 8.

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.