コード例 #1
0
ファイル: tests.py プロジェクト: rlane/loxigen
 def test_flow_stats_reply_pack(self):
     import loxi.of10 as ofp
     msg = ofp.message.flow_stats_reply(xid=6, flags=0, entries=[
         ofp.flow_stats_entry(table_id=3,
                              match=ofp.match(),
                              duration_sec=1,
                              duration_nsec=2,
                              priority=100,
                              idle_timeout=5,
                              hard_timeout=10,
                              cookie=0x0123456789abcdef,
                              packet_count=10,
                              byte_count=1000,
                              actions=[ofp.action.output(port=1),
                                       ofp.action.output(port=2)]),
         ofp.flow_stats_entry(table_id=4,
                              match=ofp.match(),
                              duration_sec=1,
                              duration_nsec=2,
                              priority=100,
                              idle_timeout=5,
                              hard_timeout=10,
                              cookie=0x0123456789abcdef,
                              packet_count=10,
                              byte_count=1000,
                              actions=[ofp.action.output(port=1),
                                       ofp.action.output(port=2),
                                       ofp.action.output(port=3)])])
     self.assertEquals(self.sample_flow_stats_reply_buf, msg.pack())
コード例 #2
0
ファイル: of10.py プロジェクト: raghdaaljaff/loxigen
 def test_match(self):
     match = ofp.match()
     self.assertEquals(match.wildcards, ofp.OFPFW_ALL)
     self.assertEquals(match.tcp_src, 0)
     buf = match.pack()
     match2 = ofp.match.unpack(buf)
     self.assertEquals(match, match2)
コード例 #3
0
ファイル: of10.py プロジェクト: harshsin/loxigen
 def test_match(self):
     match = ofp.match()
     self.assertEquals(match.wildcards, ofp.OFPFW_ALL)
     self.assertEquals(match.tcp_src, 0)
     buf = match.pack()
     match2 = ofp.match.unpack(OFReader(buf))
     self.assertEquals(match, match2)
コード例 #4
0
ファイル: tests.py プロジェクト: rlane/loxigen
 def test_match(self):
     import loxi.of10 as ofp
     match = ofp.match()
     self.assertEquals(match.wildcards, ofp.OFPFW_ALL)
     self.assertEquals(match.tcp_src, 0)
     buf = match.pack()
     match2 = ofp.match.unpack(buf)
     self.assertEquals(match, match2)
コード例 #5
0
ファイル: of10.py プロジェクト: raghdaaljaff/loxigen
 def test_flow_stats_reply_pack(self):
     msg = ofp.message.flow_stats_reply(
         xid=6,
         flags=0,
         entries=[
             ofp.flow_stats_entry(table_id=3,
                                  match=ofp.match(),
                                  duration_sec=1,
                                  duration_nsec=2,
                                  priority=100,
                                  idle_timeout=5,
                                  hard_timeout=10,
                                  cookie=0x0123456789abcdef,
                                  packet_count=10,
                                  byte_count=1000,
                                  actions=[
                                      ofp.action.output(port=1),
                                      ofp.action.output(port=2)
                                  ]),
             ofp.flow_stats_entry(table_id=4,
                                  match=ofp.match(),
                                  duration_sec=1,
                                  duration_nsec=2,
                                  priority=100,
                                  idle_timeout=5,
                                  hard_timeout=10,
                                  cookie=0x0123456789abcdef,
                                  packet_count=10,
                                  byte_count=1000,
                                  actions=[
                                      ofp.action.output(port=1),
                                      ofp.action.output(port=2),
                                      ofp.action.output(port=3)
                                  ])
         ])
     self.assertEquals(self.sample_flow_stats_reply_buf, msg.pack())
コード例 #6
0
ファイル: of10.py プロジェクト: kenchiang/loxigen
 def test_flow_add(self):
     match = ofp.match()
     msg = ofp.message.flow_add(xid=1,
                                match=match,
                                cookie=1,
                                idle_timeout=5,
                                flags=ofp.OFPFF_CHECK_OVERLAP,
                                actions=[
                                    ofp.action.output(port=1),
                                    ofp.action.output(port=2),
                                    ofp.action.output(port=ofp.OFPP_CONTROLLER,
                                                      max_len=1024)])
     buf = msg.pack()
     msg2 = ofp.message.flow_add.unpack(buf)
     self.assertEquals(msg, msg2)
コード例 #7
0
ファイル: tests.py プロジェクト: rlane/loxigen
    def test_flow_add_show(self):
        import loxi.of10 as ofp
        expected = """\
flow_add {
  xid = None,
  match = match_v1 {
    wildcards = OFPFW_DL_SRC|OFPFW_DL_DST,
    in_port = 3,
    eth_src = 01:23:45:67:89:ab,
    eth_dst = cd:ef:01:23:45:67,
    vlan_vid = 0x0,
    vlan_pcp = 0x0,
    pad1 = 0x0,
    eth_type = 0x0,
    ip_dscp = 0x0,
    ip_proto = 0x0,
    pad2 = [ 0, 0 ],
    ipv4_src = 192.168.3.127,
    ipv4_dst = 255.255.255.255,
    tcp_src = 0x0,
    tcp_dst = 0x0
  },
  cookie = 0x0,
  idle_timeout = 0x0,
  hard_timeout = 0x0,
  priority = 0x0,
  buffer_id = 0x0,
  out_port = 0,
  flags = 0x0,
  actions = [
    output { port = OFPP_FLOOD, max_len = 0x0 },
    nicira_dec_ttl { pad = 0x0, pad2 = 0x0 },
    bsn_set_tunnel_dst { dst = 0x0 }
  ]
}"""
        msg = ofp.message.flow_add(
            match=ofp.match(
                wildcards=ofp.OFPFW_DL_SRC|ofp.OFPFW_DL_DST,
                in_port=3,
                ipv4_src=0xc0a8037f,
                ipv4_dst=0xffffffff,
                eth_src=[0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
                eth_dst=[0xcd, 0xef, 0x01, 0x23, 0x45, 0x67]),
            actions=[
                ofp.action.output(port=ofp.OFPP_FLOOD),
                ofp.action.nicira_dec_ttl(),
                ofp.action.bsn_set_tunnel_dst()])
        self.assertEquals(msg.show(), expected)
コード例 #8
0
ファイル: of10.py プロジェクト: raghdaaljaff/loxigen
    def test_flow_add_show(self):
        expected = """\
flow_add {
  xid = None,
  match = match_v1 {
    wildcards = OFPFW_DL_SRC|OFPFW_DL_DST,
    in_port = 3,
    eth_src = 01:23:45:67:89:ab,
    eth_dst = cd:ef:01:23:45:67,
    vlan_vid = 0x0,
    vlan_pcp = 0x0,
    pad = 0x0,
    eth_type = 0x0,
    ip_dscp = 0x0,
    ip_proto = 0x0,
    pad1 = [ 0, 0 ],
    ipv4_src = 192.168.3.127,
    ipv4_dst = 255.255.255.255,
    tcp_src = 0x0,
    tcp_dst = 0x0
  },
  cookie = 0x0,
  idle_timeout = 0x0,
  hard_timeout = 0x0,
  priority = 0x0,
  buffer_id = 0x0,
  out_port = 0,
  flags = 0x0,
  actions = [
    output { port = OFPP_FLOOD, max_len = 0x0 },
    nicira_dec_ttl { pad = 0x0, pad1 = 0x0 },
    bsn_set_tunnel_dst { dst = 0x0 }
  ]
}"""
        msg = ofp.message.flow_add(match=ofp.match(
            wildcards=ofp.OFPFW_DL_SRC | ofp.OFPFW_DL_DST,
            in_port=3,
            ipv4_src=0xc0a8037f,
            ipv4_dst=0xffffffff,
            eth_src=[0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
            eth_dst=[0xcd, 0xef, 0x01, 0x23, 0x45, 0x67]),
                                   actions=[
                                       ofp.action.output(port=ofp.OFPP_FLOOD),
                                       ofp.action.nicira_dec_ttl(),
                                       ofp.action.bsn_set_tunnel_dst()
                                   ])
        self.assertEquals(msg.show(), expected)
コード例 #9
0
ファイル: of10.py プロジェクト: raghdaaljaff/loxigen
 def test_flow_add(self):
     match = ofp.match()
     msg = ofp.message.flow_add(xid=1,
                                match=match,
                                cookie=1,
                                idle_timeout=5,
                                flags=ofp.OFPFF_CHECK_OVERLAP,
                                actions=[
                                    ofp.action.output(port=1),
                                    ofp.action.output(port=2),
                                    ofp.action.output(
                                        port=ofp.OFPP_CONTROLLER,
                                        max_len=1024)
                                ])
     buf = msg.pack()
     msg2 = ofp.message.flow_add.unpack(buf)
     self.assertEquals(msg, msg2)
コード例 #10
0
ファイル: of10.py プロジェクト: raghdaaljaff/loxigen
 def test_flow_stats_entry_pack(self):
     obj = ofp.flow_stats_entry(
         table_id=3,
         match=ofp.match(),
         duration_sec=1,
         duration_nsec=2,
         priority=100,
         idle_timeout=5,
         hard_timeout=10,
         cookie=0x0123456789abcdef,
         packet_count=10,
         byte_count=1000,
         actions=[ofp.action.output(port=1),
                  ofp.action.output(port=2)])
     expected = ''.join([
         '\x00\x68',  # length
         '\x03',  # table_id
         '\x00',  # pad
         '\x00\x3f\xff\xff',  # match.wildcards
         '\x00' * 36,  # remaining match fields
         '\x00\x00\x00\x01',  # duration_sec
         '\x00\x00\x00\x02',  # duration_nsec
         '\x00\x64',  # priority
         '\x00\x05',  # idle_timeout
         '\x00\x0a',  # hard_timeout
         '\x00' * 6,  # pad2
         '\x01\x23\x45\x67\x89\xab\xcd\xef',  # cookie
         '\x00\x00\x00\x00\x00\x00\x00\x0a',  # packet_count
         '\x00\x00\x00\x00\x00\x00\x03\xe8',  # byte_count
         '\x00\x00',  # actions[0].type
         '\x00\x08',  # actions[0].len
         '\x00\x01',  # actions[0].port
         '\x00\x00',  # actions[0].max_len
         '\x00\x00',  # actions[1].type
         '\x00\x08',  # actions[1].len
         '\x00\x02',  # actions[1].port
         '\x00\x00',  # actions[1].max_len
     ])
     self.assertEquals(expected, obj.pack())
コード例 #11
0
ファイル: tests.py プロジェクト: rlane/loxigen
 def test_flow_stats_entry_pack(self):
     import loxi.of10 as ofp
     obj = ofp.flow_stats_entry(table_id=3,
                                match=ofp.match(),
                                duration_sec=1,
                                duration_nsec=2,
                                priority=100,
                                idle_timeout=5,
                                hard_timeout=10,
                                cookie=0x0123456789abcdef,
                                packet_count=10,
                                byte_count=1000,
                                actions=[ofp.action.output(port=1),
                                         ofp.action.output(port=2)])
     expected = ''.join([
         '\x00\x68', # length
         '\x03', # table_id
         '\x00', # pad
         '\x00\x3f\xff\xff', # match.wildcards
         '\x00' * 36, # remaining match fields
         '\x00\x00\x00\x01', # duration_sec
         '\x00\x00\x00\x02', # duration_nsec
         '\x00\x64', # priority
         '\x00\x05', # idle_timeout
         '\x00\x0a', # hard_timeout
         '\x00' * 6, # pad2
         '\x01\x23\x45\x67\x89\xab\xcd\xef', # cookie
         '\x00\x00\x00\x00\x00\x00\x00\x0a', # packet_count
         '\x00\x00\x00\x00\x00\x00\x03\xe8', # byte_count
         '\x00\x00', # actions[0].type
         '\x00\x08', # actions[0].len
         '\x00\x01', # actions[0].port
         '\x00\x00', # actions[0].max_len
         '\x00\x00', # actions[1].type
         '\x00\x08', # actions[1].len
         '\x00\x02', # actions[1].port
         '\x00\x00', # actions[1].max_len
     ])
     self.assertEquals(expected, obj.pack())