{ 0, NULL }
};
+#define MAX_VALID_NS 999999999U
+#define BOGUS_NS_STR "(bogus ns!)"
+
static inline void
-arista_print_date_hms_time(netdissect_options *ndo, uint32_t seconds,
- uint32_t nanoseconds)
+arista_print_date_hms_time(netdissect_options *ndo, const uint32_t seconds,
+ const uint32_t nanoseconds)
{
- time_t ts;
+ const time_t ts = seconds;
char buf[sizeof("-yyyyyyyyyy-mm-dd hh:mm:ss")];
- ts = seconds + (nanoseconds / 1000000000);
- nanoseconds %= 1000000000;
ND_PRINT("%s.%09u",
nd_format_time(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S",
gmtime(&ts)), nanoseconds);
+ if (nanoseconds > MAX_VALID_NS)
+ ND_PRINT(" " BOGUS_NS_STR);
}
int
// TapAgg Header Timestamping
if (subTypeId == ARISTA_SUBTYPE_TIMESTAMP) {
- uint64_t seconds;
+ uint32_t seconds;
uint32_t nanoseconds;
uint8_t ts_timescale = GET_U_1(bp);
bp += 1;
case FORMAT_48BIT:
seconds = GET_BE_U_2(bp);
nanoseconds = GET_BE_U_4(bp + 2);
- seconds += nanoseconds / 1000000000;
- nanoseconds %= 1000000000;
- ND_PRINT("%" PRIu64 ".%09u", seconds, nanoseconds);
+ ND_PRINT("%u.%09u", seconds, nanoseconds);
+ if (nanoseconds > MAX_VALID_NS)
+ ND_PRINT(" " BOGUS_NS_STR);
bytesConsumed += 6;
break;
default: