|
SourceForge Jpcap | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jpcap.net.Packet
net.sourceforge.jpcap.net.EthernetPacket
net.sourceforge.jpcap.net.IP.Packet
net.sourceforge.jpcap.net.IPv4.Packet
net.sourceforge.jpcap.net.IPPacket
net.sourceforge.jpcap.net.ICMPPacket
public class ICMPPacket
An ICMP packet.
Extends an IP packet, adding an ICMP header and ICMP data payload.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class net.sourceforge.jpcap.net.IPPacket |
---|
IPPacket.TestProbe |
Field Summary |
---|
Fields inherited from class net.sourceforge.jpcap.net.IP.Packet |
---|
_ipHeaderLength, _ipOffset |
Fields inherited from class net.sourceforge.jpcap.net.EthernetPacket |
---|
_byteBuffer, _bytes, _ethOffset, _timeval |
Fields inherited from interface net.sourceforge.jpcap.net.ICMPFields |
---|
ICMP_CODE_LEN, ICMP_CODE_POS, ICMP_CSUM_LEN, ICMP_CSUM_POS, ICMP_HEADER_LEN, ICMP_SUBC_LEN, ICMP_SUBC_POS |
Fields inherited from interface net.sourceforge.jpcap.net.IPFields |
---|
IP_CODE_LEN, IP_CODE_POS, IP_CSUM_LEN, IP_CSUM_POS, IP_DST_POS, IP_FRAG_LEN, IP_FRAG_POS, IP_HEADER_LEN, IP_ID_LEN, IP_ID_POS, IP_LEN_LEN, IP_LEN_POS, IP_SRC_POS, IP_TOS_LEN, IP_TOS_POS, IP_TTL_LEN, IP_TTL_POS, IP_VER_LEN, IP_VER_POS |
Fields inherited from interface net.sourceforge.jpcap.net.EthernetFields |
---|
ETH_CODE_LEN, ETH_CODE_POS, ETH_DST_POS, ETH_HEADER_LEN, ETH_SRC_POS |
Constructor Summary | |
---|---|
ICMPPacket(int lLen,
byte[] bytes)
Construct a new ICMP packet. |
|
ICMPPacket(int lLen,
byte[] bytes,
Timeval tv)
Construct a new ICMP packet, including the capture time. |
|
ICMPPacket(int lLen,
ByteBuffer bb,
Timeval tv)
Construct a new ICMP packet, including the capture time. |
Method Summary | |
---|---|
int |
getChecksum()
Return the actual packet checksum as received. Derived classes override this to return the most specific checksum, e.g.:
Packet.getChecksum() returns zero. |
String |
getColor()
Fetch ASCII escape sequence of the color associated with this packet type. |
byte[] |
getData()
Fetch the data portion of the packet. This is overridden in derived classes to return successively smaller and smaller amounts of data. For example:
|
byte[] |
getHeader()
Fetch header portion of the packet. This is overridden in derived classes to return the header appropriate to the packet class. For example:
|
int |
getICMPChecksum()
Fetch the ICMP checksum. |
byte[] |
getICMPData()
Fetch the ICMP data as a byte array. |
byte[] |
getICMPHeader()
Fetch the ICMP header as a byte array. |
int |
getMessageCode()
Fetch the ICMP message type, including subcode. |
int |
getMessageMajorCode()
Fetch the ICMP message type code. |
int |
getMessageMinorCode()
Fetch the ICMP message subcode. |
int |
getMessageType()
Deprecated. use getMessageMajorCode() . |
boolean |
isValidChecksum()
Return true iff all the checksums in the packet are valid, otherwise false. Derived classes with checksums should override, and should call super.isValidChecksum()
to check the validity of base class checksums.
The Packet.isValidChecksum() implementation just returns true. |
void |
setChecksums()
Set all the checksums in this packet prior to sending. Calling this method sets all the IP, ICMP, IGMP, TCP, UDP etc checksums as appropriate. It is called automatically by PacketOutputStream.writePacket(Packet) .
Derived classes must override this abstract method, and must call super.setChecksums() ,
after setting their own checksums
(unless super.setChecksums() is abstract, i.e. this method).
Otherwise the lower-level checksums will not be correct.
After calling this method the |
void |
setMessageCode(short code)
Set the ICMP message code and subcode (16 bits) as per IP.ICMP.getMessageCode() . |
String |
toColoredString(boolean colored)
Generate string with contents describing this packet. |
Methods inherited from class net.sourceforge.jpcap.net.IPPacket |
---|
getDestinationAddress, getDestinationAddressAsLong, getDestinationAddressBytes, getIpHeaderLength, getSourceAddress, getSourceAddressAsLong, getSourceAddressBytes, onesCompSum |
Methods inherited from class net.sourceforge.jpcap.net.IPv4.Packet |
---|
computeReceiverChecksum, computeReceiverIPChecksum, computeSenderChecksum, computeSenderIPChecksum, getDestinationInetAddress, getFragmentFlags, getFragmentOffset, getId, getIPChecksum, getIPData, getIPHeader, getIPHeaderLength, getIPProtocol, getLength, getProtocol, getSourceInetAddress, getTimeToLive, getTypeOfService, getVersion, isValidIPChecksum, setDestinationInetAddress, setSourceInetAddress, toColoredVerboseString |
Methods inherited from class net.sourceforge.jpcap.net.IP.Packet |
---|
getHeaderLength |
Methods inherited from class net.sourceforge.jpcap.net.EthernetPacket |
---|
equals, getDestinationHwAddress, getDestinationMACAddress, getEthernetCRC32, getEthernetData, getEthernetHeader, getEthernetHeaderLength, getEthernetProtocol, getPacketData, getPacketLength, getSourceHwAddress, getSourceMACAddress, getTimeval, hashCode, setDestinationMACAddress, setEthernetProtocol, setSourceMACAddress, toByteArray, toString |
Methods inherited from class net.sourceforge.jpcap.net.Packet |
---|
ipChecksum |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ICMPPacket(int lLen, byte[] bytes)
lLen
- link-layer header lengthbytes
- Packet datapublic ICMPPacket(int lLen, byte[] bytes, Timeval tv)
lLen
- link-layer header lengthbytes
- Packet datatv
- Timestamppublic ICMPPacket(int lLen, ByteBuffer bb, Timeval tv)
lLen
- link-layer header lengthbb
- Packet data in a ByteBuffertv
- TimestampMethod Detail |
---|
public byte[] getICMPHeader()
IP.ICMP
getICMPHeader
in interface IP.ICMP
public byte[] getHeader()
EthernetPacket.getHeader()
returns the Ethernet header
IP.Packet.getHeader()
returns the IP header, which is in the Ethernet payload
TCPPacket.getHeader()
returns the TCP header, which is in the IP payload
getHeader
in class IP.Packet
public byte[] getICMPData()
IP.ICMP
getICMPData
in interface IP.ICMP
public byte[] getData()
EthernetPacket.getData()
returns the entire Ethernet payload excluding the Ethernet header
IP.Packet.getData()
only returns the IP payload, i.e. excluding the IP header which is in the Ethernet payload
TCPPacket.getData()
only returns the TCP payload, i.e. excluding the TCP header which is in the IP payload
getData
in class IP.Packet
public int getMessageCode()
IP.ICMP
getMessageCode
in interface IP.ICMP
public void setMessageCode(short code)
IP.ICMP
IP.ICMP.getMessageCode()
.
setMessageCode
in interface IP.ICMP
code
- 2-byte code value.public int getMessageMajorCode()
Formerly getMessageType()
.
getMessageMajorCode
in interface IP.ICMP
@Deprecated public int getMessageType()
getMessageMajorCode()
.
public int getMessageMinorCode()
IP.ICMP
getMessageMinorCode
in interface IP.ICMP
public int getChecksum()
IPv4.Packet.getChecksum()
returns the IP checksum
TCPPacket.getChecksum()
returns the TCP checksum
Packet.getChecksum()
returns zero.
getChecksum
in class IPv4.Packet
public int getICMPChecksum()
IP.ICMP
getICMPChecksum
in interface IP.ICMP
public boolean isValidChecksum()
super.isValidChecksum()
to check the validity of base class checksums.
The Packet.isValidChecksum()
implementation just returns true.
isValidChecksum
in class IPv4.Packet
public void setChecksums()
PacketOutputStream.writePacket(Packet)
.
Derived classes must override this abstract method, and must call super.setChecksums()
,
after setting their own checksums
(unless super.setChecksums() is abstract, i.e. this method).
Otherwise the lower-level checksums will not be correct.
After calling this method the EthernetPacket.hashCode()
of this object will probably change.
setChecksums
in class IPv4.Packet
public String toColoredString(boolean colored)
toColoredString
in class IP.Packet
colored
- whether or not the string should contain ansi
color escape sequences.public String getColor()
getColor
in class IP.Packet
|
Copyright © Patrick Charles & Jonas Lehmann, 2001; Esmond Pitt, 2008. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |