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.PacketClass that represents the IPv4 packet objects.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description shortgetChecksum()Gets the checksum value stored.intgetDestinationAddress()Gets the destination IP address stored.bytegetDiffServ()Gets the differential services value stored.bytegetECN()Gets the ecn bits stored.intgetfieldnumBits(java.lang.String fieldName)bytegetFlags()Gets the flag values stored.shortgetFragmentOffset()Gets the fragment offset stored.intgetHeaderLen()Gets the IP header length stored.intgetHeaderSize()Gets the header size in bits.shortgetIdentification()Gets the identification value stored.byte[]getOptions()gets the Options stored.bytegetProtocol()Gets the protocol value stored.intgetSourceAddress()Gets the source IP address stored.shortgetTotalLength()Gets the total length of the IP header in bytes.bytegetTtl()Gets the TTL value stored.bytegetVersion()Gets the IP version stored.protected voidpostDeserializeCustomOperation(byte[] data, int startBitOffset)Method to perform post deserialization - like compare computed checksum with the one obtained from IP header.protected voidpostSerializeCustomOperation(byte[] data)IPv4setDestinationAddress(int ipDestinationAddress)Stores the IP destination address from the header.IPv4setDestinationAddress(java.net.InetAddress ipDestinationAddress)Stores the IP destination address from the header.IPv4setDiffServ(byte ipdiffServ)Stores the differential services value from the IP header.IPv4setECN(byte ecn)Stores the ECN bits from the header.IPv4setFlags(byte ipFlags)Stores the IP flags value.IPv4setFragmentOffset(short ipFragmentOffset)Stores the IP fragmentation offset value.voidsetHeaderField(java.lang.String headerField, byte[] readValue)IPv4setHeaderLength(byte ipheaderLength)Stores the length of IP header in words (4 bytes).IPv4setIdentification(short ipIdentification)Stores the identification number from the header.IPv4setOptions(byte[] options)Store the options from IP header.voidsetPayload(org.opendaylight.openflowplugin.libraries.liblldp.Packet payload)IPv4setProtocol(byte ipProtocol)Stores the protocol value of the IP payload.IPv4setSourceAddress(java.net.InetAddress ipSourceAddress)Stores the IP source address from the header.IPv4setTotalLength(short iptotalLength)Stores the total length of IP header in bytes.IPv4setTtl(byte ipTtl)Stores the TTL value.IPv4setVersion(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:
getHeaderSizein 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:
setHeaderFieldin 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:
getfieldnumBitsin classorg.opendaylight.openflowplugin.libraries.liblldp.Packet
-
postSerializeCustomOperation
protected void postSerializeCustomOperation(byte[] data) throws org.opendaylight.openflowplugin.libraries.liblldp.PacketException- Overrides:
postSerializeCustomOperationin 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:
setPayloadin 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:
postDeserializeCustomOperationin classorg.opendaylight.openflowplugin.libraries.liblldp.Packet
-
-