]> The Tcpdump Group git mirrors - libpcap/commitdiff
More descriptive name for bpf_filter1().
authorGuy Harris <[email protected]>
Wed, 5 Nov 2014 19:18:51 +0000 (11:18 -0800)
committerGuy Harris <[email protected]>
Wed, 5 Nov 2014 19:18:51 +0000 (11:18 -0800)
Call it bpf_filter_with_aux_data(), to better indicate what it does.

Also expand some comments and clean up white space a bit.

bpf/net/bpf_filter.c
pcap-linux.c
pcap/bpf.h

index 2c6e51099ad2ff491f8957f7b7047a00cba5accc..47e91ced50c9a5c8d8ce025ac9f1f5c139e0a697 100644 (file)
@@ -210,11 +210,14 @@ enum {
  * Execute the filter program starting at pc on the packet p
  * wirelen is the length of the original packet
  * buflen is the amount of data present
+ * aux_data is auxiliary data, currently used only when interpreting
+ * filters intended for the Linux kernel in cases where the kernel
+ * rejects the filter; it contains VLAN tag information
  * For the kernel, p is assumed to be a pointer to an mbuf if buflen is 0,
  * in all other cases, p is a pointer to a buffer and buflen is its size.
  */
 u_int
-bpf_filter1(pc, p, wirelen, buflen, aux_data)
+bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data)
        register const struct bpf_insn *pc;
        register const u_char *p;
        u_int wirelen;
@@ -594,7 +597,7 @@ bpf_filter(pc, p, wirelen, buflen)
        u_int wirelen;
        register u_int buflen;
 {
-       return bpf_filter1(pc, p, wirelen, buflen, NULL);
+       return bpf_filter_with_aux_data(pc, p, wirelen, buflen, NULL);
 }
 
 
index 101ad942407358322baa4fa47c4a53ff57b3f823..2f092b7f85bc8bb66aff005b9855bc47694ed58f 100644 (file)
@@ -1717,9 +1717,8 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
 
        /* Run the packet filter if not using kernel filter */
        if (handlep->filter_in_userland && handle->fcode.bf_insns) {
-               if (bpf_filter1(handle->fcode.bf_insns, bp,
-                               packet_len, caplen, &aux_data) == 0)
-               {
+               if (bpf_filter_with_aux_data(handle->fcode.bf_insns, bp,
+                   packet_len, caplen, &aux_data) == 0) {
                        /* rejected by filter */
                        return 0;
                }
@@ -4232,14 +4231,15 @@ static int pcap_handle_packet_mmap(
         * happen a lot later... */
        bp = frame + tp_mac;
        if (handlep->filter_in_userland && handle->fcode.bf_insns) {
-                struct bpf_aux_data aux_data;
+               struct bpf_aux_data aux_data;
 
-                aux_data.vlan_tag = tp_vlan_tci & 0x0fff;
-                aux_data.vlan_tag_present = tp_vlan_tci_valid;
+               aux_data.vlan_tag = tp_vlan_tci & 0x0fff;
+               aux_data.vlan_tag_present = tp_vlan_tci_valid;
 
-                if (bpf_filter1(handle->fcode.bf_insns, bp, tp_len, tp_snaplen, &aux_data) == 0)
-                        return 0;
-        }
+               if (bpf_filter_with_aux_data(handle->fcode.bf_insns, bp,
+                   tp_len, tp_snaplen, &aux_data) == 0)
+                       return 0;
+       }
 
        sll = (void *)frame + TPACKET_ALIGN(handlep->tp_hdrlen);
        if (!linux_check_direction(handle, sll))
index cf7478b1a12b5b660fd9c3ef21a97ebefb1904e6..5084d065e4c7f6aaf228fbf0814f94290577c529 100644 (file)
@@ -1472,6 +1472,11 @@ struct bpf_insn {
        bpf_u_int32 k;
 };
 
+/*
+ * Auxiliary data, for use when interpreting a filter intended for the
+ * Linux kernel when the kernel rejects the filter (requiring us to
+ * run it in userland).  It contains VLAN tag information.
+ */
 struct bpf_aux_data {
         uint16_t vlan_tag_present;
         uint16_t vlan_tag;
@@ -1486,7 +1491,7 @@ struct bpf_aux_data {
 #if __STDC__ || defined(__cplusplus)
 extern int bpf_validate(const struct bpf_insn *, int);
 extern u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
-extern u_int bpf_filter1(const struct bpf_insn *, const u_char *, u_int, u_int, const struct bpf_aux_data *);        
+extern u_int bpf_filter_with_aux_data(const struct bpf_insn *, const u_char *, u_int, u_int, const struct bpf_aux_data *);        
 #else
 extern int bpf_validate();
 extern u_int bpf_filter();