Hi,

How about using get_port() or get_ports() method of DPSet?


$ git diff
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 3e7c598..3f3ab64 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -21,14 +21,17 @@ from ryu.ofproto import ofproto_v1_3
  from ryu.lib.packet import packet
  from ryu.lib.packet import ethernet
  from ryu.lib.packet import ether_types
+from ryu.controller import dpset
  
  
  class SimpleSwitch13(app_manager.RyuApp):
      OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
+    _CONTEXTS = {'dpset': dpset.DPSet}
  
      def __init__(self, *args, **kwargs):
          super(SimpleSwitch13, self).__init__(*args, **kwargs)
          self.mac_to_port = {}
+        self.dpset = kwargs['dpset']
  
      @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
      def switch_features_handler(self, ev):
@@ -76,6 +79,12 @@ class SimpleSwitch13(app_manager.RyuApp):
          parser = datapath.ofproto_parser
          in_port = msg.match['in_port']
  
+        # Get port description by using DPSet API
+        # Return value of get_port() is an instance of ofproto_parser.OFPPort
+        port_info = self.dpset.get_port(datapath.id, in_port)
+        self.logger.info('port_info.name=%s', port_info.name)
+        self.logger.info('port_info.hw_addr=%s', port_info.hw_addr)
+
          pkt = packet.Packet(msg.data)
          eth = pkt.get_protocols(ethernet.ethernet)[0]

  

$ ryu-manager ryu.app.simple_switch_13
loading app ryu.app.simple_switch_13
loading app ryu.controller.ofp_handler
instantiating app None of DPSet
creating context dpset
instantiating app ryu.app.simple_switch_13 of SimpleSwitch13
instantiating app ryu.controller.ofp_handler of OFPHandler
port_info.name=s1-eth2
port_info.hw_addr=de:bd:64:0f:cb:0f
packet in 1 6a:50:d8:2c:cb:dc 33:33:00:00:00:02 2
port_info.name=s1-eth1
port_info.hw_addr=4e:31:d2:9a:80:39
packet in 1 96:2b:f0:c2:3a:d9 33:33:00:00:00:02 1
port_info.name=s1-eth2
port_info.hw_addr=de:bd:64:0f:cb:0f
packet in 1 6a:50:d8:2c:cb:dc 33:33:00:00:00:02 2


Thanks,
Iwase

On 2016年04月19日 00:35, Pynbiang Hadem wrote:
> Dear All,
> The output of "sudo ovs-ofctl show s1" is as below:
> /---------------------------------------------------------------------------/
> /mininet@mininet-vm:~$ sudo ovs-ofctl show s1                                 
>    OFPT_FEATURES_REPLY (xid=0x2): dpid:0000000000000001/
> /n_tables:254, n_buffers:256/
> /..../
> /actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src 
> mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst/
> / 1(s1-eth1): addr:46:8e:66:4f:b2:1d/
> /    ..../
> / 2(s1-eth2): addr:46:49:f0:7f:49:68/
> /    ..../
> / LOCAL(s1): addr:aa:75:65:c6:89:44/
> /    ..../
> -----------------------------------------------------------------
> I need to get the hardware address of ports /s1-eth1, //s1-eth2, /of 
> switch///s1, s2 etc / from a ryu application. Is it possible to get it using 
> get_all() method of dpset.py?. If so Kindly guide and give some reference 
> examples.
>
> Thanks
> Hadem
>
>
>
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications Manager
> Applications Manager provides deep performance insights into multiple tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>
>
>
> _______________________________________________
> Ryu-devel mailing list
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to