[email protected]
[Top] [All Lists]

PERFORCE change 114242 for review

Subject: PERFORCE change 114242 for review
From: "Christian S.J. Peron"
Date: Thu, 8 Feb 2007 16:34:48 GMT
http://perforce.freebsd.org/chv.cgi?CH=114242

Change 114242 by [email protected]_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++;
                        }
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/p4-projects
To unsubscribe, send any mail to "[email protected]"

<Prev in Thread] Current Thread [Next in Thread>
  • PERFORCE change 114242 for review, Christian S.J. Peron <=