Ejemplo n.º 1
0
    def test_port_status_pack(self):
        desc = ofp.port_desc(port_no=ofp.OFPP_CONTROLLER,
                             hw_addr=[1, 2, 3, 4, 5, 6],
                             name="foo",
                             config=ofp.OFPPC_NO_FLOOD,
                             state=ofp.OFPPS_STP_FORWARD,
                             curr=ofp.OFPPF_10MB_HD,
                             advertised=ofp.OFPPF_1GB_FD,
                             supported=ofp.OFPPF_AUTONEG,
                             peer=ofp.OFPPF_PAUSE_ASYM)

        msg = ofp.message.port_status(xid=4,
                                      reason=ofp.OFPPR_DELETE,
                                      desc=desc)
        expected = ''.join([
            '\x01',
            '\x0c',  # version/type
            '\x00\x40',  # length
            '\x00\x00\x00\x04',  # xid
            '\x01',  # reason
            '\x00\x00\x00\x00\x00\x00\x00'  # pad
            '\xff\xfd',  # desc.port_no
            '\x01\x02\x03\x04\x05\x06',  # desc.hw_addr
            'foo'.ljust(16, '\x00'),  # desc.name
            '\x00\x00\x00\x10',  # desc.config
            '\x00\x00\x02\x00',  # desc.state
            '\x00\x00\x00\x01',  # desc.curr
            '\x00\x00\x00\x20',  # desc.advertised
            '\x00\x00\x02\x00',  # desc.supported
            '\x00\x00\x08\x00',  # desc.peer
        ])
        self.assertEquals(expected, msg.pack())
Ejemplo n.º 2
0
    def test_port_status_pack(self):
        import loxi.of10 as ofp

        desc = ofp.port_desc(port_no=ofp.OFPP_CONTROLLER,
                             hw_addr=[1,2,3,4,5,6],
                             name="foo",
                             config=ofp.OFPPC_NO_FLOOD,
                             state=ofp.OFPPS_STP_FORWARD,
                             curr=ofp.OFPPF_10MB_HD,
                             advertised=ofp.OFPPF_1GB_FD,
                             supported=ofp.OFPPF_AUTONEG,
                             peer=ofp.OFPPF_PAUSE_ASYM)

        msg = ofp.message.port_status(xid=4,
                                      reason=ofp.OFPPR_DELETE,
                                      desc=desc)
        expected = ''.join([
            '\x01', '\x0c', # version/type
            '\x00\x40', # length
            '\x00\x00\x00\x04', # xid
            '\x01', # reason
            '\x00\x00\x00\x00\x00\x00\x00' # pad
            '\xff\xfd', # desc.port_no
            '\x01\x02\x03\x04\x05\x06', # desc.hw_addr
            'foo'.ljust(16, '\x00'), # desc.name
            '\x00\x00\x00\x10', # desc.config
            '\x00\x00\x02\x00', # desc.state
            '\x00\x00\x00\x01', # desc.curr
            '\x00\x00\x00\x20', # desc.advertised
            '\x00\x00\x02\x00', # desc.supported
            '\x00\x00\x08\x00', # desc.peer
        ])
        self.assertEquals(expected, msg.pack())
Ejemplo n.º 3
0
 def test_port_desc_pack(self):
     obj = ofp.port_desc(port_no=ofp.OFPP_CONTROLLER,
                         hw_addr=[1, 2, 3, 4, 5, 6],
                         name="foo",
                         config=ofp.OFPPC_NO_FLOOD,
                         state=ofp.OFPPS_STP_FORWARD,
                         curr=ofp.OFPPF_10MB_HD,
                         advertised=ofp.OFPPF_1GB_FD,
                         supported=ofp.OFPPF_AUTONEG,
                         peer=ofp.OFPPF_PAUSE_ASYM)
     expected = ''.join([
         '\xff\xfd',  # port_no
         '\x01\x02\x03\x04\x05\x06',  # hw_addr
         'foo'.ljust(16, '\x00'),  # name
         '\x00\x00\x00\x10',  # config
         '\x00\x00\x02\x00',  # state
         '\x00\x00\x00\x01',  # curr
         '\x00\x00\x00\x20',  # advertised
         '\x00\x00\x02\x00',  # supported
         '\x00\x00\x08\x00',  # peer
     ])
     self.assertEquals(expected, obj.pack())
Ejemplo n.º 4
0
 def test_port_desc_pack(self):
     obj = ofp.port_desc(port_no=ofp.OFPP_CONTROLLER,
                         hw_addr=[1,2,3,4,5,6],
                         name="foo",
                         config=ofp.OFPPC_NO_FLOOD,
                         state=ofp.OFPPS_STP_FORWARD,
                         curr=ofp.OFPPF_10MB_HD,
                         advertised=ofp.OFPPF_1GB_FD,
                         supported=ofp.OFPPF_AUTONEG,
                         peer=ofp.OFPPF_PAUSE_ASYM)
     expected = ''.join([
         '\xff\xfd', # port_no
         '\x01\x02\x03\x04\x05\x06', # hw_addr
         'foo'.ljust(16, '\x00'), # name
         '\x00\x00\x00\x10', # config
         '\x00\x00\x02\x00', # state
         '\x00\x00\x00\x01', # curr
         '\x00\x00\x00\x20', # advertised
         '\x00\x00\x02\x00', # supported
         '\x00\x00\x08\x00', # peer
     ])
     self.assertEquals(expected, obj.pack())