Hi Sakib,

On 2015年04月07日 10:02, MD.Badruzzaman Shakib wrote:
> Hello everyone,
> 
> I want to add/delete flows from my application when link_add/link_delete 
> occurs. I create two separate handler function for link_add and link_delete 
> which are decorated with corresponding event function. But in those functions 
> I only have src, dst and src_port(connected to dst). But without any datapath 
> object (ryu.controller.controller.Datapath) I cannot call my add_flow 
> function. My add_flow function is given below. Can anyone please tell me how 
> can I call the add_flow function from another function beside 
> _packet_in_handler with the information(src, src_port, dst) i have? Is there 
> any better process to add/delete flows without using packet_in_handler?

What "event" did you set to your link_add/link_delete functions?
You can get Datapath instance from Event instance("ev") in the event handlers.

e.g.)
    @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
    def switch_features_handler(self, ev):
        datapath = ev.msg.datapath

Thanks,
Iwase

> 
> def add_flow(self, datapath, dst, actions):
>         ofproto = datapath.ofproto
>        
>         match = datapath.ofproto_parser.OFPMatch(                             
>               
>             eth_type=0x800, ipv4_dst=dst)
>                
>         inst = 
> [datapath.ofproto_parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, 
> actions)]
>        
>         mod = datapath.ofproto_parser.OFPFlowMod(
>             datapath=datapath, match=match, cookie=0,
>             command=ofproto.OFPFC_ADD, idle_timeout=0, hard_timeout=0,
>             priority=ofproto.OFP_DEFAULT_PRIORITY,
>             flags=ofproto.OFPFF_SEND_FLOW_REM, instructions= inst)
>        
>         datapath.send_msg(mod)
> 
> Thanking you
> Sakib
> 
> 
> 
> ------------------------------------------------------------------------------
> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> Develop your own process in accordance with the BPMN 2 standard
> Learn Process modeling best practices with Bonita BPM through live exercises
> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to