]> The Tcpdump Group git mirrors - libpcap/commitdiff
issue: https://github.com/the-tcpdump-group/libpcap/pull/319
authorMichael Richardson <[email protected]>
Sun, 15 Feb 2015 16:48:46 +0000 (11:48 -0500)
committerMichael Richardson <[email protected]>
Sun, 15 Feb 2015 16:48:46 +0000 (11:48 -0500)
Merge branch 'master' of https://github.com/solofox/libpcap into solofox-master

1  2 
optimize.c
tests/filtertest.c

diff --cc optimize.c
Simple merge
index a36490d4c58efccbc9098a63f6600e412fa2e411,e5ebcb72ad8f732d3f336453b80cc98672e37126..e45db21eabbfd8f78806ac3e7b3bd39e19bf7d25
@@@ -197,7 -192,7 +210,7 @@@ main(int argc, char **argv
        infile = NULL;
        Oflag = 1;
        snaplen = 68;
--  
++
        if ((cp = strrchr(argv[0], '/')) != NULL)
                program_name = cp + 1;
        else
        }
  
        dlt = pcap_datalink_name_to_val(argv[optind]);
 -      if (dlt < 0)
 -              error("invalid data link type %s", argv[optind]);
 -      
 +      if (dlt < 0) {
 +              dlt = (int)strtol(argv[optind], &p, 10);
 +              if (p == argv[optind] || *p != '\0')
 +                      error("invalid data link type %s", argv[optind]);
 +      }
-       
++
        if (infile)
                cmdbuf = read_infile(infile);
        else
  
        if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
                error("%s", pcap_geterr(pd));
++
 +      if (!bpf_validate(fcode.bf_insns, fcode.bf_len))
 +              warn("Filter doesn't pass validation");
++
+ #ifdef BDEBUG
+       // replace line feed with space
+       for (cp = cmdbuf; *cp != '\0'; ++cp) {
+               if (*cp == '\r' || *cp == '\n') {
+                       *cp = ' ';
+               }
+       }
+       // only show machine code if BDEBUG defined, since dflag > 3
+       printf("machine codes for filter: %s\n", cmdbuf);
+ #endif
++
        bpf_dump(&fcode, dflag);
        pcap_close(pd);
        exit(0);