IPv6

class os_ken.lib.packet.ipv6.auth(nxt=6, size=2, spi=0, seq=0, data=b'x00x00x00x00')

IP Authentication header (RFC 2402) encoder/decoder class.

This is used with os_ken.lib.packet.ipv6.ipv6.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

nxt

Next Header

size

the length of the Authentication Header in 64-bit words, subtracting 1.

spi

security parameters index.

seq

sequence number.

data

authentication data.

class os_ken.lib.packet.ipv6.dst_opts(nxt=6, size=0, data=None)

IPv6 (RFC 2460) destination header encoder/decoder class.

This is used with os_ken.lib.packet.ipv6.ipv6.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

nxt

Next Header

size

the length of the destination header, not include the first 8 octet.

data

IPv6 options.

class os_ken.lib.packet.ipv6.fragment(nxt=6, offset=0, more=0, id_=0)

IPv6 (RFC 2460) fragment header encoder/decoder class.

This is used with os_ken.lib.packet.ipv6.ipv6.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

nxt

Next Header

offset

offset, in 8-octet units, relative to the start of the fragmentable part of the original packet.

more

1 means more fragments follow; 0 means last fragment.

id_

packet identification value.

class os_ken.lib.packet.ipv6.header(nxt)

extension header abstract class.

class os_ken.lib.packet.ipv6.hop_opts(nxt=6, size=0, data=None)

IPv6 (RFC 2460) Hop-by-Hop Options header encoder/decoder class.

This is used with os_ken.lib.packet.ipv6.ipv6.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

nxt

Next Header

size

the length of the Hop-by-Hop Options header, not include the first 8 octet.

data

IPv6 options.

class os_ken.lib.packet.ipv6.ipv6(version=6, traffic_class=0, flow_label=0, payload_length=0, nxt=6, hop_limit=255, src='10::10', dst='20::20', ext_hdrs=None)

IPv6 (RFC 2460) header encoder/decoder class.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. IPv6 addresses are represented as a string like 'ff02::1'. __init__ takes the corresponding args in this order.

Attribute

Description

Example

version

Version

traffic_class

Traffic Class

flow_label

When decoding, Flow Label. When encoding, the most significant 8 bits of Flow Label.

payload_length

Payload Length

nxt

Next Header

hop_limit

Hop Limit

src

Source Address

'ff02::1'

dst

Destination Address

'::'

ext_hdrs

Extension Headers

classmethod parser(buf)

Decode a protocol header.

This method is used only when decoding a packet.

Decode a protocol header at offset 0 in bytearray buf. Returns the following three objects.

  • An object to describe the decoded header.

  • A packet_base.PacketBase subclass appropriate for the rest of the packet. None when the rest of the packet should be considered as raw payload.

  • The rest of packet.

serialize(payload, prev)

Encode a protocol header.

This method is used only when encoding a packet.

Encode a protocol header. Returns a bytearray which contains the header.

payload is the rest of the packet which will immediately follow this header.

prev is a packet_base.PacketBase subclass for the outer protocol header. prev is None if the current header is the outer-most. For example, prev is ipv4 or ipv6 for tcp.serialize.

class os_ken.lib.packet.ipv6.opt_header(nxt, size, data)

an abstract class for Hop-by-Hop Options header and destination header.

class os_ken.lib.packet.ipv6.option(type_=0, len_=-1, data=None)

IPv6 (RFC 2460) Options header encoder/decoder class.

This is used with os_ken.lib.packet.ipv6.hop_opts or

os_ken.lib.packet.ipv6.dst_opts.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

type_

option type.

len_

the length of data. -1 if type_ is 0.

data

an option value. None if len_ is 0 or -1.

class os_ken.lib.packet.ipv6.routing(nxt)

An IPv6 Routing Header decoder class. This class has only the parser method.

IPv6 Routing Header types.

http://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml

Value

Description

Reference

0

Source Route (DEPRECATED)

[[IPV6]][RFC5095]

1

Nimrod (DEPRECATED 2009-05-06)

2

Type 2 Routing Header

[RFC6275]

3

RPL Source Route Header

[RFC6554]

4 - 252

Unassigned

253

RFC3692-style Experiment 1 [2]

[RFC4727]

254

RFC3692-style Experiment 2 [2]

[RFC4727]

255

Reserved

class os_ken.lib.packet.ipv6.routing_type3(nxt=6, size=0, type_=3, seg=0, cmpi=0, cmpe=0, adrs=None)

An IPv6 Routing Header for Source Routes with the RPL (RFC 6554) encoder/decoder class.

This is used with os_ken.lib.packet.ipv6.ipv6.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

nxt

Next Header

size

The length of the Routing header, not include the first 8 octet. (0 means automatically-calculate when encoding)

type

Identifies the particular Routing header variant.

seg

Number of route segments remaining.

cmpi

Number of prefix octets from segments 1 through n-1.

cmpe

Number of prefix octets from segment n.

pad

Number of octets that are used for padding after Address[n] at the end of the SRH.

adrs

Vector of addresses, numbered 1 to n.