#NEWLINE# def _get_send_port_ip( self , header_list ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# src_mac = header_list [ ETHERNET ] . src #NEWLINE# if ( IPV4 in header_list ) : #NEWLINE# #INDENT# src_ip = header_list [ IPV4 ] . src #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# src_ip = header_list [ ARP ] . src_ip #NEWLINE# #UNINDENT# #UNINDENT# except KeyError : #NEWLINE# #INDENT# self . logger . debug ( 'Receive unsupported packet.' , extra = self . sw_id ) #NEWLINE# return None #NEWLINE# #UNINDENT# address = self . address_data . get_data ( ip = src_ip ) #NEWLINE# if ( address is not None ) : #NEWLINE# #INDENT# return address . default_gw #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# route = self . routing_tbl . get_data ( gw_mac = src_mac ) #NEWLINE# if ( route is not None ) : #NEWLINE# #INDENT# address = self . address_data . get_data ( ip = route . gateway_ip ) #NEWLINE# if ( address is not None ) : #NEWLINE# #INDENT# return address . default_gw #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . logger . debug ( 'Receive packet from unknown IP[%s].' , ip_addr_ntoa ( header_list ) , extra = self . sw_id ) #NEWLINE# return None