VRRP¶
VRRP packet parser/serializer
[RFC 3768] VRRP v2 packet format:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Type | Virtual Rtr ID| Priority | Count IP Addrs|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Auth Type | Adver Int | Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IP Address (1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| . |
| . |
| . |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IP Address (n) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication Data (1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Authentication Data (2) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
[RFC 5798] VRRP v3 packet format:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IPv4 Fields or IPv6 Fields |
... ...
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Type | Virtual Rtr ID| Priority |Count IPvX Addr|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|(rsvd) | Max Adver Int | Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| IPvX Address(es) |
+ +
+ +
+ +
+ +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
class
os_ken.lib.packet.vrrp.vrrp(version, type_, vrid, priority, count_ip, max_adver_int, checksum, ip_addresses, auth_type=None, auth_data=None)¶ The base class for VRRPv2 (RFC 3768) and VRRPv3 (RFC 5798) header encoder/decoder classes.
Unlike other os_ken.lib.packet.packet_base.PacketBase derived classes, This class should not be directly instantiated by user.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order.
Attribute Description version Version type Type vrid Virtual Rtr ID (VRID) priority Priority count_ip Count IPvX Addr. Calculated automatically when encoding. max_adver_int Maximum Advertisement Interval (Max Adver Int) checksum Checksum. Calculated automatically when encoding. ip_addresses IPvX Address(es). A python list of IP addresses. auth_type Authentication Type (only for VRRPv2) auth_data Authentication Data (only for VRRPv2) -
create_packet(primary_ip_address, vlan_id=None)¶ Prepare a VRRP packet.
Returns a newly created os_ken.lib.packet.packet.Packet object with appropriate protocol header objects added by add_protocol(). It's caller's responsibility to serialize(). The serialized packet would looks like the ones described in the following sections.
- RFC 3768 5.1. VRRP Packet Format
- RFC 5798 5.1. VRRP Packet Format
Argument Description primary_ip_address Source IP address vlan_id VLAN ID. None for no VLAN.
-
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.vrrp.vrrpv2(version, type_, vrid, priority, count_ip, max_adver_int, checksum, ip_addresses, auth_type=None, auth_data=None)¶ VRRPv2 (RFC 3768) header encoder/decoder class.
Unlike other os_ken.lib.packet.packet_base.PacketBase derived classes, create method should be used to instantiate an object of this class.
-
static
create(type_, vrid, priority, max_adver_int, ip_addresses)¶ Unlike other os_ken.lib.packet.packet_base.PacketBase derived classes, this method should be used to instantiate an object of this class.
This method's arguments are same as os_ken.lib.packet.vrrp.vrrp object's attributes of the same name. (except that type_ corresponds to type attribute.)
-
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.
-
static
-
class
os_ken.lib.packet.vrrp.vrrpv3(version, type_, vrid, priority, count_ip, max_adver_int, checksum, ip_addresses, auth_type=None, auth_data=None)¶ VRRPv3 (RFC 5798) header encoder/decoder class.
Unlike other os_ken.lib.packet.packet_base.PacketBase derived classes, create method should be used to instantiate an object of this class.
-
static
create(type_, vrid, priority, max_adver_int, ip_addresses)¶ Unlike other os_ken.lib.packet.packet_base.PacketBase derived classes, this method should be used to instantiate an object of this class.
This method's arguments are same as os_ken.lib.packet.vrrp.vrrp object's attributes of the same name. (except that type_ corresponds to type attribute.)
-
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.
-
static