diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2018-12-02 19:21:34 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2018-12-02 19:21:34 +0100 |
commit | b3e5932e779c08d4b802a470f02358fe1f08fd7d (patch) | |
tree | 1dfa66b2a51b96cf15153409aed3e9556ea4b755 | |
parent | e479e78e9e4408a19c16e5622ca4f66363005981 (diff) |
netsniff-ng: store default prefix in ctx
Store the default "dump-" prefix in ctx->prefix instead of checking it
every time in generate_multi_pcap_filename.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r-- | netsniff-ng.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/netsniff-ng.c b/netsniff-ng.c index 1a74d91..81e49d1 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -784,7 +784,7 @@ static void generate_multi_pcap_filename(struct ctx *ctx, char *fname, size_t si { if (ctx->overwrite_interval > 0) { slprintf(fname, size, "%s/%s%010lu.pcap", ctx->device_out, - ctx->prefix ? : "dump-", ctx->file_number); + ctx->prefix, ctx->file_number); ctx->file_number++; @@ -792,7 +792,7 @@ static void generate_multi_pcap_filename(struct ctx *ctx, char *fname, size_t si ctx->file_number = 0; } else { slprintf(fname, size, "%s/%s%lu.pcap", ctx->device_out, - ctx->prefix ? : "dump-", ftime); + ctx->prefix, ftime); } } @@ -1577,6 +1577,9 @@ int main(int argc, char **argv) if (!strcmp(ctx.device_in, "any") || !strcmp(ctx.device_in, "lo")) ctx.lo_ifindex = device_ifindex("lo"); + if (!ctx.prefix) + ctx.prefix = xstrdup("dump-"); + register_signal(SIGINT, signal_handler); register_signal(SIGQUIT, signal_handler); register_signal(SIGTERM, signal_handler); |