コード例 #1
0
ファイル: test_parse.py プロジェクト: opencord/fabric-oftest
 def test_unknown_ethertype(self):
     import loxi.of12 as ofp
     self.maxDiff = None
     pkt = scapy.Ether(dst='00:01:02:03:04:05', src='00:06:07:08:09:0a', type=0x0801)/ \
         ('\x11' * 20)
     expected = [
         ofp.oxm.eth_dst([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.eth_src([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
         ofp.oxm.eth_type(0x0801),
         ofp.oxm.vlan_vid(ofp.OFP_VLAN_NONE),
     ]
     result = parse.packet_to_flow_match_v3(pkt).oxm_list
     self.assertEquals([x.show() for x in expected], [x.show() for x in result])
コード例 #2
0
ファイル: test_parse.py プロジェクト: sun363587351/OpenFlow-1
 def test_unknown_ethertype(self):
     import loxi.of12 as ofp
     self.maxDiff = None
     pkt = scapy.Ether(dst='00:01:02:03:04:05', src='00:06:07:08:09:0a', type=0x0801)/ \
         ('\x11' * 20)
     expected = [
         ofp.oxm.eth_dst([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.eth_src([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
         ofp.oxm.eth_type(0x0801),
         ofp.oxm.vlan_vid(ofp.OFP_VLAN_NONE),
     ]
     result = parse.packet_to_flow_match_v3(pkt).oxm_list
     self.assertEquals([x.show() for x in expected],
                       [x.show() for x in result])
コード例 #3
0
ファイル: test_parse.py プロジェクト: opencord/fabric-oftest
 def test_arp(self):
     import loxi.of12 as ofp
     self.maxDiff = None
     pkt = scapy.Ether(dst='00:01:02:03:04:05', src='00:06:07:08:09:0a')/ \
         scapy.ARP(hwsrc='00:01:02:03:04:05', hwdst='00:06:07:08:09:0a', \
                   psrc='192.168.0.1', pdst='192.168.0.2', op=1)
     expected = [
         ofp.oxm.eth_dst([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.eth_src([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
         ofp.oxm.eth_type(0x0806),
         ofp.oxm.vlan_vid(ofp.OFP_VLAN_NONE),
         ofp.oxm.arp_op(1),
         ofp.oxm.arp_spa(0xc0a80001),
         ofp.oxm.arp_tpa(0xc0a80002),
         ofp.oxm.arp_sha([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.arp_tha([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
     ]
     result = parse.packet_to_flow_match_v3(pkt).oxm_list
     self.assertEquals([x.show() for x in expected], [x.show() for x in result])
コード例 #4
0
ファイル: test_parse.py プロジェクト: sun363587351/OpenFlow-1
 def test_arp(self):
     import loxi.of12 as ofp
     self.maxDiff = None
     pkt = scapy.Ether(dst='00:01:02:03:04:05', src='00:06:07:08:09:0a')/ \
         scapy.ARP(hwsrc='00:01:02:03:04:05', hwdst='00:06:07:08:09:0a', \
                   psrc='192.168.0.1', pdst='192.168.0.2', op=1)
     expected = [
         ofp.oxm.eth_dst([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.eth_src([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
         ofp.oxm.eth_type(0x0806),
         ofp.oxm.vlan_vid(ofp.OFP_VLAN_NONE),
         ofp.oxm.arp_op(1),
         ofp.oxm.arp_spa(0xc0a80001),
         ofp.oxm.arp_tpa(0xc0a80002),
         ofp.oxm.arp_sha([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.arp_tha([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
     ]
     result = parse.packet_to_flow_match_v3(pkt).oxm_list
     self.assertEquals([x.show() for x in expected],
                       [x.show() for x in result])
コード例 #5
0
ファイル: test_parse.py プロジェクト: opencord/fabric-oftest
 def test_icmp(self):
     import loxi.of12 as ofp
     self.maxDiff = None
     pkt = scapy.Ether(dst='00:01:02:03:04:05', src='00:06:07:08:09:0a')/ \
         scapy.IP(src='192.168.0.1', dst='192.168.0.2', tos=2 | (32 << 2), ttl=64)/ \
         scapy.ICMP(type=8, code=1)
     expected = [
         ofp.oxm.eth_dst([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.eth_src([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
         ofp.oxm.eth_type(0x0800),
         ofp.oxm.vlan_vid(ofp.OFP_VLAN_NONE),
         ofp.oxm.ip_proto(1),
         ofp.oxm.ip_dscp(32),
         ofp.oxm.ip_ecn(2),
         ofp.oxm.ipv4_src(0xc0a80001),
         ofp.oxm.ipv4_dst(0xc0a80002),
         ofp.oxm.icmpv4_type(8),
         ofp.oxm.icmpv4_code(1)
     ]
     result = parse.packet_to_flow_match_v3(pkt).oxm_list
     self.assertEquals([x.show() for x in expected], [x.show() for x in result])
コード例 #6
0
ファイル: test_parse.py プロジェクト: opencord/fabric-oftest
 def test_icmpv6(self):
     import loxi.of12 as ofp
     self.maxDiff = None
     pkt = scapy.Ether(dst='00:01:02:03:04:05', src='00:06:07:08:09:0a')/ \
         scapy.IPv6(src="::1", dst="::2", tc=2 | (32 << 2), fl=7)/ \
         scapy.ICMPv6EchoRequest()
     expected = [
         ofp.oxm.eth_dst([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.eth_src([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
         ofp.oxm.eth_type(0x86dd),
         ofp.oxm.vlan_vid(ofp.OFP_VLAN_NONE),
         ofp.oxm.ip_proto(0x3a),
         ofp.oxm.ip_dscp(32),
         ofp.oxm.ip_ecn(2),
         ofp.oxm.ipv6_src("\x00" * 15 + "\x01"),
         ofp.oxm.ipv6_dst("\x00" * 15 + "\x02"),
         ofp.oxm.ipv6_flabel(7),
         ofp.oxm.icmpv6_type(128),
         ofp.oxm.icmpv6_code(0)
     ]
     result = parse.packet_to_flow_match_v3(pkt).oxm_list
     self.assertEquals([x.show() for x in expected], [x.show() for x in result])
コード例 #7
0
ファイル: test_parse.py プロジェクト: sun363587351/OpenFlow-1
 def test_tcp(self):
     import loxi.of12 as ofp
     self.maxDiff = None
     pkt = scapy.Ether(dst='00:01:02:03:04:05', src='00:06:07:08:09:0a')/ \
         scapy.IP(src='192.168.0.1', dst='192.168.0.2', tos=2 | (32 << 2), ttl=64)/ \
         scapy.TCP(sport=1234, dport=80)
     expected = [
         ofp.oxm.eth_dst([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.eth_src([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
         ofp.oxm.eth_type(0x0800),
         ofp.oxm.vlan_vid(ofp.OFP_VLAN_NONE),
         ofp.oxm.ip_proto(6),
         ofp.oxm.ip_dscp(32),
         ofp.oxm.ip_ecn(2),
         ofp.oxm.ipv4_src(0xc0a80001),
         ofp.oxm.ipv4_dst(0xc0a80002),
         ofp.oxm.tcp_src(1234),
         ofp.oxm.tcp_dst(80)
     ]
     result = parse.packet_to_flow_match_v3(pkt).oxm_list
     self.assertEquals([x.show() for x in expected],
                       [x.show() for x in result])
コード例 #8
0
ファイル: test_parse.py プロジェクト: opencord/fabric-oftest
 def test_vlan(self):
     import loxi.of12 as ofp
     self.maxDiff = None
     pkt = scapy.Ether(dst='00:01:02:03:04:05', src='00:06:07:08:09:0a')/ \
         scapy.Dot1Q(vlan=50, prio=5)/ \
         scapy.IP(src='192.168.0.1', dst='192.168.0.2', tos=2 | (32 << 2), ttl=64)/ \
         scapy.TCP(sport=1234, dport=80)
     expected = [
         ofp.oxm.eth_dst([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.eth_src([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
         ofp.oxm.eth_type(0x0800),
         ofp.oxm.vlan_vid(50),
         ofp.oxm.vlan_pcp(5),
         ofp.oxm.ip_proto(6),
         ofp.oxm.ip_dscp(32),
         ofp.oxm.ip_ecn(2),
         ofp.oxm.ipv4_src(0xc0a80001),
         ofp.oxm.ipv4_dst(0xc0a80002),
         ofp.oxm.tcp_src(1234),
         ofp.oxm.tcp_dst(80)
     ]
     result = parse.packet_to_flow_match_v3(pkt).oxm_list
     self.assertEquals([x.show() for x in expected], [x.show() for x in result])
コード例 #9
0
ファイル: test_parse.py プロジェクト: sun363587351/OpenFlow-1
 def test_tcpv6(self):
     import loxi.of12 as ofp
     self.maxDiff = None
     pkt = scapy.Ether(dst='00:01:02:03:04:05', src='00:06:07:08:09:0a')/ \
         scapy.IPv6(src="::1", dst="::2", nh=6, tc=2 | (32 << 2), fl=7)/ \
         scapy.TCP(sport=1234, dport=80)
     expected = [
         ofp.oxm.eth_dst([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
         ofp.oxm.eth_src([0x00, 0x06, 0x07, 0x08, 0x09, 0x0a]),
         ofp.oxm.eth_type(0x86dd),
         ofp.oxm.vlan_vid(ofp.OFP_VLAN_NONE),
         ofp.oxm.ip_proto(6),
         ofp.oxm.ip_dscp(32),
         ofp.oxm.ip_ecn(2),
         ofp.oxm.ipv6_src("\x00" * 15 + "\x01"),
         ofp.oxm.ipv6_dst("\x00" * 15 + "\x02"),
         ofp.oxm.ipv6_flabel(7),
         ofp.oxm.tcp_src(1234),
         ofp.oxm.tcp_dst(80)
     ]
     result = parse.packet_to_flow_match_v3(pkt).oxm_list
     self.assertEquals([x.show() for x in expected],
                       [x.show() for x in result])