mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-01-22 00:52:04 +01:00
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>
This commit is contained in:
parent
33d1023368
commit
bea97ae66b
@ -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)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user