diff options
author | YAMAMOTO Takashi <yamamoto@valinux.co.jp> | 2013-08-26 15:34:26 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-08-26 16:49:06 +0900 |
commit | 534f8c7e93bd973a80a551eb9e80b05ba86781aa (patch) | |
tree | 58aa2f4967ae7398d2bbe5b3540439b8210da779 | |
parent | aa6c1e8b8adb2797b25b30d39ad3b84b77ed7495 (diff) |
of12: make OFPDescStats more human readable
- when parsing, remove zero padding.
- stop base64 encoding for json representation because these fields
are ASCII strings per OF spec.
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_2_parser.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index 8de06eed..f606ddd2 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -1118,10 +1118,23 @@ class OFPDescStatsRequest(OFPStatsRequest): body_single_struct=True) class OFPDescStats(ofproto_parser.namedtuple('OFPDescStats', ( 'mfr_desc', 'hw_desc', 'sw_desc', 'serial_num', 'dp_desc'))): + + _TYPE = { + 'ascii': [ + 'mfr_desc', + 'hw_desc', + 'sw_desc', + 'serial_num', + 'dp_desc', + ] + } + @classmethod def parser(cls, buf, offset): desc = struct.unpack_from(ofproto_v1_2.OFP_DESC_STATS_PACK_STR, buf, offset) + desc = list(desc) + desc = map(lambda x: x.rstrip('\0'), desc) stats = cls(*desc) stats._length = ofproto_v1_2.OFP_DESC_STATS_SIZE return stats |