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[]destinationAddressstatic byteFIXED_HEADER_LENGTHprotected intflowLabelprotected bytehopLimitstatic byteLINK_LOCAL_0static byteLINK_LOCAL_1protected bytenextHeaderprotected shortpayloadLengthstatic bytePROTOCOL_AHstatic java.util.Map<java.lang.Byte,Deserializer<? extends IPacket>>PROTOCOL_DESERIALIZER_MAPstatic bytePROTOCOL_DSTOPTstatic bytePROTOCOL_ESPstatic bytePROTOCOL_FRAGstatic bytePROTOCOL_HOPOPTstatic bytePROTOCOL_ICMP6static bytePROTOCOL_ROUTINGstatic bytePROTOCOL_TCPstatic bytePROTOCOL_UDPprotected byte[]sourceAddressprotected bytetrafficClassprotected byteversion-
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.booleanequals(java.lang.Object obj)byte[]getDestinationAddress()Gets destination address.intgetFlowLabel()Gets flow label.bytegetHopLimit()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.bytegetNextHeader()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.bytegetTrafficClass()Gets traffic class.bytegetVersion()Gets IP version number.inthashCode()static booleanisLinkLocalAddress(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.IPv6setDestinationAddress(byte[] destinationAddress)Sets destination address.IPv6setFlowLabel(int flowLabel)Sets flow label.IPv6setHopLimit(byte hopLimit)Sets hop limit.IPv6setNextHeader(byte nextHeader)Sets the type of next header.IPv6setSourceAddress(byte[] sourceAddress)Sets source address.IPv6setTrafficClass(byte trafficClass)Sets traffic class.IPv6setVersion(byte version)Sets IP version number.java.lang.StringtoString()-
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 java.util.Map<java.lang.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:IPGets IP version number.- Specified by:
getVersionin classIP- Returns:
- IP version number
-
setVersion
public IPv6 setVersion(byte version)
Description copied from class:IPSets IP version number.- Specified by:
setVersionin 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:IExtensionHeaderGets the type of next header.- Specified by:
getNextHeaderin interfaceIExtensionHeader- Returns:
- next header
-
setNextHeader
public IPv6 setNextHeader(byte nextHeader)
Description copied from interface:IExtensionHeaderSets the type of next header.- Specified by:
setNextHeaderin 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:IPacketSets all payloads parent packet if applicable, then serializes this packet and all payloads.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classBasePacket
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classBasePacket
-
deserializer
public static Deserializer<IPv6> deserializer()
Deserializer function for IPv6 packets.- Returns:
- deserializer function
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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
-
-