def dict_to_packet_out(d):
 po = of.ofp_packet_out()
 po.buffer_id = d.get('buffer_id', (-1))
 po.in_port = _fix_of_int(d.get('in_port', of.OFPP_NONE))
 actions = d.get('actions', [])
 actions = [dict_to_action(a) for a in actions]
 po.actions = actions
 if ('output' in d):
  a = of.ofp_action_output(port=_fix_of_int(d['output']))
  po.actions.append(a)
 if ('data' in d):
  data = dict_to_packet(d['data'])
  if hasattr(data, 'pack'):
   data = data.pack()
  po.data = data
 return po

def dict_to_packet_out ( d ) : po = of . ofp_packet_out ( ) po . buffer_id = d . get ( 'buffer_id' , ( - 1 ) ) po . in_port = _fix_of_int ( d . get ( 'in_port' , of . OFPP_NONE ) ) actions = d . get ( 'actions' , [ ] ) actions = [ dict_to_action ( a ) for a in actions ] po . actions = actions if ( 'output' in d ) : a = of . ofp_action_output ( port = _fix_of_int ( d [ 'output' ] ) ) po . actions . append ( a ) if ( 'data' in d ) : data = dict_to_packet ( d [ 'data' ] ) if hasattr ( data , 'pack' ) : data = data . pack ( ) po . data = data return po
converts dict to packet_out also .