summaryrefslogtreecommitdiff
path: root/tcpdump.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2020-02-04 19:08:10 -0800
committerGuy Harris <guy@alum.mit.edu>2020-02-04 19:08:10 -0800
commit92e3315c9ff248778c825015ac16553d4b8b4f7f (patch)
treea6d3afea20df92e79a9ccde4318794d1070af514 /tcpdump.c
parent895e3dfd766bd2858e1514ec21554c22de587149 (diff)
downloadtcpdump-92e3315c9ff248778c825015ac16553d4b8b4f7f.tar.gz
Do some tests based on the type of floating-point arithmetic tcpdump does.
Add a --fp-type flag to tcpdump, which causes it to do a floating-point operation and, based on the result of the operation, prints out "FPTYPE{n}", where {n} is a number indicating the result. Have tests/TESTrun run "./tcpdump --fp-type" and set a HAVE_ key based on that. Run some tests only for FPTYPE1.
Diffstat (limited to 'tcpdump.c')
-rw-r--r--tcpdump.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tcpdump.c b/tcpdump.c
index 64aad160..40505b2c 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -150,6 +150,8 @@ The Regents of the University of California. All rights reserved.\n";
#include "print.h"
+#include "fptype.h"
+
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
@@ -687,6 +689,7 @@ show_remote_devices_and_exit(void)
#define OPTION_LIST_REMOTE_INTERFACES 132
#define OPTION_TSTAMP_MICRO 133
#define OPTION_TSTAMP_NANO 134
+#define OPTION_FP_TYPE 135
static const struct option longopts[] = {
#if defined(HAVE_PCAP_CREATE) || defined(_WIN32)
@@ -730,6 +733,7 @@ static const struct option longopts[] = {
{ "debug-filter-parser", no_argument, NULL, 'Y' },
#endif
{ "relinquish-privileges", required_argument, NULL, 'Z' },
+ { "fp-type", no_argument, NULL, OPTION_FP_TYPE },
{ "number", no_argument, NULL, '#' },
{ "print", no_argument, NULL, OPTION_PRINT },
{ "version", no_argument, NULL, OPTION_VERSION },
@@ -1891,6 +1895,26 @@ main(int argc, char **argv)
break;
#endif
+ case OPTION_FP_TYPE:
+ /*
+ * Print out the type of floating-point arithmetic
+ * we're doing; it's probably IEEE, unless somebody
+ * tries to run this on a VAX, but the precision
+ * may differ (e.g., it might be 32-bit, 64-bit,
+ * or 80-bit).
+ */
+ switch (float_type_check(0x4e93312d)) {
+
+ case 0x461a5794:
+ printf("FPTYPE1\n");
+ break;
+
+ default:
+ printf("FPTYPE2\n");
+ break;
+ }
+ return 0;
+
default:
print_usage();
exit_tcpdump(S_ERR_HOST_PROGRAM);