org.jnetpcap.protocol.network
Class Icmp

java.lang.Object
  extended by org.jnetpcap.nio.JMemory
      extended by org.jnetpcap.nio.JBuffer
          extended by org.jnetpcap.packet.JHeader
              extended by org.jnetpcap.packet.JHeaderMap<Icmp>
                  extended by org.jnetpcap.protocol.network.Icmp
All Implemented Interfaces:
JCompoundHeader<Icmp>, JHeaderChecksum, JPayloadAccessor

@Header
public class Icmp
extends JHeaderMap<Icmp>
implements JHeaderChecksum

ICMP header definition.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
static class Icmp.DestinationUnreachable
          ICMP Destination Unreachable header definition.
static class Icmp.Echo
          ICMP Echo header (ping) baseclass definition.
static class Icmp.EchoReply
          ICMP Echo Reply header definition.
static class Icmp.EchoRequest
          ICMP Echo Request header definition.
static class Icmp.IcmpCode
          A table of Icmp sub-codes per Icmp type.
static class Icmp.IcmpType
          A table of IcmpTypes and their names.
static class Icmp.ParamProblem
          ICMP Paramater Protoblem header definition.
static class Icmp.Redirect
          ICMP Redirect header definition.
static class Icmp.Reserved
          Base class for various ICMP Headers that contain a reserved field.
static class Icmp.SourceQuench
          ICMP Source Quence header definition.
 
Nested classes/interfaces inherited from class org.jnetpcap.packet.JHeader
JHeader.State
 
Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory
JMemory.Type
 
Field Summary
static int ID
          The Constant ID.
 
Fields inherited from class org.jnetpcap.packet.JHeaderMap
MAX_HEADERS, optionsBitmap, optionsLength, optionsOffsets, X_HEADERS
 
Fields inherited from class org.jnetpcap.packet.JHeader
annotatedHeader, BYTE, EMPTY_HEADER_ARRAY, isSubHeader, packet, state
 
Fields inherited from class org.jnetpcap.nio.JMemory
JNETPCAP_LIBRARY_NAME, MAX_DIRECT_MEMORY_DEFAULT, POINTER
 
Constructor Summary
Icmp()
           
 
Method Summary
 int calculateChecksum()
          Calculates a checksum using protocol specification for a header.
 int checksum()
          Retrieves the header's checksum.
 java.lang.String checksumDescription()
          Checksum description.
 int code()
          Code.
 Icmp.IcmpCode codeEnum()
          Code enum.
protected  void decodeHeader()
          Decode header.
static int headerLength(JBuffer buffer, int offset)
          Header length.
 boolean isChecksumValid()
          Checks if the checksum is valid, for un-fragmented packets.
 int type()
          Type.
 java.lang.String typeDescription()
          Type description.
 Icmp.IcmpType typeEnum()
          Type enum.
 
Methods inherited from class org.jnetpcap.packet.JHeaderMap
getSubHeader, getSubHeaders, hasSubHeader, hasSubHeader, hasSubHeaders, setSubHeader, setSubHeaders
 
Methods inherited from class org.jnetpcap.packet.JHeader
decode, getAnnotatedHeader, getDescription, getFields, getGap, getGapLength, getGapOffset, getHeader, getHeaderLength, getHeaderOffset, getId, getIndex, getLength, getName, getNextHeaderId, getNextHeaderOffset, getNicname, getOffset, getPacket, getParent, getPayload, getPayloadLength, getPayloadOffset, getPostfix, getPostfixLength, getPostfixOffset, getPrefix, getPrefixLength, getPrefixOffset, getPreviousHeaderId, getPreviousHeaderOffset, getState, hasDescription, hasGap, hasNextHeader, hasPayload, hasPostfix, hasPrefix, hasPreviousHeader, isFragmented, isGapTruncated, isHeaderTruncated, isPayloadTruncated, isPostfixTruncated, isPrefixTruncated, peer, peer, peerPayloadTo, setPacket, sizeof, toString, transferPayloadTo, transferPayloadTo, transferPayloadTo, validateHeader
 
Methods inherited from class org.jnetpcap.nio.JBuffer
findUTF8String, getByte, getByteArray, getByteArray, getByteArray, getDouble, getFloat, getInt, getLong, getShort, getUByte, getUInt, getUShort, getUTF8Char, getUTF8String, getUTF8String, getUTF8String, getUTF8String, isReadonly, order, order, peer, peer, peer, peer, setByte, setByteArray, setByteBuffer, setDouble, setFloat, setInt, setLong, setShort, setShort0, setUByte, setUInt, setUShort, transferFrom, transferFrom, transferFrom, transferTo, transferTo, transferTo
 
Methods inherited from class org.jnetpcap.nio.JMemory
availableDirectMemory, check, cleanup, createReference, isInitialized, isJMemoryBasedOwner, isOwner, maxDirectMemory, peer, reservedDirectMemory, setSize, size, softDirectMemory, toDebugString, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final int ID
The Constant ID.

See Also:
Constant Field Values
Constructor Detail

Icmp

public Icmp()
Method Detail

headerLength

@HeaderLength
public static int headerLength(JBuffer buffer,
                                            int offset)
Header length.

Parameters:
buffer - the buffer
offset - the offset
Returns:
the int

checksumDescription

@Dynamic(value=DESCRIPTION)
public java.lang.String checksumDescription()
Checksum description.

Returns:
the string

checksum

@Field(offset=16,
       length=16,
       format="%x")
public int checksum()
Retrieves the header's checksum.

Specified by:
checksum in interface JHeaderChecksum
Returns:
header's stored checksum

code

@Field(offset=8,
       length=8,
       format="%x")
public int code()
Code.

Returns:
the int

codeEnum

public Icmp.IcmpCode codeEnum()
Code enum.

Returns:
the icmp code

decodeHeader

protected void decodeHeader()
Decode header.

Overrides:
decodeHeader in class JHeader
See Also:
JHeader.decodeHeader()

type

@Field(offset=0,
       length=8,
       format="%x")
public int type()
Type.

Returns:
the int

typeDescription

@Dynamic(value=DESCRIPTION)
public java.lang.String typeDescription()
Type description.

Returns:
the string

typeEnum

public Icmp.IcmpType typeEnum()
Type enum.

Returns:
the icmp type

calculateChecksum

public int calculateChecksum()
Calculates a checksum using protocol specification for a header. Checksums for partial headers or fragmented packets (unless the protocol alows it) are not calculated.

Specified by:
calculateChecksum in interface JHeaderChecksum
Returns:
header's calculated checksum

isChecksumValid

public boolean isChecksumValid()
Checks if the checksum is valid, for un-fragmented packets. If a packet is fragmented, the checksum is not verified as data to is incomplete, but the method returns true none the less.

Specified by:
isChecksumValid in interface JHeaderChecksum
Returns:
true if checksum checks out or if this is a fragment, otherwise if the computed checksum does not match the stored checksum false is returned