def print_ofpt_stats_request_queue(msg): """ Args: msg: OpenFlow message unpacked by python-openflow """ port_number = dissector.get_phy_port_id(msg.body[0].port_no.value) print('StatReq Type: OFPST_QUEUE: Port_Number: %s Pad: %s Queue_id: %s' % (green(port_number), msg.body[0].pad, msg.body[0].queue_id))
def print_ofpt_packet_out(msg): """ Args: msg: OpenFlow message unpacked by python-openflow """ print('PacketOut: buffer_id: %s in_port: %s actions_len: %s' % (hex(msg.buffer_id.value), green(dissector.get_phy_port_id(msg.in_port.value)), msg.actions_len.value)) if msg.actions_len is not 0: print_actions(msg.actions) print_data(msg.data)
def print_ofp_body(msg): """ Args: msg: OpenFlow message unpacked by python-openflow """ string = ('Body - Cookie: %s Command: %s Idle/Hard Timeouts: ' '%s/%s\nBody - Priority: %s Buffer ID: %s Out Port: %s Flags: %s') command = green(dissector.get_ofp_command(msg.command.value)) flags = green(dissector.get_ofp_flags(msg.flags.value)) out_port = green(dissector.get_phy_port_id(msg.out_port.value)) print(string % (msg.cookie.value, command, msg.idle_timeout, msg.hard_timeout, green(msg.priority), msg.buffer_id.value, out_port, flags))
def print_ofpt_stats_request_flow_aggregate(msg): """ Args: msg: OpenFlow message unpacked by python-openflow """ if msg.body_type == 1: type_name = 'Flow' else: type_name = 'Aggregate' body_type = "%s" % msg.body_type print('StatReq Type: %s(%s)' % (type_name, body_type.split('.')[1])) print_ofp_match(msg.body[0].match) out_port = dissector.get_phy_port_id(msg.body[0].out_port.value) print('StatReq Table_id: %s Pad: %s Out_Port: %s' % (msg.body[0].table_id.value, msg.body[0].pad, out_port))
def print_ofp_action(action): """ Args: action: """ if action.action_type == 0: port = dissector.get_phy_port_id(action.port.value) print('Action - Type: %s Length: %s Port: %s ' 'Max Length: %s' % (green('OUTPUT'), action.length, green(port), action.max_length)) elif action.action_type == 1: print('Action - Type: %s Length: %s VLAN ID: %s Pad: %s' % (green('SetVLANID'), action.length, green(str(action.vlan_id.value)), action.pad2)) elif action.action_type == 2: print('Action - Type: %s Length: %s VLAN PCP: %s Pad: %s' % (green('SetVLANPCP'), action.length, green(str(action.vlan_pcp.value)), action.pad)) elif action.action_type == 3: print('Action - Type: %s Length: %s' % (green('StripVLAN'), action.length)) elif action.action_type == 4: print('Action - Type: %s Length: %s SetDLSrc: %s Pad: %s' % (green('SetDLSrc'), action.length, green(action.dl_src), action.pad)) elif action.action_type == 5: print('Action - Type: %s Length: %s SetDLDst: %s Pad: %s' % (green('SetDLDst'), action.length, green(action.dl_dst), action.pad)) elif action.action_type == 6: print('Action - Type: %s Length: %s SetNWSrc: %s' % (green('SetNWSrc'), action.length, green(action.nw_addr))) elif action.action_type == 7: print('Action - Type: %s Length: %s SetNWDst: %s' % (green('SetNWDst'), action.length, green(action.nw_addr))) elif action.action_type == 8: print('Action - Type: %s Length: %s SetNWTos: %s Pad: %s' % (green('SetNWTos'), action.length, green(action.nw_tos.value), action.pad)) elif action.action_type == 9: print('Action - Type: %s Length: %s SetTPSrc: %s Pad: %s' % (green('SetTPSrc'), action.length, green(action.port_no.value), action.pad)) elif action.action_type == int('a', 16): print('Action - Type: %s Length: %s SetTPDst: %s Pad: %s' % (green('SetTPDst'), action.length, green(action.port_no.value), action.pad)) elif action.action_type == int('b', 16): print(('Action - Type: %s Length: %s Enqueue: %s Pad: %s' ' Queue: %s') % (green('Enqueue'), action.length, green(action.port_no.value), action.pad, green(action.queue_id.value))) elif action.action_type == int('ffff', 16): print('Action - Type: %s Length: %s Vendor: %s' % (green('VENDOR'), action.length, green(action.vendor))) else: print('Unknown Action Type')