diff options
author | Bill Fenner <fenner@gmail.com> | 2019-10-07 09:03:35 -0700 |
---|---|---|
committer | fxlb <devel.fx.lebail@orange.fr> | 2019-11-13 19:34:07 +0100 |
commit | 74e6075a69453cb64418969ae16728e3063a9bae (patch) | |
tree | 8ef1ba781ba798ea5e55716586824992fb6e6a9f /tcpdump.c | |
parent | 866358cc52760b68947ae57b4f75f1e1709700b6 (diff) | |
download | tcpdump-74e6075a69453cb64418969ae16728e3063a9bae.tar.gz |
Do not open an interface if not needed for -d
Diffstat (limited to 'tcpdump.c')
-rw-r--r-- | tcpdump.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -2022,6 +2022,29 @@ main(int argc, char **argv) if (dlt == DLT_LINUX_SLL2) fprintf(stderr, "Warning: interface names might be incorrect\n"); #endif + } else if (dflag && !device) { + int dump_dlt = DLT_EN10MB; + /* + * We're dumping the compiled code without an explicit + * device specification. (If a device is specified, we + * definitely want to open it to use the DLT of that device.) + * Either default to DLT_EN10MB with a warning, or use + * the user-specified value if supplied. + */ + /* + * If no snapshot length was specified, or a length of 0 was + * specified, default to 256KB. + */ + if (ndo->ndo_snaplen == 0) + ndo->ndo_snaplen = MAXIMUM_SNAPLEN; + /* + * If a DLT was specified with the -y flag, use that instead. + */ + if (yflag_dlt != -1) + dump_dlt = yflag_dlt; + else + fprintf(stderr, "Warning: assuming Ethernet\n"); + pd = pcap_open_dead(dump_dlt, ndo->ndo_snaplen); } else { /* * We're doing a live capture. |