Modifier and Type | Field and Description |
---|---|
protected short |
checksum |
protected int |
destinationAddress |
protected byte |
diffServ |
protected byte |
flags |
protected short |
fragmentOffset |
protected byte |
headerLength |
protected short |
identification |
protected boolean |
isTruncated |
protected byte[] |
options |
protected byte |
protocol |
static java.util.Map<java.lang.Byte,Deserializer<? extends IPacket>> |
PROTOCOL_DESERIALIZER_MAP |
static byte |
PROTOCOL_ICMP |
static byte |
PROTOCOL_IGMP |
static byte |
PROTOCOL_PIM |
static byte |
PROTOCOL_TCP |
static byte |
PROTOCOL_UDP |
protected int |
sourceAddress |
protected short |
totalLength |
protected byte |
ttl |
protected byte |
version |
parent, payload
Constructor and Description |
---|
IPv4()
Default constructor that sets the version to 4.
|
Modifier and Type | Method and Description |
---|---|
static Deserializer<IPv4> |
deserializer()
Deserializer function for IPv4 packets.
|
boolean |
equals(java.lang.Object obj) |
static java.lang.String |
fromIPv4Address(int ipAddress)
Accepts an IPv4 address and returns of string of the form xxx.xxx.xxx.xxx,
e.g., 192.168.0.1.
|
static java.lang.String |
fromIPv4AddressCollection(java.util.Collection<java.lang.Integer> ipAddresses)
Accepts a collection of IPv4 addresses as integers and returns a single
String useful in toString method's containing collections of IP
addresses.
|
short |
getChecksum() |
int |
getDestinationAddress() |
byte |
getDiffServ()
Gets the DiffServ octet (including the DSCP and ECN bits).
|
byte |
getDscp()
Gets the DSCP value (6 bits).
|
byte |
getEcn()
Gets the ECN value (2 bits).
|
byte |
getFlags() |
short |
getFragmentOffset() |
byte |
getHeaderLength() |
short |
getIdentification() |
byte[] |
getOptions() |
byte |
getProtocol() |
int |
getSourceAddress() |
short |
getTotalLength() |
byte |
getTtl() |
byte |
getVersion()
Gets IP version number.
|
int |
hashCode() |
boolean |
isTruncated() |
void |
resetChecksum()
Reset any checksum as needed, and call resetChecksum on all parents.
|
byte[] |
serialize()
Serializes the packet.
|
IPv4 |
setChecksum(short checksum) |
IPv4 |
setDestinationAddress(int destinationAddress) |
IPv4 |
setDestinationAddress(java.lang.String destinationAddress) |
IPv4 |
setDiffServ(byte diffServ)
Sets the DiffServ octet (including the DSCP and ECN bits).
|
IPv4 |
setDscp(byte dscp)
Sets the DSCP value (6 bits).
|
IPv4 |
setEcn(byte ecn)
Sets the ECN value (2 bits).
|
IPv4 |
setFlags(byte flags) |
IPv4 |
setFragmentOffset(short fragmentOffset) |
IPv4 |
setIdentification(short identification) |
IPv4 |
setOptions(byte[] options) |
IPv4 |
setProtocol(byte protocol) |
IPv4 |
setSourceAddress(int sourceAddress) |
IPv4 |
setSourceAddress(java.lang.String sourceAddress) |
void |
setTruncated(boolean isTruncated) |
IPv4 |
setTtl(byte ttl) |
IPv4 |
setVersion(byte version)
Sets IP version number.
|
static int |
toIPv4Address(byte[] ipAddress)
Accepts an IPv4 address in a byte array and returns the corresponding
32-bit integer value.
|
static int |
toIPv4Address(java.lang.String ipAddress)
Accepts an IPv4 address of the form xxx.xxx.xxx.xxx, ie 192.168.0.1 and
returns the corresponding 32 bit integer.
|
static byte[] |
toIPv4AddressBytes(int ipAddress)
Accepts an IPv4 address in the form of an integer and returns the
corresponding byte array.
|
static byte[] |
toIPv4AddressBytes(java.lang.String ipAddress)
Accepts an IPv4 address of the form xxx.xxx.xxx.xxx, ie 192.168.0.1 and
returns the corresponding byte array.
|
java.lang.String |
toString() |
clone, getParent, getPayload, setParent, setPayload
public static final byte PROTOCOL_ICMP
public static final byte PROTOCOL_IGMP
public static final byte PROTOCOL_TCP
public static final byte PROTOCOL_UDP
public static final byte PROTOCOL_PIM
public static final java.util.Map<java.lang.Byte,Deserializer<? extends IPacket>> PROTOCOL_DESERIALIZER_MAP
protected byte version
protected byte headerLength
protected byte diffServ
protected short totalLength
protected short identification
protected byte flags
protected short fragmentOffset
protected byte ttl
protected byte protocol
protected short checksum
protected int sourceAddress
protected int destinationAddress
protected byte[] options
protected boolean isTruncated
public byte getVersion()
IP
getVersion
in class IP
public IPv4 setVersion(byte version)
IP
setVersion
in class IP
version
- the version to setpublic byte getHeaderLength()
public byte getDscp()
public IPv4 setDscp(byte dscp)
dscp
- the DSCP value (6 bits)public byte getEcn()
public IPv4 setEcn(byte ecn)
ecn
- the ECN value (2 bits)public byte getDiffServ()
public IPv4 setDiffServ(byte diffServ)
diffServ
- the diffServ octet to set (including the DSCP and ECN
bits)public short getTotalLength()
public short getIdentification()
public boolean isTruncated()
public void setTruncated(boolean isTruncated)
public IPv4 setIdentification(short identification)
identification
- the identification to setpublic byte getFlags()
public IPv4 setFlags(byte flags)
flags
- the flags to setpublic short getFragmentOffset()
public IPv4 setFragmentOffset(short fragmentOffset)
fragmentOffset
- the fragmentOffset to setpublic byte getTtl()
public IPv4 setTtl(byte ttl)
ttl
- the ttl to setpublic byte getProtocol()
public IPv4 setProtocol(byte protocol)
protocol
- the protocol to setpublic short getChecksum()
public IPv4 setChecksum(short checksum)
checksum
- the checksum to setpublic void resetChecksum()
IPacket
resetChecksum
in interface IPacket
resetChecksum
in class BasePacket
public int getSourceAddress()
public IPv4 setSourceAddress(int sourceAddress)
sourceAddress
- the sourceAddress to setpublic IPv4 setSourceAddress(java.lang.String sourceAddress)
sourceAddress
- the sourceAddress to setpublic int getDestinationAddress()
public IPv4 setDestinationAddress(int destinationAddress)
destinationAddress
- the destinationAddress to setpublic IPv4 setDestinationAddress(java.lang.String destinationAddress)
destinationAddress
- the destinationAddress to setpublic byte[] getOptions()
public IPv4 setOptions(byte[] options)
options
- the options to setpublic byte[] serialize()
public static int toIPv4Address(java.lang.String ipAddress)
ipAddress
- ip address in string formpublic static int toIPv4Address(byte[] ipAddress)
ipAddress
- ip address in byte formpublic static java.lang.String fromIPv4Address(int ipAddress)
ipAddress
- ip address in formpublic static java.lang.String fromIPv4AddressCollection(java.util.Collection<java.lang.Integer> ipAddresses)
ipAddresses
- collectionpublic static byte[] toIPv4AddressBytes(java.lang.String ipAddress)
ipAddress
- The IP address in the form xx.xxx.xxx.xxx.public static byte[] toIPv4AddressBytes(int ipAddress)
ipAddress
- The IP address as an integer.public int hashCode()
hashCode
in class BasePacket
public boolean equals(java.lang.Object obj)
equals
in class BasePacket
public static Deserializer<IPv4> deserializer()
public java.lang.String toString()
toString
in class java.lang.Object