Hi all,
I am running my topology on mininet and I am trying to add VLAN tags for
the packets received on switches..
from ryu. ofproto. ether import ETH_TYPE_8021Q
//////////////////////////
field = parser.OFPMatchField.make(ofproto.OXM_OF_VLAN_VID,10)
actions = [datapath. ofproto_parser. OFPActionPushVlan (ETH_TYPE_8021Q),
datapath.ofproto_parser. OFPActionSetField (field)]
///////////////////////
When I try to run this actions, I get following error..
field = parser.OFPMatchField.make(ofproto.OXM_OF_VLAN_VID,10)
AttributeError: 'module' object has no attribute 'OFPMatchField'
I have attached my full code /////////
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_3
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.lib.mac import haddr_to_bin
from ryu.topology import switches
from ryu.topology.event import EventSwitchEnter, EventSwitchLeave
from ryu.controller import dpset
from ryu. ofproto. ether import ETH_TYPE_8021Q
class SwitchEventApp(app_manager.RyuApp):
_CONTEXTS = {'switches': switches.Switches,}
@set_ev_cls(EventSwitchEnter)
def _ev_switch_enter_handler(self, ev):
print('enter: %s' % ev)
datapath = ev.switch.dp
datapathID = datapath.id
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
field = parser.OFPMatchField.make(ofproto.OXM_OF_VLAN_VID,10)
actions = [datapath. ofproto_parser. OFPActionPushVlan
(ETH_TYPE_8021Q), datapath. ofproto_parser. OFPActionSetField (field)]
self.add_flow(datapath, 2,"00:00:00:00:00:03", actions)
actions2 = [datapath.ofproto_parser.OFPActionPopVlan(ETH_TYPE_8021Q)]
self.add_flow(datapath, 2,"00:00:00:00:00:03", actions2)
print ('DATAPATH ID: %s' % datapathID)
def add_flow(self, datapath, in_port, dst, actions):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
actions = actions
match = parser.OFPMatch(in_port=in_port, dl_dst=haddr_to_bin(dst))
mod = datapath.ofproto_parser.OFPFlowMod(datapath=datapath,
cookie=0,idle_timeout=0, hard_timeout=0,priority=0,
buffer_id=ofproto.OFP_NO_BUFFER,flags=0, match=match, actions = actions2)
datapath.send_msg(mod)
Best Regards,
Windhya Rankothge,
Universitat Pompeu Fabra,
Barcelona.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel