From bea97ae66b49ec912cb69fe201c84c5fc7e0d463 Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Tue, 10 May 2016 14:29:33 +0900 Subject: [PATCH] ofctl_utils: Confirm binary type data in send_experimenter In Python 3, the data field in OFPExperimenter must be a binary type value, but when data_type='ascii', ofctl_utils may get it as a str type value. This patch confirms the data field is a binary type value. Signed-off-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori --- ryu/lib/ofctl_utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ryu/lib/ofctl_utils.py b/ryu/lib/ofctl_utils.py index 3d1b6bf0..b5fbc9b8 100644 --- a/ryu/lib/ofctl_utils.py +++ b/ryu/lib/ofctl_utils.py @@ -184,15 +184,17 @@ def send_experimenter(dp, exp, logger=None): exp_type = exp.get('exp_type', 0) data_type = exp.get('data_type', 'ascii') - if data_type not in ('ascii', 'base64'): - LOG.error('Unknown data type: %s', data_type) - data = exp.get('data', '') if data_type == 'base64': data = base64.b64decode(data) + elif data_type == 'ascii': + data = data.encode('ascii') + else: + get_logger(logger).error('Unknown data type: %s', data_type) + return - expmsg = dp.ofproto_parser.OFPExperimenter(dp, experimenter, exp_type, - data) + expmsg = dp.ofproto_parser.OFPExperimenter( + dp, experimenter, exp_type, data) send_msg(dp, expmsg, logger)