GRE¶
- class os_ken.lib.packet.gre.gre(version=0, protocol=2048, checksum=None, key=None, vsid=None, flow_id=None, seq_number=None)¶
GRE (RFC2784,RFC2890) 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. __init__ takes the corresponding args in this order.
Attribute
Description
version
Version.
protocol
Protocol Type field. The Protocol Type is defined as "ETHER TYPES".
checksum
Checksum field(optional). When you set a value other than None, this field will be automatically calculated.
key
Key field(optional) This field is intended to be used for identifying an individual traffic flow within a tunnel.
vsid
Virtual Subnet ID field(optional) This field is a 24-bit value that is used to identify the NVGRE-based Virtual Layer 2 Network.
flow_id
FlowID field(optional) This field is an 8-bit value that is used to provide per-flow entropy for flows in the same VSID.
seq_number
Sequence Number field(optional)
- 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=None, prev=None)¶
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.
- os_ken.lib.packet.gre.nvgre(version=0, vsid=0, flow_id=0)¶
Generate instance of GRE class with information for NVGRE (RFC7637).
- Parameters:
version -- Version.
vsid -- Virtual Subnet ID.
flow_id -- FlowID.
- Returns:
Instance of GRE class with information for NVGRE.