Class IPv4
- java.lang.Object
-
- org.opendaylight.openflowplugin.libraries.liblldp.Packet
-
- org.opendaylight.genius.mdsalutil.packet.IPv4
-
public class IPv4 extends org.opendaylight.openflowplugin.libraries.liblldp.Packet
Class that represents the IPv4 packet objects.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description short
getChecksum()
Gets the checksum value stored.int
getDestinationAddress()
Gets the destination IP address stored.byte
getDiffServ()
Gets the differential services value stored.byte
getECN()
Gets the ecn bits stored.int
getfieldnumBits(java.lang.String fieldName)
byte
getFlags()
Gets the flag values stored.short
getFragmentOffset()
Gets the fragment offset stored.int
getHeaderLen()
Gets the IP header length stored.int
getHeaderSize()
Gets the header size in bits.short
getIdentification()
Gets the identification value stored.byte[]
getOptions()
gets the Options stored.byte
getProtocol()
Gets the protocol value stored.int
getSourceAddress()
Gets the source IP address stored.short
getTotalLength()
Gets the total length of the IP header in bytes.byte
getTtl()
Gets the TTL value stored.byte
getVersion()
Gets the IP version stored.protected void
postDeserializeCustomOperation(byte[] data, int startBitOffset)
Method to perform post deserialization - like compare computed checksum with the one obtained from IP header.protected void
postSerializeCustomOperation(byte[] data)
IPv4
setDestinationAddress(int ipDestinationAddress)
Stores the IP destination address from the header.IPv4
setDestinationAddress(java.net.InetAddress ipDestinationAddress)
Stores the IP destination address from the header.IPv4
setDiffServ(byte ipdiffServ)
Stores the differential services value from the IP header.IPv4
setECN(byte ecn)
Stores the ECN bits from the header.IPv4
setFlags(byte ipFlags)
Stores the IP flags value.IPv4
setFragmentOffset(short ipFragmentOffset)
Stores the IP fragmentation offset value.void
setHeaderField(java.lang.String headerField, byte[] readValue)
IPv4
setHeaderLength(byte ipheaderLength)
Stores the length of IP header in words (4 bytes).IPv4
setIdentification(short ipIdentification)
Stores the identification number from the header.IPv4
setOptions(byte[] options)
Store the options from IP header.void
setPayload(org.opendaylight.openflowplugin.libraries.liblldp.Packet payload)
IPv4
setProtocol(byte ipProtocol)
Stores the protocol value of the IP payload.IPv4
setSourceAddress(java.net.InetAddress ipSourceAddress)
Stores the IP source address from the header.IPv4
setTotalLength(short iptotalLength)
Stores the total length of IP header in bytes.IPv4
setTtl(byte ipTtl)
Stores the TTL value.IPv4
setVersion(byte ipVersion)
Stores the IP version from the header.
-
-
-
Constructor Detail
-
IPv4
public IPv4()
Default constructor that sets the version to 4, headerLength to 5, and flags to 2. The default value for the identification is set to a random number and the remaining fields are set to 0.
-
IPv4
public IPv4(boolean writeAccess)
The write access to the packet is set in this constructor. Constructor that sets the version to 4, headerLength to 5, and flags to 2. The default value for the identification is set to a random number and the remaining fields are set to 0.- Parameters:
writeAccess
- - boolean
-
-
Method Detail
-
getVersion
public byte getVersion()
Gets the IP version stored.- Returns:
- the version
-
getHeaderLen
public int getHeaderLen()
Gets the IP header length stored.- Returns:
- the headerLength in bytes
-
getHeaderSize
public int getHeaderSize()
Gets the header size in bits.- Overrides:
getHeaderSize
in classorg.opendaylight.openflowplugin.libraries.liblldp.Packet
- Returns:
- The number of bits constituting the header
-
getDiffServ
public byte getDiffServ()
Gets the differential services value stored.- Returns:
- the diffServ
-
getECN
public byte getECN()
Gets the ecn bits stored.- Returns:
- the ecn bits
-
getTotalLength
public short getTotalLength()
Gets the total length of the IP header in bytes.- Returns:
- the totalLength
-
getIdentification
public short getIdentification()
Gets the identification value stored.- Returns:
- the identification
-
getFlags
public byte getFlags()
Gets the flag values stored.- Returns:
- the flags
-
getTtl
public byte getTtl()
Gets the TTL value stored.- Returns:
- the ttl
-
getProtocol
public byte getProtocol()
Gets the protocol value stored.- Returns:
- the protocol
-
getChecksum
public short getChecksum()
Gets the checksum value stored.- Returns:
- the checksum
-
getFragmentOffset
public short getFragmentOffset()
Gets the fragment offset stored.- Returns:
- the fragmentOffset
-
getSourceAddress
public int getSourceAddress()
Gets the source IP address stored.- Returns:
- the sourceAddress
-
getDestinationAddress
public int getDestinationAddress()
Gets the destination IP address stored.- Returns:
- the destinationAddress
-
getOptions
public byte[] getOptions()
gets the Options stored.- Returns:
- the options
-
setHeaderField
public void setHeaderField(java.lang.String headerField, byte[] readValue)
- Overrides:
setHeaderField
in classorg.opendaylight.openflowplugin.libraries.liblldp.Packet
-
setVersion
public IPv4 setVersion(byte ipVersion)
Stores the IP version from the header.- Parameters:
ipVersion
- the version to set- Returns:
- IPv4
-
setHeaderLength
public IPv4 setHeaderLength(byte ipheaderLength)
Stores the length of IP header in words (4 bytes).- Parameters:
ipheaderLength
- the headerLength to set- Returns:
- IPv4
-
setDiffServ
public IPv4 setDiffServ(byte ipdiffServ)
Stores the differential services value from the IP header.- Parameters:
ipdiffServ
- the diffServ to set- Returns:
- IPv4
-
setECN
public IPv4 setECN(byte ecn)
Stores the ECN bits from the header.- Parameters:
ecn
- ECN bits to set- Returns:
- IPv4
-
setTotalLength
public IPv4 setTotalLength(short iptotalLength)
Stores the total length of IP header in bytes.- Parameters:
iptotalLength
- the totalLength to set- Returns:
- IPv4
-
setIdentification
public IPv4 setIdentification(short ipIdentification)
Stores the identification number from the header.- Parameters:
ipIdentification
- the identification to set- Returns:
- IPv4
-
setFlags
public IPv4 setFlags(byte ipFlags)
Stores the IP flags value.- Parameters:
ipFlags
- the flags to set- Returns:
- IPv4
-
setFragmentOffset
public IPv4 setFragmentOffset(short ipFragmentOffset)
Stores the IP fragmentation offset value.- Parameters:
ipFragmentOffset
- the fragmentOffset to set- Returns:
- IPv4
-
setTtl
public IPv4 setTtl(byte ipTtl)
Stores the TTL value.- Parameters:
ipTtl
- the ttl to set- Returns:
- IPv4
-
setProtocol
public IPv4 setProtocol(byte ipProtocol)
Stores the protocol value of the IP payload.- Parameters:
ipProtocol
- the protocol to set- Returns:
- IPv4
-
setSourceAddress
public IPv4 setSourceAddress(java.net.InetAddress ipSourceAddress)
Stores the IP source address from the header.- Parameters:
ipSourceAddress
- the sourceAddress to set- Returns:
- IPv4
-
setDestinationAddress
public IPv4 setDestinationAddress(java.net.InetAddress ipDestinationAddress)
Stores the IP destination address from the header.- Parameters:
ipDestinationAddress
- the destination Address to set- Returns:
- IPv4
-
setDestinationAddress
public IPv4 setDestinationAddress(int ipDestinationAddress)
Stores the IP destination address from the header.- Parameters:
ipDestinationAddress
- the destinationAddress to set- Returns:
- IPv4
-
setOptions
public IPv4 setOptions(byte[] options)
Store the options from IP header.- Parameters:
options
- - byte[]- Returns:
- IPv4
-
getfieldnumBits
public int getfieldnumBits(java.lang.String fieldName)
- Overrides:
getfieldnumBits
in classorg.opendaylight.openflowplugin.libraries.liblldp.Packet
-
postSerializeCustomOperation
protected void postSerializeCustomOperation(byte[] data) throws org.opendaylight.openflowplugin.libraries.liblldp.PacketException
- Overrides:
postSerializeCustomOperation
in classorg.opendaylight.openflowplugin.libraries.liblldp.Packet
- Throws:
org.opendaylight.openflowplugin.libraries.liblldp.PacketException
-
setPayload
public void setPayload(org.opendaylight.openflowplugin.libraries.liblldp.Packet payload)
- Overrides:
setPayload
in classorg.opendaylight.openflowplugin.libraries.liblldp.Packet
-
postDeserializeCustomOperation
protected void postDeserializeCustomOperation(byte[] data, int startBitOffset)
Method to perform post deserialization - like compare computed checksum with the one obtained from IP header.- Overrides:
postDeserializeCustomOperation
in classorg.opendaylight.openflowplugin.libraries.liblldp.Packet
-
-