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
           
 
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, 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()
           
 int code()
           
 Icmp.IcmpCode codeEnum()
           
protected  void decodeHeader()
          Allows a header to decode its complex fields
static int headerLength(JBuffer buffer, int offset)
           
 boolean isChecksumValid()
          Checks if the checksum is valid, for un-fragmented packets.
 int type()
           
 java.lang.String typeDescription()
           
 Icmp.IcmpType typeEnum()
           
 
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, setUByte, setUInt, setUShort, transferFrom, transferFrom, transferFrom, transferTo, transferTo, transferTo
 
Methods inherited from class org.jnetpcap.nio.JMemory
check, cleanup, finalize, isInitialized, isJMemoryBasedOwner, isOwner, peer, setSize, size, toDebugString, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final int ID
See Also:
Constant Field Values
Constructor Detail

Icmp

public Icmp()
Method Detail

headerLength

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

checksumDescription

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

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()

codeEnum

public Icmp.IcmpCode codeEnum()

decodeHeader

protected void decodeHeader()
Description copied from class: JHeader
Allows a header to decode its complex fields

Overrides:
decodeHeader in class JHeader

type

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

typeDescription

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

typeEnum

public Icmp.IcmpType typeEnum()

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