editcap: Use the interval start for new file names

When writing files spaced over equal time periods, instead of
using the timestamp in the packet record for a new filename,
use the interval start. This keeps the filenames equally spaced,
and is especially clearer when writing empty files because no
packets occurred in that interval.

Fix #19067
This commit is contained in:
John Thacker 2023-05-24 08:39:11 -04:00
parent 4fb99bb462
commit f409a1cf2c
1 changed files with 5 additions and 2 deletions

View File

@ -1936,10 +1936,13 @@ main(int argc, char *argv[])
ret = WRITE_ERROR;
goto clean_exit;
}
nstime_add(&block_next, &secs_per_block); /* reset for next interval */
g_free(filename);
filename = fileset_get_filename_by_pattern(block_cnt++, rec, fprefix, fsuffix);
/* Use the interval start time for the filename. */
temp_rec = *rec;
temp_rec.ts = block_next;
filename = fileset_get_filename_by_pattern(block_cnt++, &temp_rec, fprefix, fsuffix);
ws_assert(filename);
nstime_add(&block_next, &secs_per_block); /* reset for next interval */
if (verbose)
fprintf(stderr, "Continuing writing in file %s\n", filename);