]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-zep.c
CI: Add warning exemptions for Sun C (suncc-5.14) on Solaris 10
[tcpdump] / print-zep.c
index 689de8c784986f0a2c80eb2ef2bc398531c29f4c..20a1e2ae6ddfa50ac08fe7ecd552428250f717e5 100644 (file)
@@ -21,9 +21,7 @@
 
 /* \summary: ZigBee Encapsulation Protocol (ZEP) printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
@@ -32,6 +30,8 @@
 
 #include "extract.h"
 
+#include "ntp.h"
+
 /* From wireshark packet-zep.c:
  *
  ***********************************************************************
  *------------------------------------------------------------
  */
 
-#define     JAN_1970        2208988800U
-
-/* Print timestamp */
-static void zep_print_ts(netdissect_options *ndo, const u_char *p)
-{
-       int32_t i;
-       uint32_t uf;
-       uint32_t f;
-       float ff;
-
-       i = GET_BE_U_4(p);
-       uf = GET_BE_U_4(p + 4);
-       ff = (float) uf;
-       if (ff < 0.0)           /* some compilers are buggy */
-               ff += FMAXINT;
-       ff = (float) (ff / FMAXINT); /* shift radix point by 32 bits */
-       f = (uint32_t) (ff * 1000000000.0);  /* treat fraction as parts per
-                                               billion */
-       ND_PRINT("%u.%09d", i, f);
-
-       /*
-        * print the time in human-readable format.
-        */
-       if (i) {
-               time_t seconds = i - JAN_1970;
-               char time_buf[128];
-
-               ND_DEBUG
-               ND_PRINT(" (%s)",
-                   nd_format_time(time_buf, sizeof (time_buf), "%Y-%m-%d %H:%M:%S",
-                     localtime(&seconds)));
-       }
-}
-
 /*
  * Main function to print packets.
  */
@@ -154,7 +120,12 @@ zep_print(netdissect_options *ndo,
                        else
                                ND_PRINT("LQI %u, ", GET_U_1(bp + 8));
 
-                       zep_print_ts(ndo, bp + 9);
+                       /*
+                        * XXX - why a space rather than a "T"
+                        * between the date and time?
+                        */
+                       p_ntp_time_fmt(ndo, "%Y-%m-%d %H:%M:%S",
+                           (const struct l_fixedpt *)(bp + 9));
                        seq_no = GET_BE_U_4(bp + 17);
                        inner_len = GET_U_1(bp + 31);
                        ND_PRINT(", seq# = %u, inner len = %u",