wrcsr(0, 0x48)

logging.info('DHCP discovery packet sent')

# Now wait 2 seconds for a DHCP offer to be received.
logging.debug('Waiting 2 seconds for an offer to be received')
time.sleep(2)

stop()

busdma.sync_range(dmamem, busdma.SYNC_PREWRITE, addr_rxdesc - cpuaddr,
                  ctypes.sizeof(bufdesc) * nrxbufs)

for i in xrange(nrxbufs):
    bd = bufdesc.from_address(addr_rxdesc + ctypes.sizeof(bufdesc) * i)
    if (bd.flags & 0x80000000):
        continue
    pkt = packet.from_address(addr_rxbufs + i * bufsize)
    if mac_is(pkt.eth_dest, bcast):
        logging.debug('RX #%d: broadcast packet: length %u' % (i, bd.length))
        continue
    if not mac_is(pkt.eth_dest, mac):
        logging.debug('RX #%d: packet for %s?' % (i, mac_str(pkt.eth_dest)))
        continue
    logging.debug('RX %d: packet from %s!' % (i, mac_str(pkt.eth_src)))
    logging.info('Our IP address = %s' % (ip_str(pkt.ip_dest)))

busdma.mem_free(dmamem)
busdma.tag_destroy(mem_tag)
bus.unmap(io)
Beispiel #2
0
wrcsr(0, 0x48)

logging.info('DHCP discovery packet sent')

# Now wait 2 seconds for a DHCP offer to be received.
logging.debug('Waiting 2 seconds for an offer to be received')
time.sleep(2)

stop()

busdma.sync_range(dmamem, busdma.SYNC_PREWRITE, addr_rxdesc - cpuaddr,
                  ctypes.sizeof(bufdesc) * nrxbufs)

for i in xrange(nrxbufs):
    bd = bufdesc.from_address(addr_rxdesc + ctypes.sizeof(bufdesc) * i)
    if (bd.flags & 0x80000000):
        continue
    pkt = packet.from_address(addr_rxbufs + i * bufsize)
    if mac_is(pkt.eth_dest, bcast):
        logging.debug('RX #%d: broadcast packet: length %u' % (i, bd.length))
        continue
    if not mac_is(pkt.eth_dest, mac):
        logging.debug('RX #%d: packet for %s?' % (i, mac_str(pkt.eth_dest)))
        continue
    logging.debug('RX %d: packet from %s!' % (i, mac_str(pkt.eth_src)))
    logging.info('Our IP address = %s' % (ip_str(pkt.ip_dest)))

busdma.mem_free(dmamem)
busdma.tag_destroy(mem_tag)
bus.unmap(io)