Add test cases for udp src_port/dst_port and ICMP type/code match
diff --git a/tests/FuncUtils.py b/tests/FuncUtils.py
index 6c55425..f320652 100644
--- a/tests/FuncUtils.py
+++ b/tests/FuncUtils.py
@@ -454,6 +454,111 @@
     return (pkt_matchdst,match)        
 
 
+def match_udp_src(self,of_ports,priority=None):
+    #Generate Match_Udp_Src
+
+    #Create a simple udp packet and generate match on udp source port flow
+    pkt_matchtSrc = simple_udp_packet(udp_sport=111)
+    match = parse.packet_to_flow_match(pkt_matchtSrc)
+    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_TP_SRC  
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != None :
+        msg.priority = priority
+
+    act = action.action_output()
+    act.port = of_ports[1]
+    msg.actions.add(act)
+
+    self.controller.message_send(msg)
+    do_barrier(self.controller)
+
+    return (pkt_matchtSrc,match)  
+
+def match_udp_dst(self,of_ports,priority=None):
+    #Generate Match_Udp_Dst
+
+        #Create a simple udp packet and generate match on udp destination port flow
+    pkt_matchdst = simple_udp_packet(udp_dport=112)
+    match = parse.packet_to_flow_match(pkt_matchdst)
+    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_TP_DST  
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != None :
+        msg.priority = priority
+    act = action.action_output()
+    act.port = of_ports[1]
+    msg.actions.add(act)
+
+    self.controller.message_send(msg)
+    do_barrier(self.controller)
+
+    return (pkt_matchdst,match)        
+
+
+def match_icmp_type(self,of_ports,priority=None):
+    #Generate Match_Icmp_Type
+
+    #Create a simple icmp packet and generate match on icmp type flow
+    pkt_match = simple_icmp_packet(icmp_type=1)
+    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_TP_SRC  
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != None :
+        msg.priority = priority
+
+    act = action.action_output()
+    act.port = of_ports[1]
+    msg.actions.add(act)
+
+    self.controller.message_send(msg)
+    do_barrier(self.controller)
+
+    return (pkt_match, match)
+
+def match_icmp_code(self,of_ports,priority=None):
+    #Generate Match_Icmp_Code
+
+    #Create a simple icmp packet and generate match on icmp code flow
+    pkt_match = simple_icmp_packet(icmp_code=3)
+    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_TP_DST
+    msg = message.flow_mod()
+    msg.out_port = ofp.OFPP_NONE
+    msg.command = ofp.OFPFC_ADD
+    msg.buffer_id = 0xffffffff
+    msg.match = match
+    if priority != None :
+        msg.priority = priority
+
+    act = action.action_output()
+    act.port = of_ports[1]
+    msg.actions.add(act)
+
+    self.controller.message_send(msg)
+    do_barrier(self.controller)
+
+    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 105b178..592d7c3 100644
--- a/tests/flow_matches.py
+++ b/tests/flow_matches.py
@@ -526,6 +526,158 @@
         (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=10)
         self.assertTrue(response is not None, "PacketIn not received for non matching packet")
 
+class UdpSrcPort(base_tests.SimpleDataPlane):
+    
+    """Verify match on Single header field -- Udp Source Port,  """
+    
+    def runTest(self):
+
+        logging.info("Running Udp Src Port 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 Udp Udp Source Port ")
+        logging.info("Sending matching and non-matching tcp packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+
+        (pkt,match) = match_udp_src(self,of_ports)   
+
+        #Sending packet matching the tcp_sport, verify it implements the action
+        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)
+
+        #Sending non matching packet , verify Packetin event gets triggered.
+        pkt2 = simple_udp_packet(udp_sport=540);
+        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 UdpDstPort(base_tests.SimpleDataPlane):
+    
+    """Verify match on Single header field -- Udp Destination Port """
+    
+    def runTest(self):
+
+        logging.info("Running Udp Destination Port 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 Udp Destination Port ")
+        logging.info("Sending matching and non-matching packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+
+        (pkt,match) = match_udp_dst(self,of_ports)   
+
+        #Sending packet matching the tcp_dport, verify it implements the action
+        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)
+
+        #Sending non matching packet , verify Packetin event gets triggered.
+        pkt2 = simple_udp_packet(udp_dport=541);
+        self.dataplane.send(of_ports[0], str(pkt2))
+        
+        (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN,timeout=10)
+        self.assertTrue(response is not None, "PacketIn not received for non matching packet")
+
+class ICMPType(base_tests.SimpleDataPlane):
+    
+    """Verify match on Single header field -- ICMP type,  """
+
+    def runTest(self):
+
+        logging.info("Running ICMP type 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 ICMP type")
+        logging.info("Sending matching and non-matching ICMP packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+
+        (pkt,match) = match_icmp_type(self,of_ports)   
+
+        #Sending packet matching the tcp_sport, verify it implements the action
+        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)
+
+        #Sending non matching packet , verify Packetin event gets triggered.
+        pkt2 = simple_icmp_packet(icmp_type=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 ICMPCode(base_tests.SimpleDataPlane):
+    
+    """Verify match on Single header field -- ICMP code,  """
+
+    def runTest(self):
+
+        logging.info("Running ICMP code 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 ICMP type")
+        logging.info("Sending matching and non-matching ICMP packets")
+        logging.info("Verifying matching packets implements the action specified in the flow")
+
+        (pkt,match) = match_icmp_code(self,of_ports)   
+
+        #Sending packet matching the tcp_dport, verify it implements the action
+        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)
+
+        #Sending non matching packet , verify Packetin event gets triggered.
+        pkt2 = simple_icmp_packet(icmp_code=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):