|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.protocols.icmp.ICMPHeader
This class defines Internet Control Message Protocol header. The header defines the first 8 bytes of any ICMP message. Some ICMP messages may need to override the format of the second 4 bytes, the first 4 bytes are fixed by the RFC. The minimum message size for any ICMP message is 8 bytes.
Constructor Summary | |
ICMPHeader()
Initializes the header to a default value. |
|
ICMPHeader(byte type)
Initializes the header using the specified type. |
|
ICMPHeader(byte[] data,
int offset)
Constructs a new ICMP header based upon the data contained in the buffer. |
|
ICMPHeader(byte type,
byte code)
Initializes the header with the specified type and code values. |
|
ICMPHeader(byte type,
byte code,
short checksum,
short identity,
short sequence)
Constructs an ICMP header with the specified header fields. |
|
ICMPHeader(ICMPHeader second)
Constructs a duplicate ICMP header that is identical to the passed ICMPHeader object. |
Method Summary | |
protected static int |
byteToInt(byte b)
Converts a byte to an integer. |
protected static short |
byteToShort(byte b)
Converts a byte to a short. |
void |
computeChecksum()
Provides the default checksum implementation for the ICMP header. |
protected void |
computeChecksum(OC16ChecksumProducer summer)
Used by derived classes to begin the checksum process. |
short |
getChecksum()
Used to retrieve the current checksum for the header. |
byte |
getCode()
Returns the 8-bit code for the ICMP packet. |
short |
getIdentity()
Used to get the headers user defined identity. |
static int |
getNetworkSize()
Returns the number of bytes required to read/write an icmp header. |
short |
getSequenceId()
Returns the sequence identifier for the ICMP header. |
byte |
getType()
Returns the 8-bit type code for the ICMP packet. |
boolean |
isEchoReply()
Used to test to see if the header is an echo reply message. |
boolean |
isEchoRequest()
Used to test to see if the header is an echo request message. |
protected int |
loadFromBuffer(byte[] buf,
int offset)
Reads the ICMP header from the specified buffer and sets the internal fields equal to the data. |
static short |
nextSequenceId()
Returns the next 16-bit sequence identifier for the class. |
protected void |
setChecksum(short sum)
|
void |
setCode(byte code)
Sets the 8-bit code for the ICMP packet |
void |
setIdentity(short identity)
Sets the header's 16-bit user defined identity value. |
short |
setNextSequenceId()
Gets the next global identifier and sets the value in the object. |
void |
setSequenceId(short id)
Sets the headers 16-bit sequence identifier. |
protected void |
setType(byte type)
Sets the 8-bit type code for the packet. |
protected int |
storeToBuffer(byte[] buf,
int offset)
Writes the ICMP header out to the specified buffer at the starting offset. |
byte[] |
toBytes()
Converts the object to a string of bytes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final byte TYPE_ECHO_REPLY
public static final byte TYPE_DESTINATION_UNREACHABLE
public static final byte CODE_NETWORK_UNREACHABLE
public static final byte CODE_HOST_UNREACHABLE
public static final byte CODE_PROTOCOL_UNREACHABLE
public static final byte CODE_PORT_UNREACHABLE
public static final byte CODE_FRAGMENTATION_NEEDED
public static final byte CODE_SOURCE_ROUTE_FAILED
public static final byte CODE_DESTINATION_NETWORK_UNKNOWN
public static final byte CODE_DESTINATION_HOST_UNKNOWN
public static final byte CODE_SOURCE_HOST_ISOLATED
public static final byte CODE_DESTINATION_NETWORK_ADMIN_PROHIBITED
public static final byte CODE_DESTINATION_HOST_ADMIN_PROHIBITED
public static final byte CODE_NETWORK_UNREACHABLE_FOR_TOS
public static final byte CODE_HOST_UNREACHABLE_FOR_TOS
public static final byte CODE_COMMUNICATIONS_ADMIN_PROHIBITIED
public static final byte CODE_HOST_PRECEDENCE_VIOLATION
public static final byte CODE_PRECEDENCE_CUTOFF_IN_EFFECT
public static final byte TYPE_SOURCE_QUENCH
public static final byte TYPE_REDIRECT
public static final byte CODE_REDIRECT_FOR_NETWORK
public static final byte CODE_REDIRECT_FOR_HOST
public static final byte CODE_REDIRECT_FOR_TYPE_OF_SERVICE_AND_NETWORK
public static final byte CODE_REDIRECT_FOR_TYPE_OF_SERVICE_AND_HOST
public static final byte TYPE_ECHO_REQUEST
public static final byte TYPE_ROUTER_ADVERTISEMENT
public static final byte TYPE_ROUTER_SOLICITATION
public static final byte TYPE_TIME_EXCEEDED
public static final byte CODE_TTL_EQ_ZERO_IN_TRANSIT
public static final byte CODE_TTL_EQ_ZERO_IN_REASSEMBLY
public static final byte TYPE_PARAMETER_PROBLEM
public static final byte CODE_BAD_IP_HEADER
public static final byte CODE_REQUIRED_OPTION_MISSING
public static final byte TYPE_TIMESTAMP_REQUEST
public static final byte TYPE_TIMESTAMP_REPLY
public static final byte TYPE_INFORMATION_REQUEST
public static final byte TYPE_INFORMATION_REPLY
public static final byte TYPE_ADDRESS_MASK_REQUEST
public static final byte TYPE_ADDRESS_MASK_REPLY
private byte m_type
private byte m_code
private short m_checksum
private short m_ident
private short m_sequence
private static short sm_seq
Constructor Detail |
public ICMPHeader()
public ICMPHeader(byte type)
type
- The header type.public ICMPHeader(byte type, byte code)
type
- The type value for the headercode
- The code value for the headerpublic ICMPHeader(byte type, byte code, short checksum, short identity, short sequence)
type
- The 8-bit ICMP type.code
- The 8-bit ICMP code.checksum
- The 16-bit checksum header.identity
- The 16-bit identity (user).sequence
- The 16-bit sequence id.public ICMPHeader(ICMPHeader second)
second
- The object to duplicate.public ICMPHeader(byte[] data, int offset)
Constructs a new ICMP header based upon the data contained in the buffer.
The buffer is decode in network byte ordering (big-endin) and must be at
least a minimum
number of bytes available to be
decoded.
If there is an insufficent amount of data to decode a header then an exception is thrown.
data
- The data buffer containing the headeroffset
- The offset of the header in the buffer
java.lang.IndexOutOfBoundsException
- Thrown if there is not enough data to construct the
header.Method Detail |
public static final short nextSequenceId()
protected static short byteToShort(byte b)
b
- The byte to convert.
protected static int byteToInt(byte b)
b
- The byte to convert.
public final byte getType()
protected void setType(byte type)
type
- The new ICMP type.public final byte getCode()
public final void setCode(byte code)
code
- The new ICMP code.public final short getSequenceId()
public final short setNextSequenceId()
public final void setSequenceId(short id)
id
- The new 16-bit sequence id.public final short getIdentity()
public final void setIdentity(short identity)
identity
- The header's new identity.public final short getChecksum()
protected void setChecksum(short sum)
public void computeChecksum()
protected void computeChecksum(OC16ChecksumProducer summer)
summer
- The checksum builder object.protected int storeToBuffer(byte[] buf, int offset)
buf
- The storage buffer.offset
- The location to start in buf.
java.lang.IndexOutOfBoundsException
- Thrown if the buffer does not have enough storage space.protected int loadFromBuffer(byte[] buf, int offset)
buf
- The buffer to read the data from.offset
- The offset to start reading data.
java.lang.IndexOutOfBoundsException
- is thrown if there is not sufficent data in the buffer.public static int getNetworkSize()
public final boolean isEchoReply()
public final boolean isEchoRequest()
public byte[] toBytes()
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |