Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/ofproto/ofproto_v1_0_parser.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_0_parser.py 
b/ryu/ofproto/ofproto_v1_0_parser.py
index 84fba98..e6c94b2 100644
--- a/ryu/ofproto/ofproto_v1_0_parser.py
+++ b/ryu/ofproto/ofproto_v1_0_parser.py
@@ -83,15 +83,22 @@ class OFPPhyPort(ofproto_parser.namedtuple('OFPPhyPort', (
         'port_no', 'hw_addr', 'name', 'config', 'state', 'curr', 'advertised',
         'supported', 'peer'))):
 
-    _JSON_FORMATTER = {'hw_addr': addrconv.plain_text}
+    _JSON_FORMATTER = {
+        'hw_addr': addrconv.plain_text,
+        # XXX OF spec is unclear about the encoding of name.
+        # OVS seems to use UTF-8.
+        # 'name': addrconv.plain_text,
+    }
 
     @classmethod
     def parser(cls, buf, offset):
         port = struct.unpack_from(ofproto_v1_0.OFP_PHY_PORT_PACK_STR,
                                   buf, offset)
-        i = cls._fields.index('hw_addr')
         port = list(port)
+        i = cls._fields.index('hw_addr')
         port[i] = addrconv.mac.bin_to_text(port[i])
+        i = cls._fields.index('name')
+        port[i] = port[i].rstrip('\0')
         return cls(*port)
 
 
-- 
1.8.3.1


------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to