--- libaitio/example/bpf.c 2013/06/26 12:27:40 1.1.2.9 +++ libaitio/example/bpf.c 2013/06/26 13:33:55 1.1.2.10 @@ -78,16 +78,9 @@ ShowPkt(void *buffer) assert(buffer); -#ifdef __FreeBSD__ - bpf = (struct bpf_hdr*) (buffer + (flg ? sizeof(struct bpf_zbuf_header) : 0)); - snprintf(szLine, BUFSIZ, "#Packet length: %d/%d\n>>> Ethernet ...\n", flg ? bzh->bzh_kernel_len : bpf->bh_datalen, bpf->bh_datalen); - strlcat(szShow, szLine, USHRT_MAX); - eth = (struct ether_header *) (buffer + (flg ? sizeof(struct bpf_zbuf_header) : 0) + bpf->bh_hdrlen); -#else snprintf(szLine, BUFSIZ, "#Packet length: %d\n>>> Ethernet ...\n", bpf->bh_datalen); strlcat(szShow, szLine, USHRT_MAX); eth = (struct ether_header *) (buffer + bpf->bh_hdrlen); -#endif switch (ntohs(eth->ether_type)) { case ETHERTYPE_ARP: @@ -342,10 +335,12 @@ main(int argc, char **argv) if (mode == 'R') { pfd.events = POLLIN; for (i = 0; i < count; i++) { - if (poll(&pfd, 1, -1) == -1) + if ((ret = poll(&pfd, 1, -1)) == -1) break; ret = io_etherRecv(dev, buffer, siz, bz); + if (!ret) + continue; if (ret == -1) printf("%d) io_etherRecv(%d) #%d - %s\n", i, ret, io_GetErrno(), io_GetError());