'Populate MAC and IP tables based on incoming packets.
Handles only packets from ports identified as not switch-only.
If a MAC was not seen before, insert it in the MAC table;
otherwise, update table and enry.
If packet has a source IP, update that info for the macEntry (may require
removing the info from antoher entry previously with that IP address).
It does not forward any packets, just extract info from them.'

def _handle_openflow_PacketIn(self, event):

    dpid = event.connection.dpid
    inport = event.port
    packet = event.parsed
    if (not packet.parsed):
        log.warning('%i    %i    ignoring    unparsed    packet', dpid, inport)
        return
    if (packet.type == ethernet.LLDP_TYPE):
        return
    if (not core.openflow_discovery.is_edge_port(dpid, inport)):
        log.debug('%i    %i    ignoring    packetIn    at    switch-only    port', dpid, inport)
        return
    log.debug('PacketIn:    %i    %i    ETH    %s    =>    %s', dpid, inport, str(packet.src), str(packet.dst))
    macEntry = self.getMacEntry(packet.src)
    if (macEntry is None):
        macEntry = MacEntry(dpid, inport, packet.src)
        self.entryByMAC[packet.src] = macEntry
        log.info('Learned    %s', str(macEntry))
        self.raiseEventNoErrors(HostEvent, macEntry, join=True)
    elif (macEntry != (dpid, inport, packet.src)):
        log.info('Learned    %s    moved    to    %i    %i', str(macEntry), dpid, inport)
        if ((time.time() - macEntry.lastTimeSeen) < timeoutSec['entryMove']):
            log.warning('Possible    duplicate:    %s    at    time    %i,    now    (%i    %i),    time    %i', str(macEntry), macEntry.lastTimeSeen, dpid, inport, time.time())
        e = HostEvent(macEntry, move=True, new_dpid=dpid, new_port=inport)
        self.raiseEventNoErrors(e)
        macEntry.dpid = e._new_dpid
        macEntry.inport = e._new_port
    macEntry.refresh()
    (pckt_srcip, hasARP) = self.getSrcIPandARP(packet.next)
    if (pckt_srcip is not None):
        self.updateIPInfo(pckt_srcip, macEntry, hasARP)
    if (self.eat_packets and (packet.dst == self.ping_src_mac)):
        return EventHalt
