Date: Thu, 8 Feb 2007 16:34:48 GMT From: "Christian S.J. Peron" <csjp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 114242 for review Message-ID: <200702081634.l18GYm9X043894@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=114242 Change 114242 by csjp@csjp_rnd01 on 2007/02/08 16:34:38 Clean up packet access options Affected files ... .. //depot/projects/zcopybpf/utils/bpfnull/bpfnull.c#12 edit Differences ... ==== //depot/projects/zcopybpf/utils/bpfnull/bpfnull.c#12 (text+ko) ==== @@ -95,6 +95,8 @@ u_char *b,*bp, *ep, *p, by; #define bhp ((struct bpf_hdr *)bp) + if (!wflag && !tflag && !Tflag) + return; b = bp = bz->bz_bufa; ep = bp + bz->bz_buflen; while (bp < ep) { @@ -114,13 +116,15 @@ bp += BPF_WORDALIGN(clen + hlen); continue; } - pcap_dump((u_char *)dp, &phd, p); - if (ferror((FILE *)dp)) { - perror("dump.pcap"); - exit(1); + if (wflag) { + pcap_dump((u_char *)dp, &phd, p); + if (ferror((FILE *)dp)) { + perror("dump.pcap"); + exit(1); + } + fflush((FILE *)dp); + bp += BPF_WORDALIGN(clen + hlen); } - fflush((FILE *)dp); - bp += BPF_WORDALIGN(clen + hlen); } } @@ -160,8 +164,7 @@ err(1, "read failed"); bz.bz_bufa = pbuf; bz.bz_buflen = n; - if (wflag) - bpf_process_packets(&bz, "W"); + bpf_process_packets(&bz, "W"); } else { processed_data = 0; bzha = (struct bpf_zbuf_header *)bufa; @@ -179,16 +182,14 @@ bz.bz_bufa = bufa; bz.bz_bufa += sizeof(struct bpf_zbuf_header); bz.bz_buflen = bzha->bzh_kernel_len; - if (wflag) - bpf_process_packets(&bz, "A"); + bpf_process_packets(&bz, "A"); bzha->bzh_user_gen++; processed_data++; } else if (bzhb->bzh_kernel_gen > bzhb->bzh_user_gen) { bz.bz_bufa = bufb; bz.bz_bufa += sizeof(struct bpf_zbuf_header); bz.bz_buflen = bzhb->bzh_kernel_len; - if (wflag) - bpf_process_packets(&bz, "B"); + bpf_process_packets(&bz, "B"); bzhb->bzh_user_gen++; processed_data++; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702081634.l18GYm9X043894>