diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2022-08-26 14:58:32 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-08-30 19:17:57 +0200 |
commit | bf95322fc1ef2d0d7a21cb0e6a9bf01902024859 (patch) | |
tree | 591d27594b910183c5a42df3b496f06855bf0f41 /pcap.c | |
parent | 63d13902296e39221b16941db4525e0efa8ce218 (diff) | |
download | passt-bf95322fc1ef2d0d7a21cb0e6a9bf01902024859.tar passt-bf95322fc1ef2d0d7a21cb0e6a9bf01902024859.tar.gz passt-bf95322fc1ef2d0d7a21cb0e6a9bf01902024859.tar.bz2 passt-bf95322fc1ef2d0d7a21cb0e6a9bf01902024859.tar.lz passt-bf95322fc1ef2d0d7a21cb0e6a9bf01902024859.tar.xz passt-bf95322fc1ef2d0d7a21cb0e6a9bf01902024859.tar.zst passt-bf95322fc1ef2d0d7a21cb0e6a9bf01902024859.zip |
conf: Make the argument to --pcap option mandatory
The --pcap or -p option can be used with or without an argument. If given,
the argument gives the name of the file to save a packet trace to. If
omitted, we generate a default name in /tmp.
Generating the default name isn't particularly useful though, since making
a suitable name can easily be done by the caller. Remove this feature.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'pcap.c')
-rw-r--r-- | pcap.c | 28 |
1 files changed, 0 insertions, 28 deletions
@@ -31,11 +31,6 @@ #include "util.h" #include "passt.h" -#define PCAP_PREFIX "/tmp/passt_" -#define PCAP_PREFIX_PASTA "/tmp/pasta_" -#define PCAP_ISO8601_FORMAT "%FT%H:%M:%SZ" -#define PCAP_ISO8601_STR "YYYY-MM-ddTHH:mm:ssZ" - #define PCAP_VERSION_MINOR 4 static int pcap_fd = -1; @@ -171,7 +166,6 @@ fail: void pcap_init(struct ctx *c) { int flags = O_WRONLY | O_CREAT | O_TRUNC; - struct timeval tv; if (pcap_fd != -1) return; @@ -179,28 +173,6 @@ void pcap_init(struct ctx *c) if (!*c->pcap) return; - if (*c->pcap == 1) { - char name[] = PCAP_PREFIX PCAP_ISO8601_STR STR(UINT_MAX) - ".pcap"; - struct tm *tm; - - if (c->mode == MODE_PASTA) - memcpy(name, PCAP_PREFIX_PASTA, - sizeof(PCAP_PREFIX_PASTA)); - - gettimeofday(&tv, NULL); - tm = localtime(&tv.tv_sec); - strftime(name + strlen(PCAP_PREFIX), - sizeof(PCAP_ISO8601_STR) - 1, PCAP_ISO8601_FORMAT, tm); - - snprintf(name + strlen(PCAP_PREFIX) + strlen(PCAP_ISO8601_STR), - sizeof(name) - strlen(PCAP_PREFIX) - - strlen(PCAP_ISO8601_STR), - "_%i.pcap", getpid()); - - strncpy(c->pcap, name, PATH_MAX); - } - flags |= c->foreground ? O_CLOEXEC : 0; pcap_fd = open(c->pcap, flags, S_IRUSR | S_IWUSR); if (pcap_fd == -1) { |