#NEWLINE# def _handle_dhcp_request( self , msg , pkt , lport ) : #NEWLINE# #INDENT# packet = ryu_packet . Packet ( data = msg . data ) #NEWLINE# in_port = msg . match . get ( 'in_port' ) #NEWLINE# if isinstance ( packet [ 3 ] , str ) : #NEWLINE# #INDENT# dhcp_packet = dhcp . dhcp . parser ( packet [ 3 ] ) [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dhcp_packet = packet [ 3 ] #NEWLINE# #UNINDENT# dhcp_message_type = self . _get_dhcp_message_type_opt ( dhcp_packet ) #NEWLINE# send_packet = None #NEWLINE# if ( dhcp_message_type == DHCP_DISCOVER ) : #NEWLINE# #INDENT# send_packet = self . _create_dhcp_offer ( pkt , dhcp_packet , lport ) #NEWLINE# LOG . info ( ( _LI ( 'sending DHCP offer for port IP %(port_ip)s port id %(port_id)s' ) % { #NEWLINE# #INDENT# 'port_ip' : lport . get_ip ( ) , #NEWLINE# 'port_id' : lport . get_id ( ) , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( dhcp_message_type == DHCP_REQUEST ) : #NEWLINE# #INDENT# send_packet = self . _create_dhcp_ack ( pkt , dhcp_packet , lport ) #NEWLINE# LOG . info ( ( _LI ( 'sending DHCP ACK for port IP %(port_ip)s port id %(tunnel_id)s' ) % { #NEWLINE# #INDENT# 'port_ip' : lport . get_ip ( ) , #NEWLINE# 'tunnel_id' : lport . get_id ( ) , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# LOG . error ( _LE ( 'DHCP message type %d not handled' ) , dhcp_message_type ) #NEWLINE# #UNINDENT# #UNINDENT# if send_packet : #NEWLINE# #INDENT# self . _send_packet ( self . get_datapath ( ) , in_port , send_packet )