diff options
author | Chema Gonzalez <chemag@fb.com> | 2020-11-02 13:51:36 -0800 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-01-11 18:01:08 +0000 |
commit | 03baf65ae7cf4fc43d76b82f7d67b3c276fe7cae (patch) | |
tree | 19964f055a5c0e5fdfafb36dd65393a7f6e47653 /editcap.c | |
parent | 0e846106760cddd4e98cc23d21c2c7d3000e584d (diff) |
editcap: add support for epoch timestamps in `-A` and `-B` options
Inspired in https://gitlab.com/wireshark/wireshark/-/merge_requests/1618.
Tested:
Timestamps on file used for comparison:
```
$ tshark -r test/captures/snakeoil-dtls.pcap -T fields -e frame.time_epoch
1150121069.248818000
1150121069.249193000
1150121069.251152000
1150121069.251384000
1150121069.293686000
1150121069.319315000
1150121075.230753000
1150121105.510885000
1150121105.510934000
```
Before:
```
$ ./build/run/editcap -B 1150121069.3 test/captures/snakeoil-dtls.pcap -
editcap: "1150121069.3" isn't a valid date and time
$ ./build/run/editcap -A 1150121069.3 test/captures/snakeoil-dtls.pcap -
editcap: "1150121069.3" isn't a valid date and time
$ ./build/run/editcap -A 1150121069 test/captures/snakeoil-dtls.pcap -
editcap: "1150121069" isn't a valid date and time
$ ./build/run/editcap -B 1150121069 test/captures/snakeoil-dtls.pcap -
editcap: "1150121069" isn't a valid date and time
```
After:
```
$ ./build/run/editcap -A 1150121069.3 test/captures/snakeoil-dtls.pcap - | tshark -r - -T fields -e frame.time_epoch
1150121069.319315000
1150121075.230753000
1150121105.510885000
1150121105.510934000
$ ./build/run/editcap -A 1150121069 test/captures/snakeoil-dtls.pcap - | tshark -r - -T fields -e frame.time_epoch
1150121069.248818000
1150121069.249193000
1150121069.251152000
1150121069.251384000
1150121069.293686000
1150121069.319315000
1150121075.230753000
1150121105.510885000
1150121105.510934000
$ ./build/run/editcap -B 1150121069.3 test/captures/snakeoil-dtls.pcap - | tshark -r - -T fields -e frame.time_epoch
1150121069.248818000
1150121069.249193000
1150121069.251152000
1150121069.251384000
1150121069.293686000
$ ./build/run/editcap -B 1150121069 test/captures/snakeoil-dtls.pcap - | tshark -r - -T fields -e frame.time_epoch
```
Diffstat (limited to 'editcap.c')
-rw-r--r-- | editcap.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -764,6 +764,7 @@ print_usage(FILE *output) fprintf(output, " given time.\n"); fprintf(output, " Time format for -A/-B options is\n"); fprintf(output, " YYYY-MM-DDThh:mm:ss[.nnnnnnnnn][Z|+-hh:mm]\n"); + fprintf(output, " Unix epoch timestamps are also supported.\n"); fprintf(output, "\n"); fprintf(output, "Duplicate packet removal:\n"); fprintf(output, " --novlan remove vlan info from packets before checking for duplicates.\n"); @@ -1284,7 +1285,7 @@ main(int argc, char *argv[]) nstime_t in_time; check_startstop = TRUE; - if (0 < iso8601_to_nstime(&in_time, optarg)) { + if ((0 < iso8601_to_nstime(&in_time, optarg)) || (0 < unix_epoch_to_nstime(&in_time, optarg))) { if (opt == 'A') { nstime_copy(&starttime, &in_time); have_starttime = TRUE; |