Created
March 27, 2014 21:45
-
-
Save gad0lin/9819718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ryu.base import app_manager | |
from ryu.controller import ofp_event | |
from ryu.controller.handler import MAIN_DISPATCHER | |
from ryu.controller.handler import CONFIG_DISPATCHER | |
from ryu.controller.handler import set_ev_cls | |
class L2Switch(app_manager.RyuApp): | |
def __init__(self, *args, **kwargs): | |
super(L2Switch, self).__init__(*args, **kwargs) | |
@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER) | |
def switch_features_handler(self, ev): | |
print "Switch features received" | |
print "received test" | |
msg = ev.msg | |
dp = msg.datapath | |
ofp = dp.ofproto | |
ofp_parser = dp.ofproto_parser | |
print "running test" | |
#monitor_flags = [ofp.OFPFMF_INITIAL, ofp.OFPFMF_ONLY_OWN] | |
monitor_flags = ofp.OFPFMF_INITIAL | |
match = ofp_parser.OFPMatch(in_port=1) | |
req = ofp_parser.OFPFlowMonitorRequest(dp, 0, 10000, | |
ofp.OFPP_ANY, ofp.OFPG_ANY, | |
monitor_flags, | |
ofp.OFPTT_ALL, | |
ofp.OFPFMC_ADD, match) | |
dp.send_msg(req) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment