diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2016-05-10 14:29:33 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-05-13 22:17:46 +0900 |
commit | bea97ae66b49ec912cb69fe201c84c5fc7e0d463 (patch) | |
tree | 3d77979fceb3ec23217e1774ffc53ef9d011819c | |
parent | 33d1023368492196139f1e749a085c363895af10 (diff) |
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 <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/lib/ofctl_utils.py | 12 |
1 files 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) |