Package org.opennms.protocols.icmp
Class TimestampReply
java.lang.Object
org.opennms.protocols.icmp.ICMPHeader
org.opennms.protocols.icmp.TimestampReply
This is the implementation of an ICMP timestamp 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.
- Version:
- 0.1
- Author:
- Brian Weaver
-
Field Summary
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
ConstructorsConstructorDescriptionCreates a new ICMP Timestamp Reply object.TimestampReply(byte[] buf, int offset) Creates a new ICMP timestamp reply from the spcified data at the specific offset. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidComputes the ones compliment 16-bit checksum for the ICMP message.final intRetreives the current timestamp of the reqeust object.final intRetreives the current received timestamp of the reqeust object.final intRetreives the current transmit timestamp of the reply object.final intloadFromBuffer(byte[] buf, int offset) Reads the ICMP Address Mask Reqeust from the specified buffer and sets the internal fields equal to the data.final voidSets the originate timestamp to the current date in millisecond resolution.final voidsetOriginateTS(int ts) Sets the originate timestamp to the passed value.final voidSets the receive timestamp to the current date in millisecond resolution.final voidsetReceiveTS(int ts) Sets the receive timestamp to the passed value.final voidSets the transmit timestamp to the current date in millisecond resolution.final voidsetTransmitTS(int ts) Sets the tranmit timestamp to the passed value.final intstoreToBuffer(byte[] buf, int offset) Writes the ICMP address mask reply out to the specified buffer at the starting offset.final byte[]toBytes()Converts the object to an array of bytes.Methods inherited from class org.opennms.protocols.icmp.ICMPHeader
byteToInt, byteToShort, computeChecksum, getChecksum, getCode, getHeaderSize, getIdentity, getNetworkSize, getSequenceId, getType, isEchoReply, isEchoRequest, nextSequenceId, setChecksum, setCode, setIdentity, setNextSequenceId, setSequenceId, setType
-
Constructor Details
-
TimestampReply
public TimestampReply()Creates a new ICMP Timestamp Reply object. -
TimestampReply
public TimestampReply(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:
IndexOutOfBoundsException- Thrown if there is not sufficent data in the buffer.IllegalArgumentException- Thrown if the ICMP type is not an Timestamp Reply.
-
-
Method Details
-
computeChecksum
public final void computeChecksum()Computes the ones compliment 16-bit checksum for the ICMP message.- Overrides:
computeChecksumin classICMPHeader
-
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:
storeToBufferin classICMPHeader- 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:
loadFromBufferin classICMPHeader- 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 Timestamp Reply.
-
setOriginateTS
public final void setOriginateTS()Sets the originate timestamp to the current date in millisecond resolution.- See Also:
-
setOriginateTS
public final void setOriginateTS(int ts) Sets the originate timestamp to the passed value.- Parameters:
ts- The timestamp in milliseconds
-
getOriginateTS
public final int getOriginateTS()Retreives the current timestamp of the reqeust object.- Returns:
- The 32-bit timestamp in milliseconds.
-
setReceiveTS
public final void setReceiveTS()Sets the receive timestamp to the current date in millisecond resolution.- See Also:
-
setReceiveTS
public final void setReceiveTS(int ts) Sets the receive timestamp to the passed value.- Parameters:
ts- The timestamp in milliseconds
-
getReceiveTS
public final int getReceiveTS()Retreives the current received timestamp of the reqeust object.- Returns:
- The 32-bit timestamp in milliseconds.
-
setTransmitTS
public final void setTransmitTS()Sets the transmit timestamp to the current date in millisecond resolution.- See Also:
-
setTransmitTS
public final void setTransmitTS(int ts) Sets the tranmit timestamp to the passed value.- Parameters:
ts- The timestamp in milliseconds
-
getTransmitTS
public final int getTransmitTS()Retreives the current transmit timestamp of the reply object.- Returns:
- The 32-bit timestamp in milliseconds.
-
toBytes
public final byte[] toBytes()Converts the object to an array of bytes.- Overrides:
toBytesin classICMPHeader
-