Signed-off-by: IWASE Yusuke <[email protected]>
---
 ryu/controller/controller.py              |  2 --
 ryu/services/protocols/bgp/speaker.py     |  2 +-
 ryu/services/protocols/bgp/utils/other.py | 12 +++++-------
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py
index 4aea6bd..54fb1c9 100644
--- a/ryu/controller/controller.py
+++ b/ryu/controller/controller.py
@@ -233,8 +233,6 @@ class Datapath(ofproto_protocol.ProtocolDesc):
 
         count = 0
         while self.state != DEAD_DISPATCHER:
-            ret = ""
-
             try:
                 ret = self.socket.recv(required_len)
             except SocketTimeout:
diff --git a/ryu/services/protocols/bgp/speaker.py 
b/ryu/services/protocols/bgp/speaker.py
index fd6af44..31553b2 100644
--- a/ryu/services/protocols/bgp/speaker.py
+++ b/ryu/services/protocols/bgp/speaker.py
@@ -101,7 +101,7 @@ class BgpProtocol(Protocol, Activity):
         Activity.__init__(self, name=activity_name)
         # Intialize instance variables.
         self._peer = None
-        self._recv_buff = ''
+        self._recv_buff = b''
         self._socket = socket
         self._socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
         self._sendlock = semaphore.Semaphore()
diff --git a/ryu/services/protocols/bgp/utils/other.py 
b/ryu/services/protocols/bgp/utils/other.py
index 94f849a..c8410e8 100644
--- a/ryu/services/protocols/bgp/utils/other.py
+++ b/ryu/services/protocols/bgp/utils/other.py
@@ -1,11 +1,9 @@
+import six
+
+
 def bytes2hex(given_bytes):
-    return ''.join(["%02X " % ord(x) for x in given_bytes]).strip()
+    return ' '.join('%02X' % b for b in bytearray(given_bytes))
 
 
 def hex2byte(given_hex):
-    given_hex = ''.join(given_hex.split())
-    result = []
-    for offset in range(0, len(given_hex), 2):
-        result.append(chr(int(given_hex[offset:offset + 2], 16)))
-
-    return ''.join(result)
+    return b''.join([six.int2byte(int(c, 16)) for c in given_hex.split()])
-- 
2.7.4


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to