This repository was archived by the owner on Apr 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
tests/v0x01/test_symmetric Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55# Third-party imports
66
77from pyof .foundation .base import GenericMessage
8- from pyof .foundation .basic_types import UBInt32
8+ from pyof .foundation .basic_types import BinaryData , UBInt32
99from pyof .v0x01 .common .header import Header , Type
1010
1111__all__ = ('VendorHeader' ,)
@@ -21,15 +21,18 @@ class VendorHeader(GenericMessage):
2121
2222 header = Header (message_type = Type .OFPT_VENDOR )
2323 vendor = UBInt32 ()
24+ data = BinaryData ()
2425
25- def __init__ (self , xid = None , vendor = None ):
26+ def __init__ (self , xid = None , vendor = None , data = None ):
2627 """Create a VendorHeader with the options parameters below.
2728
2829 Args:
2930 xid (int): xid to be used on the message header.
3031 vendor (int): Vendor ID:
3132 MSB 0: low-order bytes are IEEE OUI.
3233 MSB != 0: defined by OpenFlow consortium.
34+ data (BinaryData): Vendor-defined arbitrary additional data.
3335 """
3436 super ().__init__ (xid )
3537 self .vendor = vendor
38+ self .data = data
Original file line number Diff line number Diff line change 66class TestVendorHeader (TestStruct ):
77 """Vendor message tests (also those in :class:`.TestDump`)."""
88
9- @ classmethod
10- def setUpClass ( cls ):
11- """Configure raw file and its object in parent class (TestDump)."""
12- super (). setUpClass ()
13- super (). set_raw_dump_file ( 'v0x01' , 'ofpt_vendor_header' )
14- super (). set_raw_dump_object ( VendorHeader , xid = 4 , vendor = 128 )
15- super (). set_minimum_size ( 12 )
9+ def test_unpack ( self ):
10+ """Test unpack VendorHeader message."""
11+ message = b'My custom vendor extra data.'
12+ vendor_header = VendorHeader ( xid = 4 , vendor = 128 ,
13+ data = message )
14+ data = b' \x01 \x04 \x00 ( \x00 \x00 \x00 \x04 \x00 \x00 \x00 \x80 ' + message
15+ self . _test_unpack ( vendor_header , bytes2unpack = data )
You can’t perform that action at this time.
0 commit comments