From bf95322fc1ef2d0d7a21cb0e6a9bf01902024859 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 26 Aug 2022 14:58:32 +1000 Subject: 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 --- pcap.c | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'pcap.c') diff --git a/pcap.c b/pcap.c index 64beb34..7a48baf 100644 --- a/pcap.c +++ b/pcap.c @@ -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) { -- cgit v1.2.3