Add tests to verify match on ARP sender and target IPs
diff --git a/tests/FuncUtils.py b/tests/FuncUtils.py
index 278f15c..87df355 100644
--- a/tests/FuncUtils.py
+++ b/tests/FuncUtils.py
@@ -281,6 +281,30 @@
match_send_flowadd(self, match, priority, of_ports[1])
return (pkt_match, match)
+def match_arp_sender(self,of_ports,priority=None):
+ #Generate Match_Arp_Sender
+
+ #Create a simple icmp packet and generate match on arp sender flow
+ pkt_match = simple_arp_packet()
+ match = parse.packet_to_flow_match(pkt_match)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL^ofp.OFPFW_DL_TYPE ^ofp.OFPFW_NW_PROTO ^ofp.OFPFW_NW_SRC_MASK
+ match_send_flowadd(self, match, priority, of_ports[1])
+ return (pkt_match, match)
+
+def match_arp_target(self,of_ports,priority=None):
+ #Generate Match_Arp_Target
+
+ #Create a simple icmp packet and generate match on arp target flow
+ pkt_match = simple_arp_packet()
+ match = parse.packet_to_flow_match(pkt_match)
+ self.assertTrue(match is not None, "Could not generate flow match from pkt")
+
+ match.wildcards = ofp.OFPFW_ALL^ofp.OFPFW_DL_TYPE ^ofp.OFPFW_NW_PROTO ^ofp.OFPFW_NW_DST_MASK
+ match_send_flowadd(self, match, priority, of_ports[1])
+ return (pkt_match, match)
+
def match_ethernet_type(self,of_ports,priority=None):
#Generate a Match_Ethernet_Type flow
diff --git a/tests/flow_matches.py b/tests/flow_matches.py
index 592d7c3..9d04093 100644
--- a/tests/flow_matches.py
+++ b/tests/flow_matches.py
@@ -679,6 +679,83 @@
self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+class ArpSenderIP(base_tests.SimpleDataPlane):
+
+ """"Verify match on single Header Field -- Arp Protocol"""
+
+ def runTest(self):
+
+ logging.info("Running Arp Protocol test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear Switch State
+ delete_all_flows(self.controller)
+
+ egress_port=of_ports[1]
+ no_ports=set(of_ports).difference([egress_port])
+ yes_ports = of_ports[1]
+
+ logging.info("Inserting a flow with match on Arp Protocol ")
+ logging.info("Sending matching and non-matching arp packets")
+ logging.info("Verifying only matching packets implements the action specified in the flow")
+
+ #Create a flow matching on ARP sender IP
+ (pkt,match) = match_arp_sender(self,of_ports)
+
+ #Send Packet matching the flow
+ self.dataplane.send(of_ports[0], str(pkt))
+
+ #Verify packet implements the action specified in the flow
+ receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+ #Create a non-matching packet , verify packet_in get generated
+ pkt2 = simple_arp_packet(ip_snd="10.10.0.10");
+ self.dataplane.send(of_ports[0], str(pkt2))
+ (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+ self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+class ArpTargetIP(base_tests.SimpleDataPlane):
+
+ """"Verify match on single Header Field -- Arp Protocol"""
+
+ def runTest(self):
+
+ logging.info("Running Arp Protocol test")
+
+ of_ports = config["port_map"].keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
+
+ #Clear Switch State
+ delete_all_flows(self.controller)
+
+ egress_port=of_ports[1]
+ no_ports=set(of_ports).difference([egress_port])
+ yes_ports = of_ports[1]
+
+ logging.info("Inserting a flow with match on Arp Protocol ")
+ logging.info("Sending matching and non-matching arp packets")
+ logging.info("Verifying only matching packets implements the action specified in the flow")
+
+ #Create a flow matching on ARP target IP
+ (pkt,match) = match_arp_target(self,of_ports)
+
+ #Send Packet matching the flow
+ self.dataplane.send(of_ports[0], str(pkt))
+
+ #Verify packet implements the action specified in the flow
+ receive_pkt_check(self.dataplane,pkt,[yes_ports],no_ports,self)
+
+ #Create a non-matching packet , verify packet_in get generated
+ pkt2 = simple_arp_packet(ip_tgt="10.10.0.10");
+ self.dataplane.send(of_ports[0], str(pkt2))
+ (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=4)
+ self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+
class ExactMatch(base_tests.SimpleDataPlane):
"""Verify match on Single header field -- Exact Match """