python
from pox.core import core
import pox.openflow.libopenflow_01 as of
class MyController(object):
def __init__(self):
core.openflow.addListeners(self)
def _handle_ConnectionUp(self, event):
msg = of.ofp_flow_mod()
action = of.ofp_action_output(port=of.OFPP_CONTROLLER)
msg.actions.append(action)
event.connection.send(msg)
def _handle_PacketIn(self, event):
packet = event.parsed
def launch():
core.registerNew(MyController)