Ejemplo n.º 1
0
void
delay(int usecs)
{
    int	msecs, start;

    msecs = usecs / 1000;
    start = OF_milliseconds();

    while (OF_milliseconds() - start < msecs);
}
Ejemplo n.º 2
0
time_t
time(time_t *tloc)
{
    int secs;

    secs = OF_milliseconds() / 1000;
    if (tloc)
        *tloc = secs;
    return secs;
}
Ejemplo n.º 3
0
/*
 * Receive a packet, including the ether header.
 * Return the total length received (or -1 on error).
 */
ssize_t
netif_get(struct iodesc *desc, void *pkt, size_t maxlen, time_t timo)
{
    struct of_dev *op;
    int tick0, tmo_ms;
    int len;

    op = desc->io_netif->nif_devdata;

#ifdef	NETIF_DEBUG
    printf("netif_get: pkt=0x%x, maxlen=%d, tmo=%d\n",
           pkt, maxlen, timo);
#endif

    tmo_ms = timo * 1000;
    tick0 = OF_milliseconds();

    do {
        len = OF_read(op->handle, pkt, maxlen);
    } while ((len == -2 || len == 0) &&
             ((OF_milliseconds() - tick0) < tmo_ms));

#ifdef	NETIF_DEBUG
    printf("netif_get: received len=%d\n", len);
#endif

    if (len < 12)
        return -1;

#ifdef	NETIF_DEBUG
    {
        struct ether_header *eh = pkt;

        printf("dst: %s ", ether_sprintf(eh->ether_dhost));
        printf("src: %s ", ether_sprintf(eh->ether_shost));
        printf("type: 0x%x\n", eh->ether_type & 0xFFFF);
    }
#endif

    return len;
}
Ejemplo n.º 4
0
/*
 * Shouldn't really be here, but is used solely for networking, so...
 */
time_t
getsecs()
{
    return OF_milliseconds() / 1000;
}