Exemple #1
0
 def send_packet_in(self, data, in_port):
     match = ofp.match()
     match.oxm_list.append(ofp.oxm.in_port(in_port))
     msg = ofp.message.packet_in(reason=ofp.OFPR_ACTION,
                                 match=match,
                                 data=data)
     self.cxn.send(msg)
Exemple #2
0
 def test_packet_in(self):
     obj = ofp.message.packet_in(
         xid=0x12345678,
         buffer_id=100,
         total_len=17000,
         reason=ofp.OFPR_ACTION,
         table_id=20,
         cookie=0xFEDCBA9876543210,
         match=ofp.match(oxm_list=[
             ofp.oxm.arp_op(value=1),
             ofp.oxm.in_port_masked(value=4, value_mask=5)]),
         data="abc")
     buf = ''.join([
         '\x04', '\x0a', # version, type
         '\x00\x35', # length
         '\x12\x34\x56\x78', # xid
         '\x00\x00\x00\x64', # buffer_id
         '\x42\x68', # total_len
         '\x01', # reason
         '\x14', # table_id
         '\xfe\xdc\xba\x98\x76\x54\x32\x10', # cookie
         '\x00\x01', # match.type
         '\x00\x16', # match.length
         '\x80\x00\x2A\x02', # match.oxm_list[0].type_len
         '\x00\x01', # match.oxm_list[0].value
         '\x80\x00\x01\x08', # match.oxm_list[1].type_len
         '\x00\x00\x00\x04', # match.oxm_list[1].value
         '\x00\x00\x00\x05', # match.oxm_list[1].mask
         '\x00\x00', # match.pad
         '\x00\x00', # pad
         'abc', # data
     ])
     test_serialization(obj, buf)
Exemple #3
0
    def test_flow_add(self):
        obj = ofp.message.flow_add(
            xid=0x12345678,
            cookie=0xFEDCBA9876543210,
            cookie_mask=0xFF00FF00FF00FF00,
            table_id=3,
            idle_timeout=5,
            hard_timeout=10,
            priority=6000,
            buffer_id=50,
            out_port=6,
            out_group=8,
            flags=0,
            match=ofp.match(oxm_list=[]),
            instructions=[
                ofp.instruction.goto_table(table_id=4),
                ofp.instruction.goto_table(table_id=7)])
        buf = ''.join([
            '\x04', '\x0e', # version, type
            '\x00\x48', # length
            '\x12\x34\x56\x78', # xid

            '\xfe\xdc\xba\x98\x76\x54\x32\x10', # cookie

            '\xff\x00\xff\x00\xff\x00\xff\x00', # cookie_mask

            '\x03', # table_id
            '\x00', # _command
            '\x00\x05', # idle_timeout
            '\x00\x0a', # hard_timeout
            '\x17\x70', # priority

            '\x00\x00\x00\x32', # buffer_id
            '\x00\x00\x00\x06', # out_port

            '\x00\x00\x00\x08', # out_group
            '\x00\x00', # flags
            '\x00' * 2, # pad

            '\x00\x01', # match.type
            '\x00\x04', # match.length
            '\x00' * 4, # pad

            '\x00\x01', # instructions[0].type
            '\x00\x08', # instructions[0].length
            '\x04', # instructions[0].table_id
            '\x00' * 3, # pad

            '\x00\x01', # instructions[1].type
            '\x00\x08', # instructions[1].length
            '\x07', # instructions[1].table_id
            '\x00' * 3, # pad
        ])
        test_serialization(obj, buf)
Exemple #4
0
 def test_flow_removed(self):
     obj = ofp.message.flow_removed(
         xid=0x12345678,
         cookie=0xFEDCBA9876543210,
         priority=17000,
         reason=ofp.OFPRR_DELETE,
         table_id=20,
         duration_sec=10,
         duration_nsec=1000,
         idle_timeout=5,
         hard_timeout=30,
         packet_count=1,
         byte_count=2,
         match=ofp.match(oxm_list=[
             ofp.oxm.arp_op(value=1),
             ofp.oxm.in_port_masked(value=4, value_mask=5)]))
     buf = ''.join([
         '\x04', '\x0b', # version, type
         '\x00\x48', # length
         '\x12\x34\x56\x78', # xid
         '\xfe\xdc\xba\x98\x76\x54\x32\x10', # cookie
         '\x42\x68', # priority
         '\x02', # reason
         '\x14', # table_id
         '\x00\x00\x00\x0a', # duration_sec
         '\x00\x00\x03\xe8', # duration_nsec
         '\x00\x05', # idle_timeout
         '\x00\x1e', # hard_timeout
         '\x00\x00\x00\x00\x00\x00\x00\x01', # packet_count
         '\x00\x00\x00\x00\x00\x00\x00\x02', # byte_count
         '\x00\x01', # match.type
         '\x00\x16', # match.length
         '\x80\x00\x2A\x02', # match.oxm_list[0].type_len
         '\x00\x01', # match.oxm_list[0].value
         '\x80\x00\x01\x08', # match.oxm_list[1].type_len
         '\x00\x00\x00\x04', # match.oxm_list[1].value
         '\x00\x00\x00\x05', # match.oxm_list[1].mask
         '\x00\x00', # match.pad
     ])
     test_serialization(obj, buf)