add test pktact.DirectPacketController
diff --git a/tests/pktact.py b/tests/pktact.py
index 73ef8c4..78bdab7 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -181,6 +181,68 @@
self.assertEqual(str(pkt), str(rcv_pkt),
'Response packet does not match send packet')
+class DirectPacketController(basic.SimpleDataPlane):
+ """
+ Send packet to the controller port
+
+ Generate a packet
+ Generate and install a matching flow
+ Add action to direct the packet to the controller port
+ Send the packet to ingress dataplane port
+ Verify the packet is received at the controller port
+ """
+ def runTest(self):
+ self.handleFlow()
+
+ def handleFlow(self, pkttype='TCP'):
+ of_ports = pa_port_map.keys()
+ of_ports.sort()
+ self.assertTrue(len(of_ports) > 0, "Not enough ports for test")
+
+ if (pkttype == 'ICMP'):
+ pkt = simple_icmp_packet()
+ else:
+ pkt = simple_tcp_packet()
+ match = parse.packet_to_flow_match(pkt)
+ match.wildcards &= ~ofp.OFPFW_IN_PORT
+ self.assertTrue(match is not None,
+ "Could not generate flow match from pkt")
+ act = action.action_output()
+
+ rv = delete_all_flows(self.controller, pa_logger)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
+
+ ingress_port = of_ports[0]
+ match.in_port = ingress_port
+
+ request = message.flow_mod()
+ request.match = match
+
+ request.buffer_id = 0xffffffff
+ act.port = ofp.OFPP_CONTROLLER
+ act.max_len = 65535
+ self.assertTrue(request.actions.add(act), "Could not add action")
+
+ pa_logger.info("Inserting flow")
+ rv = self.controller.message_send(request)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+
+ pa_logger.info("Sending packet to dp port " +
+ str(ingress_port))
+ self.dataplane.send(ingress_port, str(pkt))
+
+ (response, raw) = self.controller.poll(ofp.OFPT_PACKET_IN)
+
+ self.assertTrue(response is not None,
+ 'Packet in message not received by controller')
+ if not dataplane.match_exp_pkt(pkt, response.data):
+ pa_logger.debug("Sent %s" % format_packet(pkt))
+ pa_logger.debug("Resp %s" % format_packet(response.data))
+ self.assertTrue(False,
+ 'Response packet does not match send packet' +
+ ' for controller port')
+
class DirectPacketQueue(basic.SimpleDataPlane):
"""