Skip to content

Commit aacc29d

Browse files
committed
Add --time-t-size option to print the size of time_t in bits
Have tests/TESTrun run "./tcpdump --time-t-size and set HAVE_TIME_T_64 key based on that. This will permit to run tests based on time_t size (32-bit or 64-bit).
1 parent 0546e6a commit aacc29d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tcpdump.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ show_remote_devices_and_exit(void)
641641
#define OPTION_COUNT 136
642642
#define OPTION_PRINT_SAMPLING 137
643643
#define OPTION_LENGTHS 138
644+
#define OPTION_TIME_T_SIZE 139
644645

645646
static const struct option longopts[] = {
646647
{ "buffer-size", required_argument, NULL, 'B' },
@@ -682,6 +683,7 @@ static const struct option longopts[] = {
682683
{ "print", no_argument, NULL, OPTION_PRINT },
683684
{ "print-sampling", required_argument, NULL, OPTION_PRINT_SAMPLING },
684685
{ "lengths", no_argument, NULL, OPTION_LENGTHS },
686+
{ "time-t-size", no_argument, NULL, OPTION_TIME_T_SIZE },
685687
{ "version", no_argument, NULL, OPTION_VERSION },
686688
{ NULL, 0, NULL, 0 }
687689
};
@@ -1870,6 +1872,10 @@ main(int argc, char **argv)
18701872
ndo->ndo_lengths = 1;
18711873
break;
18721874

1875+
case OPTION_TIME_T_SIZE:
1876+
printf("%zu\n", sizeof(time_t) * 8);
1877+
return 0;
1878+
18731879
case OPTION_VERSION:
18741880
print_version(stdout);
18751881
exit_tcpdump(S_SUCCESS);

tests/TESTrun

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,17 @@ sub loadconfighash {
390390
printf "$TCPDUMP --fp-type => %s\n", $have_fptype;
391391
$main::confighhash->{$have_fptype} = 1;
392392

393+
# run tcpdump --time-t-size to get the size of size_t in bits
394+
open(TIMETSIZE_PIPE, "$TCPDUMP --time-t-size |") or die("piping tcpdump --time-t-size failed\n");
395+
my $time_t_size = <TIMETSIZE_PIPE>;
396+
close(TIMETSIZE_PIPE);
397+
my $have_time_t_64;
398+
if($time_t_size == "64") {
399+
$have_time_t_64 = "HAVE_TIME_T_64";
400+
}
401+
printf "$TCPDUMP --time-t-size => %s\n", $time_t_size;
402+
$main::confighhash->{$have_time_t_64} = 1;
403+
393404
# and check whether this is OpenBSD, as one test fails in OpenBSD
394405
# due to the sad hellscape of low-numbered DLT_ values, due to
395406
# 12 meaning "OpenBSD loopback" rather than "raw IP" on OpenBSD

0 commit comments

Comments
 (0)