Hi,

How about using this instead of addrconv module?
  e.g.) parser.OFPMatch(nw_src=struct.unpack("!I", 
socket.inet_aton('10.0.0.1'))[0])

Thanks,
Iwase

On 2015年09月24日 15:38, Vishlesh Patel wrote:
> Hi,
> 
> It is the same error i received last time without using addrconv method.
> 
> Error: cannot convert argument to integer.
> 
> hub: uncaught exception: Traceback (most recent call last):
>   File "/usr/local/lib/python2.7/dist-packages/ryu/lib/hub.py", line 52, in 
> _launch
>     func(*args, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py", line 
> 276, in _event_loop
>     handler(ev)
>   File "/home/vishlesh/ryu-scripts/sample.py", line 79, in 
> switch_features_handler
>     self.add_flow(datapath, 10, match, action)
>   File "/home/vishlesh/ryu-scripts/sample.py", line 137, in add_flow
>     datapath.send_msg(mod)
>   File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", 
> line 235, in send_msg
>     msg.serialize()
>   File 
> "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_parser.py", line 
> 212, in serialize
>     self._serialize_body()
>   File 
> "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_0_parser.py", 
> line 2135, in _serialize_body
>     self.match.serialize(self.buf, offset)
>   File 
> "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_0_parser.py", 
> line 213, in serialize
>     self.nw_src, self.nw_dst, self.tp_src, self.tp_dst)
>   File "/usr/local/lib/python2.7/dist-packages/ryu/lib/pack_utils.py", line 
> 25, in msg_pack_into
>     buf += struct.pack(fmt, *args)
> error: cannot convert argument to integer
> 
> On Thu, Sep 24, 2015 at 2:12 AM, Yusuke Iwase <[email protected] 
> <mailto:[email protected]>> wrote:
> 
>     Hi,
> 
>     On 2015年09月24日 11:40, Vishlesh Patel wrote:
>     > Hi Yusuke,
>     >
>     > Thanks for the reply. I tried it, still having same error.
> 
>     What error did you get?
> 
>     >
>     > Code now looks like that:
>     >
>     > def add_layer4_rules(self, datapath, nw_proto, nw_dst, priority, 
> fwd_port ):
>     >         print " I am in method add_layer4_rules "
>     >         parser = datapath.ofproto_parser
>     >         actions = [parser.OFPActionOutput(fwd_port)]
>     >         match = parser.OFPMatch(nw_proto = nw_proto,
>     >                 nw_dst = addrconv.ipv4.text_to_bin(nw_dst))
>     >         self.add_flow(datapath, priority, match, actions)
>     >
>     >     # Member methods you can call to install general rules
>     >     def add_flow(self, datapath, priority, match, actions):
>     >         ofproto = datapath.ofproto
>     >         mod = datapath.ofproto_parser.OFPFlowMod(
>     >                 datapath=datapath, match=match, cookie=0,
>     >                 command=ofproto.OFPFC_ADD, idle_timeout=0, 
> hard_timeout=0,
>     >                 priority = priority,
>     >                 flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
>     >         datapath.send_msg(mod)
>     >
>     >
>     >
>     >
>     > Best Regards,
>     > Vishlesh Patel
>     > M.S. Computer Engineering
>     > NYU Polytechnic School of Engineering
>     >
>     > On Wed, Sep 23, 2015 at 8:22 PM, Yusuke Iwase <[email protected] 
> <mailto:[email protected]> <mailto:[email protected] 
> <mailto:[email protected]>>> wrote:
>     >
>     >     Hi,
>     >
>     >     On 2015年09月23日 14:41, Vishlesh Patel wrote:
>     >     > Hi there,
>     >     >
>     >     > I am using RYU controller with flowvisor. As flowvisor do not 
> support any other version other than openflow v1. I am using openflow v1 in 
> my project.
>     >     >
>     >     > I have topology of 3 ovs switches and controller sits in one of 
> server conataining ovs bridge. Other two ovs bridge in other servers connects 
> to controller through public interface. But when run my ryu application, it 
> connects to switches but not able to add rules with nw_src match . I am 
> getting this error here:
>     >     >
>     >     > hub: uncaught exception: Traceback (most recent call last):
>     >     >   File "/usr/local/lib/python2.7/dist-packages/ryu/lib/hub.py", 
> line 52, in _launch
>     >     >     func(*args, **kwargs)
>     >     >   File 
> "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py", line 276, 
> in _event_loop
>     >     >     handler(ev)
>     >     >   File "/home/vishlesh/ryu-scripts/sample.py", line 79, in 
> switch_features_handler
>     >     >     self.add_flow(datapath, 10, match, action)
>     >     >   File "/home/vishlesh/ryu-scripts/sample.py", line 137, in 
> add_flow
>     >     >     datapath.send_msg(mod)
>     >     >   File 
> "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 
> 235, in send_msg
>     >     >     msg.serialize()
>     >     >   File 
> "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_parser.py", line 
> 212, in serialize
>     >     >     self._serialize_body()
>     >     >   File 
> "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_0_parser.py", 
> line 2135, in _serialize_body
>     >     >     self.match.serialize(self.buf, offset)
>     >     >   File 
> "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_0_parser.py", 
> line 213, in serialize
>     >     >     self.nw_src, self.nw_dst, self.tp_src, self.tp_dst)
>     >     >   File 
> "/usr/local/lib/python2.7/dist-packages/ryu/lib/pack_utils.py", line 25, in 
> msg_pack_into
>     >     >     buf += struct.pack(fmt, *args)
>     >     > error: cannot convert argument to integer
>     >     >
>     >     > My code is here:
>     >     > class SimpleSwitch(app_manager.RyuApp):
>     >     >     OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]
>     >     >     """
>     >     >         Constructor:
>     >     >         You can define some globally used variables inside the 
> class
>     >     >     """
>     >     >     def __init__(self, *args, **kwargs):
>     >     >         super(SimpleSwitch, self).__init__(*args, **kwargs)
>     >     >         # arp table: for searching
>     >     >         self.arp_table ={"10.0.0.3":"53:54:00:69:ae:2b",
>     >     >                          "10.1.0.3":"52:54:00:cb:51:8b"}
>     >     >         self.TCP_proto = 6
>     >     >         self.UDP_proto = 17
>     >     >         self.ICMP_proto = 1
>     >     >
>     >     >  @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
>     >     >     def switch_features_handler(self, ev):
>     >     >         datapath = ev.msg.datapath
>     >     >         ofproto = datapath.ofproto
>     >     >         parser = datapath.ofproto_parser
>     >     >
>     >     >         # Insert Static rule
>     >     >         match1 = parser.OFPMatch()
>     >     >         action1 = 
> [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER)]
>     >     >         self.add_flow(datapath, 0, match1, action1)
>     >     >
>     >     >
>     >     >         match2 = parser.OFPMatch(dl_type = ether.ETH_TYPE_ARP)
>     >     >         action2 = 
> [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER)]
>     >     >         self.add_flow(datapath, 40, match2, action2)
>     >     >         print "added rule#1"
>     >     >
>     >     >         # Installing static rules to process TCP/UDP and ICMP and 
> ACL
>     >     >         dpid = datapath.id <http://datapath.id> 
> <http://datapath.id> <http://datapath.id>  # classifying the switch ID
>     >     >         print("switch ",dpid," detected")
>     >     >         if dpid == 2: # switch ovs of host 1
>     >     >             match = parser.OFPMatch(dl_type=ether.ETH_TYPE_IP,
>     >     >                  nw_proto=self.TCP_proto,
>     >     >                  nw_src = '10.0.0.3' , nw_dst = '10.1.0.3' )
>     >     >             action = [parser.OFPActionOutput(2)]
>     >     >             self.add_flow(datapath, 10, match, action)
>     >     >
>     >     > Please help.
>     >
>     >     You need to convert IP/MAC address into binary data.
>     >
>     >      e.g.)
>     >        from ryu.lib import addrconv
>     >        ...
>     >        parser.OFPMatch(nw_src=addrconv.ipv4.text_to_bin('10.0.0.3'))
>     >
>     >     This conversion is required in only OpenFlow1.0 with Ryu.
>     >
>     >     Thanks,
>     >     Iwase
>     >
>     >     >
>     >     >
>     >     > Best Regards,
>     >     > Vishlesh Patel
>     >     > M.S. Computer Engineering
>     >     > NYU Polytechnic School of Engineering
>     >     >
>     >     >
>     >     > 
> ------------------------------------------------------------------------------
>     >     > Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
>     >     > Get real-time metrics from all of your servers, apps and tools
>     >     > in one place.
>     >     > SourceForge users - Click here to start your Free Trial of 
> Datadog now!
>     >     > http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
>     >     >
>     >     >
>     >     >
>     >     > _______________________________________________
>     >     > Ryu-devel mailing list
>     >     > [email protected] 
> <mailto:[email protected]> 
> <mailto:[email protected] 
> <mailto:[email protected]>>
>     >     > https://lists.sourceforge.net/lists/listinfo/ryu-devel
>     >     >
>     >
>     >
>     >
>     >
>     > 
> ------------------------------------------------------------------------------
>     > Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
>     > Get real-time metrics from all of your servers, apps and tools
>     > in one place.
>     > SourceForge users - Click here to start your Free Trial of Datadog now!
>     > http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
>     >
>     >
>     >
>     > _______________________________________________
>     > Ryu-devel mailing list
>     > [email protected] <mailto:[email protected]>
>     > https://lists.sourceforge.net/lists/listinfo/ryu-devel
>     >
> 
> 
> 
> ------------------------------------------------------------------------------
> Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
> Get real-time metrics from all of your servers, apps and tools
> in one place.
> SourceForge users - Click here to start your Free Trial of Datadog now!
> http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to