diff --git a/doc/source/library_packet_ref.rst b/doc/source/library_packet_ref.rst index 301bad48..f47d35bd 100644 --- a/doc/source/library_packet_ref.rst +++ b/doc/source/library_packet_ref.rst @@ -57,3 +57,8 @@ Protocol Header classes :members: .. autoclass:: ryu.lib.packet.vrrp.vrrpv3 :members: + +.. autoclass:: ryu.lib.packet.slow.slow + :members: +.. autoclass:: ryu.lib.packet.slow.lacp + :members: diff --git a/ryu/lib/packet/slow.py b/ryu/lib/packet/slow.py new file mode 100755 index 00000000..7f4870b9 --- /dev/null +++ b/ryu/lib/packet/slow.py @@ -0,0 +1,577 @@ +# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import struct +from . import packet_base +from ryu.lib import mac + +# Slow Protocol Multicast destination +SLOW_PROTOCOL_MULTICAST = '\x01\x80\xc2\x00\x00\x02' + +# Slow Protocol SubType +SLOW_SUBTYPE_LACP = 0x01 +SLOW_SUBTYPE_MARKER = 0x02 +SLOW_SUBTYPE_OAM = 0x03 +SLOW_SUBTYPE_OSSP = 0x0a + + +class slow(packet_base.PacketBase): + """Slow Protocol header decoder class. + This class has only the parser method. + + http://standards.ieee.org/getieee802/download/802.3-2012_section5.pdf + + Slow Protocols Subtypes + + +---------------+--------------------------------------------------+ + | Subtype Value | Protocol Name | + +===============+==================================================+ + | 0 | Unused - Illegal Value | + +---------------+--------------------------------------------------+ + | 1 | Link Aggregation Control Protocol(LACP) | + +---------------+--------------------------------------------------+ + | 2 | Link Aggregation - Marker Protocol | + +---------------+--------------------------------------------------+ + | 3 | Operations, Administration, and Maintenance(OAM) | + +---------------+--------------------------------------------------+ + | 4 - 9 | Reserved for future use | + +---------------+--------------------------------------------------+ + | 10 | Organization Specific Slow Protocol(OSSP) | + +---------------+--------------------------------------------------+ + | 11 - 255 | Unused - Illegal values | + +---------------+--------------------------------------------------+ + """ + _PACK_STR = '!B' + + @classmethod + def parser(cls, buf): + (subtype, ) = struct.unpack_from(cls._PACK_STR, buf) + switch = { + SLOW_SUBTYPE_LACP: lacp, + # TODO: make parsers of other subtypes. + SLOW_SUBTYPE_MARKER: None, + SLOW_SUBTYPE_OAM: None, + SLOW_SUBTYPE_OSSP: None, + } + cls_ = switch.get(subtype) + if cls_: + return cls_.parser(buf) + else: + return None, None, buf + + +class lacp(packet_base.PacketBase): + """Link Aggregation Control Protocol(LACP, IEEE 802.1AX) + header encoder/decoder class. + + http://standards.ieee.org/getieee802/download/802.1AX-2008.pdf + + LACPDU format + + +------------------------------------------------+--------+ + | LACPDU structure | Octets | + +================================================+========+ + | Subtype = LACP | 1 | + +------------------------------------------------+--------+ + | Version Number | 1 | + +------------+-----------------------------------+--------+ + | TLV | TLV_type = Actor Information | 1 | + | Actor +-----------------------------------+--------+ + | | Actor_Information_Length = 20 | 1 | + | +-----------------------------------+--------+ + | | Actor_System_Priority | 2 | + | +-----------------------------------+--------+ + | | Actor_System | 6 | + | +-----------------------------------+--------+ + | | Actor_Key | 2 | + | +-----------------------------------+--------+ + | | Actor_Port_Priority | 2 | + | +-----------------------------------+--------+ + | | Actor_Port | 2 | + | +-----------------------------------+--------+ + | | Actor_State | 1 | + | +-----------------------------------+--------+ + | | Reserved | 3 | + +------------+-----------------------------------+--------+ + | TLV | TLV_type = Partner Information | 1 | + | Partner +-----------------------------------+--------+ + | | Partner_Information_Length = 20 | 1 | + | +-----------------------------------+--------+ + | | Partner_System_Priority | 2 | + | +-----------------------------------+--------+ + | | Partner_System | 6 | + | +-----------------------------------+--------+ + | | Partner_Key | 2 | + | +-----------------------------------+--------+ + | | Partner_Port_Priority | 2 | + | +-----------------------------------+--------+ + | | Partner_Port | 2 | + | +-----------------------------------+--------+ + | | Partner_State | 1 | + | +-----------------------------------+--------+ + | | Reserved | 3 | + +------------+-----------------------------------+--------+ + | TLV | TLV_type = Collector Information | 1 | + | Collector +-----------------------------------+--------+ + | | Collector_Information_Length = 16 | 1 | + | +-----------------------------------+--------+ + | | Collector_Max_Delay | 2 | + | +-----------------------------------+--------+ + | | Reserved | 12 | + +------------+-----------------------------------+--------+ + | TLV | TLV_type = Terminator | 1 | + | Terminator +-----------------------------------+--------+ + | | Terminator_Length = 0 | 1 | + | +-----------------------------------+--------+ + | | Reserved | 50 | + +------------+-----------------------------------+--------+ + + + Terminator information uses a length value of 0 (0x00). + + NOTE--The use of a Terminator_Length of 0 is intentional. + In TLV encoding schemes it is common practice + for the terminator encoding to be 0 both + for the type and the length. + + Actor_State and Partner_State encoded as individual bits within + a single octet as follows: + + +------+------+------+------+------+------+------+------+ + | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | + +======+======+======+======+======+======+======+======+ + | EXPR | DFLT | DIST | CLCT | SYNC | AGGR | TMO | ACT | + +------+------+------+------+------+------+------+------+ + + ACT + bit 0. + about the activity control value with regard to this link. + TMO + bit 1. + about the timeout control value with regard to this link. + AGGR + bit 2. + about how the system regards this link from the point of view + of the aggregation. + SYNC + bit 3. + about how the system regards this link from the point of view + of the synchronization. + CLCT + bit 4. + about collecting of incoming frames. + DIST + bit 5. + about distributing of outgoing frames. + DFLT + bit 6. + about the opposite system information which the system use. + EXPR + bit 7. + about the expire state of the system. + + 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 correspondig args in this order. + + =============================== ==================================== + Attribute Description + =============================== ==================================== + version LACP version. This parameter must be + set to LACP_VERSION_NUMBER(i.e. 1). + + actor_system_priority The priority assigned to this + System. + + actor_system The Actor's System ID, encoded as + a MAC address. + + actor_key The operational Key value assigned + to the port by the Actor. + + actor_port_priority The priority assigned to this port. + + actor_port The port number assigned to the + port by the Actor. + + actor_state_activity .. _lacp_activity: + + | about the activity control value + with regard to this link. + | LACP_STATE_ACTIVE(1) + | LACP_STATE_PASSIVE(0) + + actor_state_timeout .. _lacp_timeout: + + | about the timeout control value + with regard to this link. + | LACP_STATE_SHORT_TIMEOUT(1) + | LACP_STATE_LONG_TIMEOUT(0) + + actor_state_aggregation .. _lacp_aggregation: + + | about how the system regards this + link from the point of view of the + aggregation. + | LACP_STATE_AGGREGATEABLE(1) + | LACP_STATE_INDIVIDUAL(0) + + actor_state_synchronization .. _lacp_synchronization: + + | about how the system regards this + link from the point of view of the + synchronization. + | LACP_STATE_IN_SYNC(1) + | LACP_STATE_OUT_OF_SYNC(0) + + actor_state_collecting .. _lacp_collecting: + + | about collecting of incoming + frames. + | LACP_STATE_COLLECTING_ENABLED(1) + | LACP_STATE_COLLECTING_DISABLED(0) + + actor_state_distributing .. _lacp_distributing: + + | about distributing of outgoing + frames. + | LACP_STATE_DISTRIBUTING_ENABLED(1) + | LACP_STATE_DISTRIBUTING_DISABLED(0) + + actor_state_defaulted .. _lacp_defaulted: + + | about the Partner information + which the the Actor use. + | LACP_STATE_DEFAULTED_PARTNER(1) + | LACP_STATE_OPERATIONAL_PARTNER(0) + + actor_state_expired .. _lacp_expired: + + | about the state of the Actor. + | LACP_STATE_EXPIRED(1) + | LACP_STATE_NOT_EXPIRED(0) + + partner_system_priority The priority assigned to the + Partner System. + + partner_system The Partner's System ID, encoded + as a MAC address. + + partner_key The operational Key value assigned + to the port by the Partner. + + partner_port_priority The priority assigned to this port + by the Partner. + + partner_port The port number assigned to the + port by the Partner. + + partner_state_activity See :ref:`actor_state_activity\ + `. + + partner_state_timeout See :ref:`actor_state_timeout\ + `. + + partner_state_aggregation See :ref:`actor_state_aggregation\ + `. + + partner_state_synchronization See + :ref:`actor_state_synchronization\ + `. + + partner_state_collecting See :ref:`actor_state_collecting\ + `. + + partner_state_distributing See :ref:`actor_state_distributing\ + `. + + partner_state_defaulted See :ref:`actor_state_defaulted\ + `. + + partner_state_expired See :ref:`actor_state_expired\ + `. + + collector_max_delay the maximum time that the Frame + Collector may delay. + =============================== ==================================== + + """ + LACP_VERSION_NUMBER = 1 + + # LACP TLV type + LACP_TLV_TYPE_ACTOR = 1 + LACP_TLV_TYPE_PARTNER = 2 + LACP_TLV_TYPE_COLLECTOR = 3 + LACP_TLV_TYPE_TERMINATOR = 0 + + # LACP state(LACP_Activity) + LACP_STATE_ACTIVE = 1 + LACP_STATE_PASSIVE = 0 + # LACP state(LACP_Timeout) + LACP_STATE_SHORT_TIMEOUT = 1 + LACP_STATE_LONG_TIMEOUT = 0 + # LACP state(Aggregation) + LACP_STATE_AGGREGATEABLE = 1 + LACP_STATE_INDIVIDUAL = 0 + # LACP state(Synchronization) + LACP_STATE_IN_SYNC = 1 + LACP_STATE_OUT_OF_SYNC = 0 + # LACP state(Collecting) + LACP_STATE_COLLECTING_ENABLED = 1 + LACP_STATE_COLELCTING_DISABLED = 0 + # LACP state(Distributing) + LACP_STATE_DISTRIBUTING_ENABLED = 1 + LACP_STATE_DISTRIBUTING_DISABLED = 0 + # LACP state(Defaulted) + LACP_STATE_DEFAULED_PARTNER = 1 + LACP_STATE_OPERATIONAL_PARTNER = 0 + # LACP state(Expired) + LACP_STATE_EXPIRED = 1 + LACP_STATE_NOT_EXPIRED = 0 + + # The number of seconds between periodic transmissions using + # Short Timeouts. + FAST_PERIODIC_TIME = 1 + # The number of seconds between periodic transmissions using + # Long Timeouts. + SLOW_PERIODIC_TIME = 30 + # The number of seconds before invalidating received LACPDU + # information when using Short Timeouts(3 x Fast_Periodic_Time). + SHORT_TIMEOUT_TIME = 3 * FAST_PERIODIC_TIME + # The number of seconds before invalidating received LACPDU + # information when using Long Timeouts (3 x Slow_Periodic_Time). + LONG_TIMEOUT_TIME = 3 * SLOW_PERIODIC_TIME + + _HLEN_PACK_STR = '!BB' + _HLEN_PACK_LEN = struct.calcsize(_HLEN_PACK_STR) + _ACTPRT_INFO_PACK_STR = '!BBH6sHHHB3x' + _ACTPRT_INFO_PACK_LEN = struct.calcsize(_ACTPRT_INFO_PACK_STR) + _COL_INFO_PACK_STR = '!BBH12x' + _COL_INFO_PACK_LEN = struct.calcsize(_COL_INFO_PACK_STR) + _TRM_PACK_STR = '!BB50x' + _TRM_PACK_LEN = struct.calcsize(_TRM_PACK_STR) + _ALL_PACK_LEN = _HLEN_PACK_LEN + _ACTPRT_INFO_PACK_LEN * 2 + \ + _COL_INFO_PACK_LEN + _TRM_PACK_LEN + + def __init__(self, version=LACP_VERSION_NUMBER, + actor_system_priority=0, + actor_system=mac.haddr_to_bin('00:00:00:00:00:00'), + actor_key=0, actor_port_priority=0, actor_port=0, + actor_state_activity=0, actor_state_timeout=0, + actor_state_aggregation=0, + actor_state_synchronization=0, + actor_state_collecting=0, actor_state_distributing=0, + actor_state_defaulted=0, actor_state_expired=0, + partner_system_priority=0, + partner_system=mac.haddr_to_bin('00:00:00:00:00:00'), + partner_key=0, partner_port_priority=0, partner_port=0, + partner_state_activity=0, partner_state_timeout=0, + partner_state_aggregation=0, + partner_state_synchronization=0, + partner_state_collecting=0, + partner_state_distributing=0, + partner_state_defaulted=0, partner_state_expired=0, + collector_max_delay=0): + super(lacp, self).__init__() + # parameter check + assert (1 == actor_state_activity | 1) + assert (1 == actor_state_timeout | 1) + assert (1 == actor_state_aggregation | 1) + assert (1 == actor_state_synchronization | 1) + assert (1 == actor_state_collecting | 1) + assert (1 == actor_state_distributing | 1) + assert (1 == actor_state_defaulted | 1) + assert (1 == actor_state_expired | 1) + assert (1 == partner_state_activity | 1) + assert (1 == partner_state_timeout | 1) + assert (1 == partner_state_aggregation | 1) + assert (1 == partner_state_synchronization | 1) + assert (1 == partner_state_collecting | 1) + assert (1 == partner_state_distributing | 1) + assert (1 == partner_state_defaulted | 1) + assert (1 == partner_state_expired | 1) + #------------------------------ + # Header + #------------------------------ + self.subtype = SLOW_SUBTYPE_LACP + self.version = version + #------------------------------ + # Actor Information + #------------------------------ + self.actor_tag = self.LACP_TLV_TYPE_ACTOR + self.actor_length = self._ACTPRT_INFO_PACK_LEN + self.actor_system_priority = actor_system_priority + self.actor_system = actor_system + self.actor_key = actor_key + self.actor_port_priority = actor_port_priority + self.actor_port = actor_port + self.actor_state_activity = actor_state_activity + self.actor_state_timeout = actor_state_timeout + self.actor_state_aggregation = actor_state_aggregation + self.actor_state_synchronization = actor_state_synchronization + self.actor_state_collecting = actor_state_collecting + self.actor_state_distributing = actor_state_distributing + self.actor_state_defaulted = actor_state_defaulted + self.actor_state_expired = actor_state_expired + self.actor_state = ( + (self.actor_state_activity << 0) | + (self.actor_state_timeout << 1) | + (self.actor_state_aggregation << 2) | + (self.actor_state_synchronization << 3) | + (self.actor_state_collecting << 4) | + (self.actor_state_distributing << 5) | + (self.actor_state_defaulted << 6) | + (self.actor_state_expired << 7)) + #------------------------------ + # Partner Information + #------------------------------ + self.partner_tag = self.LACP_TLV_TYPE_PARTNER + self.partner_length = self._ACTPRT_INFO_PACK_LEN + self.partner_system_priority = partner_system_priority + self.partner_system = partner_system + self.partner_key = partner_key + self.partner_port_priority = partner_port_priority + self.partner_port = partner_port + self.partner_state_activity = partner_state_activity + self.partner_state_timeout = partner_state_timeout + self.partner_state_aggregation = partner_state_aggregation + self.partner_state_synchronization = \ + partner_state_synchronization + self.partner_state_collecting = partner_state_collecting + self.partner_state_distributing = partner_state_distributing + self.partner_state_defaulted = partner_state_defaulted + self.partner_state_expired = partner_state_expired + self.partner_state = ( + (self.partner_state_activity << 0) | + (self.partner_state_timeout << 1) | + (self.partner_state_aggregation << 2) | + (self.partner_state_synchronization << 3) | + (self.partner_state_collecting << 4) | + (self.partner_state_distributing << 5) | + (self.partner_state_defaulted << 6) | + (self.partner_state_expired << 7)) + #------------------------------ + # Collector Information + #------------------------------ + self.collector_tag = self.LACP_TLV_TYPE_COLLECTOR + self.collector_length = self._COL_INFO_PACK_LEN + self.collector_max_delay = collector_max_delay + #------------------------------ + # Terminator + #------------------------------ + self.terminator_tag = self.LACP_TLV_TYPE_TERMINATOR + self.terminator_length = 0 + + @classmethod + def parser(cls, buf): + assert cls._ALL_PACK_LEN == len(buf) + offset = 0 + #------------------------------ + # Header + #------------------------------ + (subtype, version + ) = struct.unpack_from(cls._HLEN_PACK_STR, buf, offset) + assert SLOW_SUBTYPE_LACP == subtype + assert cls.LACP_VERSION_NUMBER == version + offset += cls._HLEN_PACK_LEN + #------------------------------ + # Actor Information + #------------------------------ + (actor_tag, actor_length, actor_system_priority, actor_system, + actor_key, actor_port_priority, actor_port, actor_state + ) = struct.unpack_from(cls._ACTPRT_INFO_PACK_STR, buf, offset) + assert cls.LACP_TLV_TYPE_ACTOR == actor_tag + assert cls._ACTPRT_INFO_PACK_LEN == actor_length + offset += cls._ACTPRT_INFO_PACK_LEN + actor_state_activity = (actor_state >> 0) & 1 + actor_state_timeout = (actor_state >> 1) & 1 + actor_state_aggregation = (actor_state >> 2) & 1 + actor_state_synchronization = (actor_state >> 3) & 1 + actor_state_collecting = (actor_state >> 4) & 1 + actor_state_distributing = (actor_state >> 5) & 1 + actor_state_defaulted = (actor_state >> 6) & 1 + actor_state_expired = (actor_state >> 7) & 1 + #------------------------------ + # Partner Information + #------------------------------ + (partner_tag, partner_length, partner_system_priority, + partner_system, partner_key, partner_port_priority, + partner_port, partner_state + ) = struct.unpack_from(cls._ACTPRT_INFO_PACK_STR, buf, offset) + assert cls.LACP_TLV_TYPE_PARTNER == partner_tag + assert cls._ACTPRT_INFO_PACK_LEN == partner_length + offset += cls._ACTPRT_INFO_PACK_LEN + partner_state_activity = (partner_state >> 0) & 1 + partner_state_timeout = (partner_state >> 1) & 1 + partner_state_aggregation = (partner_state >> 2) & 1 + partner_state_synchronization = (partner_state >> 3) & 1 + partner_state_collecting = (partner_state >> 4) & 1 + partner_state_distributing = (partner_state >> 5) & 1 + partner_state_defaulted = (partner_state >> 6) & 1 + partner_state_expired = (partner_state >> 7) & 1 + #------------------------------ + # Collector Information + #------------------------------ + (collector_tag, collector_length, collector_max_delay + ) = struct.unpack_from(cls._COL_INFO_PACK_STR, buf, offset) + assert cls.LACP_TLV_TYPE_COLLECTOR == collector_tag + assert cls._COL_INFO_PACK_LEN == collector_length + offset += cls._COL_INFO_PACK_LEN + #------------------------------ + # Terminator Information + #------------------------------ + (terminator_tag, terminator_length + ) = struct.unpack_from(cls._TRM_PACK_STR, buf, offset) + assert cls.LACP_TLV_TYPE_TERMINATOR == terminator_tag + assert 0 == terminator_length + return cls(version, actor_system_priority, + actor_system, actor_key, actor_port_priority, + actor_port, actor_state_activity, + actor_state_timeout, actor_state_aggregation, + actor_state_synchronization, actor_state_collecting, + actor_state_distributing, actor_state_defaulted, + actor_state_expired, partner_system_priority, + partner_system, partner_key, partner_port_priority, + partner_port, partner_state_activity, + partner_state_timeout, partner_state_aggregation, + partner_state_synchronization, + partner_state_collecting, partner_state_distributing, + partner_state_defaulted, partner_state_expired, + collector_max_delay), None, buf[lacp._ALL_PACK_LEN:] + + def serialize(self, payload, prev): + header = struct.pack(self._HLEN_PACK_STR, self.subtype, + self.version) + actor = struct.pack(self._ACTPRT_INFO_PACK_STR, + self.actor_tag, self.actor_length, + self.actor_system_priority, + self.actor_system, self.actor_key, + self.actor_port_priority, self.actor_port, + self.actor_state) + partner = struct.pack(self._ACTPRT_INFO_PACK_STR, + self.partner_tag, self.partner_length, + self.partner_system_priority, + self.partner_system, self.partner_key, + self.partner_port_priority, + self.partner_port, self.partner_state) + collector = struct.pack(self._COL_INFO_PACK_STR, + self.collector_tag, + self.collector_length, + self.collector_max_delay) + terminator = struct.pack(self._TRM_PACK_STR, + self.terminator_tag, + self.terminator_length) + return header + actor + partner + collector + terminator diff --git a/ryu/lib/packet/vlan.py b/ryu/lib/packet/vlan.py index 913d7cdb..cbd63968 100644 --- a/ryu/lib/packet/vlan.py +++ b/ryu/lib/packet/vlan.py @@ -19,6 +19,7 @@ from . import arp from . import ipv4 from . import ipv6 from . import lldp +from . import slow from ryu.ofproto import ether from ryu.ofproto.ofproto_parser import msg_pack_into @@ -67,3 +68,4 @@ vlan.register_packet_type(arp.arp, ether.ETH_TYPE_ARP) vlan.register_packet_type(ipv4.ipv4, ether.ETH_TYPE_IP) vlan.register_packet_type(ipv6.ipv6, ether.ETH_TYPE_IPV6) vlan.register_packet_type(lldp.lldp, ether.ETH_TYPE_LLDP) +vlan.register_packet_type(slow.slow, ether.ETH_TYPE_SLOW) diff --git a/ryu/tests/unit/packet/test_slow.py b/ryu/tests/unit/packet/test_slow.py new file mode 100755 index 00000000..fe6a0e5f --- /dev/null +++ b/ryu/tests/unit/packet/test_slow.py @@ -0,0 +1,1096 @@ +# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import unittest +import logging +import copy +from struct import pack, unpack_from +from nose.tools import ok_, eq_, raises +from ryu.ofproto import ether +from ryu.lib import mac +from ryu.lib.packet.ethernet import ethernet +from ryu.lib.packet.packet import Packet +from ryu.lib.packet.slow import slow, lacp +from ryu.lib.packet.slow import SLOW_PROTOCOL_MULTICAST +from ryu.lib.packet.slow import SLOW_SUBTYPE_LACP +from ryu.lib.packet.slow import SLOW_SUBTYPE_MARKER + +LOG = logging.getLogger(__name__) + + +class Test_slow(unittest.TestCase): + """ Test case for Slow Protocol + """ + def setUp(self): + self.subtype = SLOW_SUBTYPE_LACP + self.version = lacp.LACP_VERSION_NUMBER + self.actor_tag = lacp.LACP_TLV_TYPE_ACTOR + self.actor_length = 20 + self.actor_system_priority = 65534 + self.actor_system = mac.haddr_to_bin('00:07:0d:af:f4:54') + self.actor_key = 1 + self.actor_port_priority = 65535 + self.actor_port = 1 + self.actor_state_activity = lacp.LACP_STATE_ACTIVE + self.actor_state_timeout = lacp.LACP_STATE_LONG_TIMEOUT + self.actor_state_aggregation = lacp.LACP_STATE_AGGREGATEABLE + self.actor_state_synchronization = lacp.LACP_STATE_IN_SYNC + self.actor_state_collecting = lacp.LACP_STATE_COLLECTING_ENABLED + self.actor_state_distributing = lacp.LACP_STATE_DISTRIBUTING_ENABLED + self.actor_state_defaulted = lacp.LACP_STATE_OPERATIONAL_PARTNER + self.actor_state_expired = lacp.LACP_STATE_EXPIRED + self.actor_state = ( + (self.actor_state_activity << 0) | + (self.actor_state_timeout << 1) | + (self.actor_state_aggregation << 2) | + (self.actor_state_synchronization << 3) | + (self.actor_state_collecting << 4) | + (self.actor_state_distributing << 5) | + (self.actor_state_defaulted << 6) | + (self.actor_state_expired << 7)) + self.partner_tag = lacp.LACP_TLV_TYPE_PARTNER + self.partner_length = 20 + self.partner_system_priority = 0 + self.partner_system = mac.haddr_to_bin('00:00:00:00:00:00') + self.partner_key = 0 + self.partner_port_priority = 0 + self.partner_port = 0 + self.partner_state_activity = 0 + self.partner_state_timeout = lacp.LACP_STATE_SHORT_TIMEOUT + self.partner_state_aggregation = 0 + self.partner_state_synchronization = 0 + self.partner_state_collecting = 0 + self.partner_state_distributing = 0 + self.partner_state_defaulted = 0 + self.partner_state_expired = 0 + self.partner_state = ( + (self.partner_state_activity << 0) | + (self.partner_state_timeout << 1) | + (self.partner_state_aggregation << 2) | + (self.partner_state_synchronization << 3) | + (self.partner_state_collecting << 4) | + (self.partner_state_distributing << 5) | + (self.partner_state_defaulted << 6) | + (self.partner_state_expired << 7)) + self.collector_tag = lacp.LACP_TLV_TYPE_COLLECTOR + self.collector_length = 16 + self.collector_max_delay = 0 + self.terminator_tag = lacp.LACP_TLV_TYPE_TERMINATOR + self.terminator_length = 0 + + self.head_fmt = lacp._HLEN_PACK_STR + self.head_len = lacp._HLEN_PACK_LEN + self.act_fmt = lacp._ACTPRT_INFO_PACK_STR + self.act_len = lacp._ACTPRT_INFO_PACK_LEN + self.prt_fmt = lacp._ACTPRT_INFO_PACK_STR + self.prt_len = lacp._ACTPRT_INFO_PACK_LEN + self.col_fmt = lacp._COL_INFO_PACK_STR + self.col_len = lacp._COL_INFO_PACK_LEN + self.trm_fmt = lacp._TRM_PACK_STR + self.trm_len = lacp._TRM_PACK_LEN + self.length = lacp._ALL_PACK_LEN + + self.head_buf = pack(self.head_fmt, + self.subtype, + self.version) + self.act_buf = pack(self.act_fmt, + self.actor_tag, + self.actor_length, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state) + self.prt_buf = pack(self.prt_fmt, + self.partner_tag, + self.partner_length, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state) + self.col_buf = pack(self.col_fmt, + self.collector_tag, + self.collector_length, + self.collector_max_delay) + self.trm_buf = pack(self.trm_fmt, + self.terminator_tag, + self.terminator_length) + + self.buf = self.head_buf + self.act_buf + self.prt_buf + \ + self.col_buf + self.trm_buf + + def tearDown(self): + pass + + def test_parser(self): + slow.parser(self.buf) + + def test_not_implemented_subtype(self): + not_implemented_buf = str(SLOW_SUBTYPE_MARKER) + self.buf[1:] + (instance, nexttype, last) = slow.parser(not_implemented_buf) + assert None == instance + assert None == nexttype + assert None != last + + def test_invalid_subtype(self): + invalid_buf = "\xff" + self.buf[1:] + (instance, nexttype, last) = slow.parser(invalid_buf) + assert None == instance + assert None == nexttype + assert None != last + + +class Test_lacp(unittest.TestCase): + """ Test case for lacp + """ + + def setUp(self): + self.subtype = SLOW_SUBTYPE_LACP + self.version = lacp.LACP_VERSION_NUMBER + self.actor_tag = lacp.LACP_TLV_TYPE_ACTOR + self.actor_length = 20 + self.actor_system_priority = 65534 + self.actor_system = mac.haddr_to_bin('00:07:0d:af:f4:54') + self.actor_key = 1 + self.actor_port_priority = 65535 + self.actor_port = 1 + self.actor_state_activity = lacp.LACP_STATE_ACTIVE + self.actor_state_timeout = lacp.LACP_STATE_LONG_TIMEOUT + self.actor_state_aggregation = lacp.LACP_STATE_AGGREGATEABLE + self.actor_state_synchronization = lacp.LACP_STATE_IN_SYNC + self.actor_state_collecting = lacp.LACP_STATE_COLLECTING_ENABLED + self.actor_state_distributing = lacp.LACP_STATE_DISTRIBUTING_ENABLED + self.actor_state_defaulted = lacp.LACP_STATE_OPERATIONAL_PARTNER + self.actor_state_expired = lacp.LACP_STATE_EXPIRED + self.actor_state = ( + (self.actor_state_activity << 0) | + (self.actor_state_timeout << 1) | + (self.actor_state_aggregation << 2) | + (self.actor_state_synchronization << 3) | + (self.actor_state_collecting << 4) | + (self.actor_state_distributing << 5) | + (self.actor_state_defaulted << 6) | + (self.actor_state_expired << 7)) + self.partner_tag = lacp.LACP_TLV_TYPE_PARTNER + self.partner_length = 20 + self.partner_system_priority = 0 + self.partner_system = mac.haddr_to_bin('00:00:00:00:00:00') + self.partner_key = 0 + self.partner_port_priority = 0 + self.partner_port = 0 + self.partner_state_activity = 0 + self.partner_state_timeout = lacp.LACP_STATE_SHORT_TIMEOUT + self.partner_state_aggregation = 0 + self.partner_state_synchronization = 0 + self.partner_state_collecting = 0 + self.partner_state_distributing = 0 + self.partner_state_defaulted = 0 + self.partner_state_expired = 0 + self.partner_state = ( + (self.partner_state_activity << 0) | + (self.partner_state_timeout << 1) | + (self.partner_state_aggregation << 2) | + (self.partner_state_synchronization << 3) | + (self.partner_state_collecting << 4) | + (self.partner_state_distributing << 5) | + (self.partner_state_defaulted << 6) | + (self.partner_state_expired << 7)) + self.collector_tag = lacp.LACP_TLV_TYPE_COLLECTOR + self.collector_length = 16 + self.collector_max_delay = 0 + self.terminator_tag = lacp.LACP_TLV_TYPE_TERMINATOR + self.terminator_length = 0 + + self.head_fmt = lacp._HLEN_PACK_STR + self.head_len = lacp._HLEN_PACK_LEN + self.act_fmt = lacp._ACTPRT_INFO_PACK_STR + self.act_len = lacp._ACTPRT_INFO_PACK_LEN + self.prt_fmt = lacp._ACTPRT_INFO_PACK_STR + self.prt_len = lacp._ACTPRT_INFO_PACK_LEN + self.col_fmt = lacp._COL_INFO_PACK_STR + self.col_len = lacp._COL_INFO_PACK_LEN + self.trm_fmt = lacp._TRM_PACK_STR + self.trm_len = lacp._TRM_PACK_LEN + self.length = lacp._ALL_PACK_LEN + + self.head_buf = pack(self.head_fmt, + self.subtype, + self.version) + self.act_buf = pack(self.act_fmt, + self.actor_tag, + self.actor_length, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state) + self.prt_buf = pack(self.prt_fmt, + self.partner_tag, + self.partner_length, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state) + self.col_buf = pack(self.col_fmt, + self.collector_tag, + self.collector_length, + self.collector_max_delay) + self.trm_buf = pack(self.trm_fmt, + self.terminator_tag, + self.terminator_length) + + self.buf = self.head_buf + self.act_buf + self.prt_buf + \ + self.col_buf + self.trm_buf + + self.l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + + def tearDown(self): + pass + + def find_protocol(self, pkt, name): + for p in pkt.protocols: + if p.protocol_name == name: + return p + + def test_init(self): + eq_(self.subtype, self.l.subtype) + eq_(self.version, self.l.version) + eq_(self.actor_tag, self.l.actor_tag) + eq_(self.actor_length, self.l.actor_length) + eq_(self.actor_system_priority, self.l.actor_system_priority) + eq_(self.actor_system, self.l.actor_system) + eq_(self.actor_key, self.l.actor_key) + eq_(self.actor_port_priority, self.l.actor_port_priority) + eq_(self.actor_port, self.l.actor_port) + eq_(self.actor_state_activity, self.l.actor_state_activity) + eq_(self.actor_state_timeout, self.l.actor_state_timeout) + eq_(self.actor_state_aggregation, + self.l.actor_state_aggregation) + eq_(self.actor_state_synchronization, + self.l.actor_state_synchronization) + eq_(self.actor_state_collecting, + self.l.actor_state_collecting) + eq_(self.actor_state_distributing, + self.l.actor_state_distributing) + eq_(self.actor_state_defaulted, self.l.actor_state_defaulted) + eq_(self.actor_state_expired, self.l.actor_state_expired) + eq_(self.actor_state, self.l.actor_state) + eq_(self.partner_tag, self.l.partner_tag) + eq_(self.partner_length, self.l.partner_length) + eq_(self.partner_system_priority, + self.l.partner_system_priority) + eq_(self.partner_system, self.l.partner_system) + eq_(self.partner_key, self.l.partner_key) + eq_(self.partner_port_priority, self.l.partner_port_priority) + eq_(self.partner_port, self.l.partner_port) + eq_(self.partner_state_activity, self.l.partner_state_activity) + eq_(self.partner_state_timeout, self.l.partner_state_timeout) + eq_(self.partner_state_aggregation, + self.l.partner_state_aggregation) + eq_(self.partner_state_synchronization, + self.l.partner_state_synchronization) + eq_(self.partner_state_collecting, + self.l.partner_state_collecting) + eq_(self.partner_state_distributing, + self.l.partner_state_distributing) + eq_(self.partner_state_defaulted, + self.l.partner_state_defaulted) + eq_(self.partner_state_expired, self.l.partner_state_expired) + eq_(self.partner_state, self.l.partner_state) + eq_(self.collector_tag, self.l.collector_tag) + eq_(self.collector_length, self.l.collector_length) + eq_(self.collector_max_delay, self.l.collector_max_delay) + eq_(self.terminator_tag, self.l.terminator_tag) + eq_(self.terminator_length, self.l.terminator_length) + + def test_parser(self): + _res = self.l.parser(self.buf) + if type(_res) is tuple: + res = _res[0] + else: + res = _res + + eq_(res.subtype, self.subtype) + eq_(res.version, self.version) + eq_(res.actor_tag, self.actor_tag) + eq_(res.actor_length, self.actor_length) + eq_(res.actor_system_priority, self.actor_system_priority) + eq_(res.actor_system, self.actor_system) + eq_(res.actor_key, self.actor_key) + eq_(res.actor_port_priority, self.actor_port_priority) + eq_(res.actor_port, self.actor_port) + eq_(res.actor_state_activity, self.actor_state_activity) + eq_(res.actor_state_timeout, self.actor_state_timeout) + eq_(res.actor_state_aggregation, self.actor_state_aggregation) + eq_(res.actor_state_synchronization, + self.actor_state_synchronization) + eq_(res.actor_state_collecting, self.actor_state_collecting) + eq_(res.actor_state_distributing, self.actor_state_distributing) + eq_(res.actor_state_defaulted, self.actor_state_defaulted) + eq_(res.actor_state_expired, self.actor_state_expired) + eq_(res.actor_state, self.actor_state) + eq_(res.partner_tag, self.partner_tag) + eq_(res.partner_length, self.partner_length) + eq_(res.partner_system_priority, self.partner_system_priority) + eq_(res.partner_system, self.partner_system) + eq_(res.partner_key, self.partner_key) + eq_(res.partner_port_priority, self.partner_port_priority) + eq_(res.partner_port, self.partner_port) + eq_(res.partner_state_activity, self.partner_state_activity) + eq_(res.partner_state_timeout, self.partner_state_timeout) + eq_(res.partner_state_aggregation, + self.partner_state_aggregation) + eq_(res.partner_state_synchronization, + self.partner_state_synchronization) + eq_(res.partner_state_collecting, self.partner_state_collecting) + eq_(res.partner_state_distributing, + self.partner_state_distributing) + eq_(res.partner_state_defaulted, self.partner_state_defaulted) + eq_(res.partner_state_expired, self.partner_state_expired) + eq_(res.partner_state, self.partner_state) + eq_(res.collector_tag, self.collector_tag) + eq_(res.collector_length, self.collector_length) + eq_(res.collector_max_delay, self.collector_max_delay) + eq_(res.terminator_tag, self.terminator_tag) + eq_(res.terminator_length, self.terminator_length) + + def test_serialize(self): + data = bytearray() + prev = None + buf = self.l.serialize(data, prev) + + offset = 0 + head_res = unpack_from(self.head_fmt, buf, offset) + offset += self.head_len + act_res = unpack_from(self.act_fmt, buf, offset) + offset += self.act_len + prt_res = unpack_from(self.prt_fmt, buf, offset) + offset += self.prt_len + col_res = unpack_from(self.col_fmt, buf, offset) + offset += self.col_len + trm_res = unpack_from(self.trm_fmt, buf, offset) + + eq_(head_res[0], self.subtype) + eq_(head_res[1], self.version) + + eq_(act_res[0], self.actor_tag) + eq_(act_res[1], self.actor_length) + eq_(act_res[2], self.actor_system_priority) + eq_(act_res[3], self.actor_system) + eq_(act_res[4], self.actor_key) + eq_(act_res[5], self.actor_port_priority) + eq_(act_res[6], self.actor_port) + eq_(act_res[7], self.actor_state) + + eq_(prt_res[0], self.partner_tag) + eq_(prt_res[1], self.partner_length) + eq_(prt_res[2], self.partner_system_priority) + eq_(prt_res[3], self.partner_system) + eq_(prt_res[4], self.partner_key) + eq_(prt_res[5], self.partner_port_priority) + eq_(prt_res[6], self.partner_port) + eq_(prt_res[7], self.partner_state) + + eq_(col_res[0], self.collector_tag) + eq_(col_res[1], self.collector_length) + eq_(col_res[2], self.collector_max_delay) + + eq_(trm_res[0], self.terminator_tag) + eq_(trm_res[1], self.terminator_length) + + def _build_lacp(self): + ethertype = ether.ETH_TYPE_SLOW + dst = SLOW_PROTOCOL_MULTICAST + e = ethernet(dst, self.actor_system, ethertype) + p = Packet() + + p.add_protocol(e) + p.add_protocol(self.l) + p.serialize() + return p + + def test_build_lacp(self): + p = self._build_lacp() + + e = self.find_protocol(p, "ethernet") + ok_(e) + eq_(e.ethertype, ether.ETH_TYPE_SLOW) + + l = self.find_protocol(p, "lacp") + ok_(l) + + eq_(l.subtype, self.subtype) + eq_(l.version, self.version) + eq_(l.actor_tag, self.actor_tag) + eq_(l.actor_length, self.actor_length) + eq_(l.actor_system_priority, self.actor_system_priority) + eq_(l.actor_system, self.actor_system) + eq_(l.actor_key, self.actor_key) + eq_(l.actor_port_priority, self.actor_port_priority) + eq_(l.actor_port, self.actor_port) + eq_(l.actor_state_activity, self.actor_state_activity) + eq_(l.actor_state_timeout, self.actor_state_timeout) + eq_(l.actor_state_aggregation, self.actor_state_aggregation) + eq_(l.actor_state_synchronization, + self.actor_state_synchronization) + eq_(l.actor_state_collecting, self.actor_state_collecting) + eq_(l.actor_state_distributing, self.actor_state_distributing) + eq_(l.actor_state_defaulted, self.actor_state_defaulted) + eq_(l.actor_state_expired, self.actor_state_expired) + eq_(l.actor_state, self.actor_state) + eq_(l.partner_tag, self.partner_tag) + eq_(l.partner_length, self.partner_length) + eq_(l.partner_system_priority, self.partner_system_priority) + eq_(l.partner_system, self.partner_system) + eq_(l.partner_key, self.partner_key) + eq_(l.partner_port_priority, self.partner_port_priority) + eq_(l.partner_port, self.partner_port) + eq_(l.partner_state_activity, self.partner_state_activity) + eq_(l.partner_state_timeout, self.partner_state_timeout) + eq_(l.partner_state_aggregation, self.partner_state_aggregation) + eq_(l.partner_state_synchronization, + self.partner_state_synchronization) + eq_(l.partner_state_collecting, self.partner_state_collecting) + eq_(l.partner_state_distributing, + self.partner_state_distributing) + eq_(l.partner_state_defaulted, self.partner_state_defaulted) + eq_(l.partner_state_expired, self.partner_state_expired) + eq_(l.collector_tag, self.collector_tag) + eq_(l.collector_length, self.collector_length) + eq_(l.collector_max_delay, self.collector_max_delay) + eq_(l.terminator_tag, self.terminator_tag) + eq_(l.terminator_length, self.terminator_length) + + @raises(Exception) + def test_malformed_lacp(self): + m_short_buf = self.buf[1:self.length] + slow.parser(m_short_buf) + + @raises(Exception) + def test_invalid_subtype(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.subtype = 0xff + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_version(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.version = 0xff + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_actor_tag(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.actor_tag = 0x04 + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_actor_length(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.actor_length = 50 + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_partner_tag(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.partner_tag = 0x01 + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_partner_length(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.partner_length = 0 + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_collector_tag(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.collector_tag = 0x00 + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_collector_length(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.collector_length = 20 + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_terminator_tag(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.terminator_tag = 0x04 + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_terminator_length(self): + invalid_lacv = copy.deepcopy(self.l) + invalid_lacv.terminator_length = self.trm_len + invalid_buf = invalid_lacv.serialize() + slow.parser(invalid_buf) + + @raises(Exception) + def test_invalid_actor_state_activity(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + 2, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_actor_state_timeout(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + 2, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_actor_state_aggregation(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + 2, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_actor_state_synchronization(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + 2, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_actor_state_collecting(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + 2, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_actor_state_distributing(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + 2, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_actor_state_defaulted(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + 2, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_actor_state_expired(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + 2, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_partner_state_activity(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + -1, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_partner_state_timeout(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + -1, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_partner_state_aggregation(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + -1, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_partner_state_synchronization(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + -1, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_partner_state_collecting(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + -1, + self.partner_state_distributing, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_partner_state_distributing(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + -1, + self.partner_state_defaulted, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_partner_state_defaulted(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + -1, + self.partner_state_expired, + self.collector_max_delay) + l.serialize() + + @raises(Exception) + def test_invalid_partner_state_expired(self): + l = lacp(self.version, + self.actor_system_priority, + self.actor_system, + self.actor_key, + self.actor_port_priority, + self.actor_port, + self.actor_state_activity, + self.actor_state_timeout, + self.actor_state_aggregation, + self.actor_state_synchronization, + self.actor_state_collecting, + self.actor_state_distributing, + self.actor_state_defaulted, + self.actor_state_expired, + self.partner_system_priority, + self.partner_system, + self.partner_key, + self.partner_port_priority, + self.partner_port, + self.partner_state_activity, + self.partner_state_timeout, + self.partner_state_aggregation, + self.partner_state_synchronization, + self.partner_state_collecting, + self.partner_state_distributing, + self.partner_state_defaulted, + -1, + self.collector_max_delay) + l.serialize()