|
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
public abstract static class IPv4.Packet
Base IPv4 packet class.
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.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 | |
---|---|
IPv4.Packet(int lLen,
byte[] bytes)
|
|
IPv4.Packet(int lLen,
byte[] bytes,
Timeval tv)
|
|
IPv4.Packet(int lLen,
ByteBuffer bb,
Timeval tv)
|
Method Summary | |
---|---|
protected int |
computeReceiverChecksum(int start,
int len)
|
protected int |
computeReceiverIPChecksum()
|
protected int |
computeSenderChecksum(int start,
int len,
int csumPos)
|
protected int |
computeSenderIPChecksum()
|
int |
getChecksum()
Return the actual packet checksum as received. |
InetAddress |
getDestinationInetAddress()
Fetch the destination IP address. |
int |
getFragmentFlags()
Fetch fragmentation flags. |
int |
getFragmentOffset()
Fetch fragment offset. |
int |
getId()
Fetch the unique ID of this IP packet. |
int |
getIPChecksum()
Fetch the IP checksum. |
byte[] |
getIPData()
Fetch the IP data as a byte array. |
byte[] |
getIPHeader()
Fetch the IP header as a byte array. |
int |
getIPHeaderLength()
Fetch the IP header length in bytes. |
int |
getIPProtocol()
Fetch the code indicating the type of protocol embedded in the IP packet. |
int |
getLength()
Fetch the IP payload length in bytes. |
int |
getProtocol()
Return the protocol. This is overridden by derived classes: for example:
|
InetAddress |
getSourceInetAddress()
Fetch the source IP address. |
int |
getTimeToLive()
Fetch the time to live. |
int |
getTypeOfService()
Fetch the type of service. |
int |
getVersion()
Get the IP version code. |
boolean |
isValidChecksum()
Return true iff all the checksums in the packet are valid, otherwise false. |
boolean |
isValidIPChecksum()
Check if the IP packet is valid, checksum-wise. |
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. |
void |
setDestinationInetAddress(InetAddress address)
Set the destination address. |
void |
setSourceInetAddress(InetAddress address)
Set the source address. |
String |
toColoredVerboseString(boolean colored)
Convert this IP packet to a more verbose string. |
Methods inherited from class net.sourceforge.jpcap.net.IP.Packet |
---|
getColor, getData, getHeader, getHeaderLength, toColoredString |
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 IPv4.Packet(int lLen, byte[] bytes)
public IPv4.Packet(int lLen, byte[] bytes, Timeval tv)
public IPv4.Packet(int lLen, ByteBuffer bb, Timeval tv)
Method Detail |
---|
public int getVersion()
IP.Packet
getVersion
in class IP.Packet
public int getIPHeaderLength()
IP.Packet
getIPHeaderLength
in class IP.Packet
public int getTypeOfService()
TypesOfService
interface.
TypesOfService
public int getLength()
IP.Packet
getLength
in class IP.Packet
public int getId()
public int getFragmentFlags()
public int getFragmentOffset()
public int getTimeToLive()
public int getIPProtocol()
IP.Packet
getIPProtocol
in class IP.Packet
IPProtocols
public int getProtocol()
EthernetPacket.getProtocol()
returns the Ethernet protocol word.
getProtocol()
returns the IP protocol word
getProtocol
in class EthernetPacket
public int getIPChecksum()
public int getChecksum()
getChecksum()
returns the IP checksum
TCPPacket.getChecksum()
returns the TCP checksum
Packet.getChecksum()
returns zero.
getChecksum
in class Packet
public InetAddress getSourceInetAddress()
IP.Packet
getSourceInetAddress
in class IP.Packet
public void setSourceInetAddress(InetAddress address)
IP.Packet
setSourceInetAddress
in class IP.Packet
address
- Source address.public InetAddress getDestinationInetAddress()
IP.Packet
getDestinationInetAddress
in class IP.Packet
public void setDestinationInetAddress(InetAddress address)
IP.Packet
setDestinationInetAddress
in class IP.Packet
address
- Destination address.public byte[] getIPHeader()
IP.Packet
getIPHeader
in class IP.Packet
public byte[] getIPData()
IP.Packet
getIPData
in class IP.Packet
public boolean isValidChecksum()
super.isValidChecksum()
to check the validity of base class checksums.
The Packet.isValidChecksum()
implementation just returns true.
isValidChecksum
in class Packet
public boolean isValidIPChecksum()
protected int computeReceiverIPChecksum()
protected int computeReceiverChecksum(int start, int len)
protected int computeSenderIPChecksum()
protected int computeSenderChecksum(int start, int len, int csumPos)
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 EthernetPacket
public String toColoredVerboseString(boolean colored)
IP.Packet
toColoredVerboseString
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 |