Package org.onlab.packet
Class IPv6
- java.lang.Object
-
- org.onlab.packet.BasePacket
-
- org.onlab.packet.IP
-
- org.onlab.packet.IPv6
-
- All Implemented Interfaces:
IPacket
,IExtensionHeader
public class IPv6 extends IP implements IExtensionHeader
Implements IPv6 packet format. (RFC 2460)
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
destinationAddress
static byte
FIXED_HEADER_LENGTH
protected int
flowLabel
protected byte
hopLimit
static byte
LINK_LOCAL_0
static byte
LINK_LOCAL_1
protected byte
nextHeader
protected short
payloadLength
static byte
PROTOCOL_AH
static Map<Byte,Deserializer<? extends IPacket>>
PROTOCOL_DESERIALIZER_MAP
static byte
PROTOCOL_DSTOPT
static byte
PROTOCOL_ESP
static byte
PROTOCOL_FRAG
static byte
PROTOCOL_HOPOPT
static byte
PROTOCOL_ICMP6
static byte
PROTOCOL_ROUTING
static byte
PROTOCOL_TCP
static byte
PROTOCOL_UDP
protected byte[]
sourceAddress
protected byte
trafficClass
protected byte
version
-
Fields inherited from class org.onlab.packet.BasePacket
parent, payload
-
-
Constructor Summary
Constructors Constructor Description IPv6()
Default constructor that sets the version to 6.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Deserializer<IPv6>
deserializer()
Deserializer function for IPv6 packets.boolean
equals(Object obj)
byte[]
getDestinationAddress()
Gets destination address.int
getFlowLabel()
Gets flow label.byte
getHopLimit()
Gets hop limit.static byte[]
getLinkLocalAddress(byte[] macAddress)
Returns the auto-generated link local address using the mac address as parameter.static byte[]
getMacAddress(byte[] linkLocalAddress)
Returns the mac address from the auto-generated link local address.static byte[]
getMCastMacAddress(byte[] targetIp)
According to the RFC 2464, an IPv6 packet with a multicast destination address DST, consisting of the sixteen octets DST[1] through DST[16], is transmitted to the Ethernet multicast address whose first two octets are the value 3333 hexadecimal and whose last four octets are the last four octets of DST.byte
getNextHeader()
Gets the type of next header.static byte[]
getSolicitNodeAddress(byte[] targetIp)
According to the RFC 4291, the solicitation node addresses are formed by taking the low-order 24 bits of an address (unicast or anycast) and appending those bits to the prefix FF02:0:0:0:0:1:FF00::/104.byte[]
getSourceAddress()
Gets source address.byte
getTrafficClass()
Gets traffic class.byte
getVersion()
Gets IP version number.int
hashCode()
static boolean
isLinkLocalAddress(byte[] targetIp)
According to the RFC 4291, an IPv6 link local address is an IPv6 unicast address that can be automatically configured on any interface using the link-local prefix FE80::/10 (1111 1110 10) and the interface identifier in the modified EUI-64 format.byte[]
serialize()
Sets all payloads parent packet if applicable, then serializes this packet and all payloads.IPv6
setDestinationAddress(byte[] destinationAddress)
Sets destination address.IPv6
setFlowLabel(int flowLabel)
Sets flow label.IPv6
setHopLimit(byte hopLimit)
Sets hop limit.IPv6
setNextHeader(byte nextHeader)
Sets the type of next header.IPv6
setSourceAddress(byte[] sourceAddress)
Sets source address.IPv6
setTrafficClass(byte trafficClass)
Sets traffic class.IPv6
setVersion(byte version)
Sets IP version number.String
toString()
-
Methods inherited from class org.onlab.packet.BasePacket
clone, getParent, getPayload, resetChecksum, setParent, setPayload
-
-
-
-
Field Detail
-
FIXED_HEADER_LENGTH
public static final byte FIXED_HEADER_LENGTH
- See Also:
- Constant Field Values
-
PROTOCOL_TCP
public static final byte PROTOCOL_TCP
- See Also:
- Constant Field Values
-
PROTOCOL_UDP
public static final byte PROTOCOL_UDP
- See Also:
- Constant Field Values
-
PROTOCOL_ICMP6
public static final byte PROTOCOL_ICMP6
- See Also:
- Constant Field Values
-
PROTOCOL_HOPOPT
public static final byte PROTOCOL_HOPOPT
- See Also:
- Constant Field Values
-
PROTOCOL_ROUTING
public static final byte PROTOCOL_ROUTING
- See Also:
- Constant Field Values
-
PROTOCOL_FRAG
public static final byte PROTOCOL_FRAG
- See Also:
- Constant Field Values
-
PROTOCOL_ESP
public static final byte PROTOCOL_ESP
- See Also:
- Constant Field Values
-
PROTOCOL_AH
public static final byte PROTOCOL_AH
- See Also:
- Constant Field Values
-
PROTOCOL_DSTOPT
public static final byte PROTOCOL_DSTOPT
- See Also:
- Constant Field Values
-
LINK_LOCAL_0
public static final byte LINK_LOCAL_0
- See Also:
- Constant Field Values
-
LINK_LOCAL_1
public static final byte LINK_LOCAL_1
- See Also:
- Constant Field Values
-
PROTOCOL_DESERIALIZER_MAP
public static final Map<Byte,Deserializer<? extends IPacket>> PROTOCOL_DESERIALIZER_MAP
-
version
protected byte version
-
trafficClass
protected byte trafficClass
-
flowLabel
protected int flowLabel
-
payloadLength
protected short payloadLength
-
nextHeader
protected byte nextHeader
-
hopLimit
protected byte hopLimit
-
sourceAddress
protected byte[] sourceAddress
-
destinationAddress
protected byte[] destinationAddress
-
-
Method Detail
-
getVersion
public byte getVersion()
Description copied from class:IP
Gets IP version number.- Specified by:
getVersion
in classIP
- Returns:
- IP version number
-
setVersion
public IPv6 setVersion(byte version)
Description copied from class:IP
Sets IP version number.- Specified by:
setVersion
in classIP
- Parameters:
version
- the version to set- Returns:
- IP class
-
getTrafficClass
public byte getTrafficClass()
Gets traffic class.- Returns:
- the traffic class
-
setTrafficClass
public IPv6 setTrafficClass(byte trafficClass)
Sets traffic class.- Parameters:
trafficClass
- the traffic class to set- Returns:
- this
-
getFlowLabel
public int getFlowLabel()
Gets flow label.- Returns:
- the flow label
-
setFlowLabel
public IPv6 setFlowLabel(int flowLabel)
Sets flow label.- Parameters:
flowLabel
- the flow label to set- Returns:
- this
-
getNextHeader
public byte getNextHeader()
Description copied from interface:IExtensionHeader
Gets the type of next header.- Specified by:
getNextHeader
in interfaceIExtensionHeader
- Returns:
- next header
-
setNextHeader
public IPv6 setNextHeader(byte nextHeader)
Description copied from interface:IExtensionHeader
Sets the type of next header.- Specified by:
setNextHeader
in interfaceIExtensionHeader
- Parameters:
nextHeader
- the next header to set- Returns:
- this
-
getHopLimit
public byte getHopLimit()
Gets hop limit.- Returns:
- the hop limit
-
setHopLimit
public IPv6 setHopLimit(byte hopLimit)
Sets hop limit.- Parameters:
hopLimit
- the hop limit to set- Returns:
- this
-
getSourceAddress
public byte[] getSourceAddress()
Gets source address.- Returns:
- the IPv6 source address
-
setSourceAddress
public IPv6 setSourceAddress(byte[] sourceAddress)
Sets source address.- Parameters:
sourceAddress
- the IPv6 source address to set- Returns:
- this
-
getDestinationAddress
public byte[] getDestinationAddress()
Gets destination address.- Returns:
- the IPv6 destination address
-
setDestinationAddress
public IPv6 setDestinationAddress(byte[] destinationAddress)
Sets destination address.- Parameters:
destinationAddress
- the IPv6 destination address to set- Returns:
- this
-
serialize
public byte[] serialize()
Description copied from interface:IPacket
Sets all payloads parent packet if applicable, then serializes this packet and all payloads.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBasePacket
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classBasePacket
-
deserializer
public static Deserializer<IPv6> deserializer()
Deserializer function for IPv6 packets.- Returns:
- deserializer function
-
getSolicitNodeAddress
public static byte[] getSolicitNodeAddress(byte[] targetIp)
According to the RFC 4291, the solicitation node addresses are formed by taking the low-order 24 bits of an address (unicast or anycast) and appending those bits to the prefix FF02:0:0:0:0:1:FF00::/104. Solicited-Node Address: FF02:0:0:0:0:1:FFXX:XXXX- Parameters:
targetIp
- the unicast or anycast address- Returns:
- the computed solicitation node address
-
getMCastMacAddress
public static byte[] getMCastMacAddress(byte[] targetIp)
According to the RFC 2464, an IPv6 packet with a multicast destination address DST, consisting of the sixteen octets DST[1] through DST[16], is transmitted to the Ethernet multicast address whose first two octets are the value 3333 hexadecimal and whose last four octets are the last four octets of DST. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0 0 1 1 0 0 1 1|0 0 1 1 0 0 1 1| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DST[13] | DST[14] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DST[15] | DST[16] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
targetIp
- the multicast address.- Returns:
- the multicast mac address
-
isLinkLocalAddress
public static boolean isLinkLocalAddress(byte[] targetIp)
According to the RFC 4291, an IPv6 link local address is an IPv6 unicast address that can be automatically configured on any interface using the link-local prefix FE80::/10 (1111 1110 10) and the interface identifier in the modified EUI-64 format. +----------------------------------------------------------------+ | 10 bits | 54 bits | 64 bits | +----------- +-------------------------+-------------------------+ | 1111111010 | 0 | interface ID | +----------- +-------------------------+-------------------------+- Parameters:
targetIp
- the ip address to verify- Returns:
- true if the ipv6 address is link local, false otherwise
-
getLinkLocalAddress
public static byte[] getLinkLocalAddress(byte[] macAddress)
Returns the auto-generated link local address using the mac address as parameter.- Parameters:
macAddress
- the mac address to use- Returns:
- the ipv6 link local address
-
getMacAddress
public static byte[] getMacAddress(byte[] linkLocalAddress)
Returns the mac address from the auto-generated link local address.- Parameters:
linkLocalAddress
- the ipv6 to use- Returns:
- the mac address
-
-