|
57 | 57 | #define CYCLE_SIZE ((uint64_t)1 << 32) |
58 | 58 |
|
59 | 59 | #define IMPLEMENTED_GN_HEADER_TYPES_NUM 2 |
60 | | -const u_int implemented_gn_header_types[IMPLEMENTED_GN_HEADER_TYPES_NUM] = { |
| 60 | +static const u_int implemented_gn_header_types[IMPLEMENTED_GN_HEADER_TYPES_NUM] = { |
61 | 61 | HT_BEACON, |
62 | 62 | HT_TSB |
63 | 63 | }; |
@@ -324,30 +324,24 @@ static const char* process_gn_addr(netdissect_options *ndo, u_int64_t gn_addr){ |
324 | 324 |
|
325 | 325 |
|
326 | 326 | static const char* process_tst(uint32_t tst) { |
327 | | - static char buffer[32]; |
| 327 | + static char buffer[80]; |
328 | 328 |
|
329 | | - // Get current UTC time in milliseconds |
330 | 329 | struct timespec now; |
331 | 330 | clock_gettime(CLOCK_REALTIME, &now); |
332 | 331 | uint64_t ref_utc_ms = (uint64_t)now.tv_sec * 1000 + now.tv_nsec / 1000000; |
333 | 332 |
|
334 | | - // Compute number of cycles |
335 | 333 | uint64_t adjusted_timestamp = ref_utc_ms - ITS_EPOCH_MS; |
336 | 334 | uint64_t number_of_cycles = adjusted_timestamp / CYCLE_SIZE; |
337 | 335 |
|
338 | | - // Compute transformed timestamp |
339 | 336 | uint64_t transformed_timestamp = tst + CYCLE_SIZE * number_of_cycles + ITS_EPOCH_MS; |
340 | 337 |
|
341 | | - // Correct if transformed_timestamp is in the future |
342 | 338 | if (transformed_timestamp > ref_utc_ms) { |
343 | 339 | transformed_timestamp = tst + CYCLE_SIZE * (number_of_cycles - 1) + ITS_EPOCH_MS; |
344 | 340 | } |
345 | 341 |
|
346 | | - // Split into seconds and milliseconds |
347 | 342 | time_t abs_time = transformed_timestamp / 1000; |
348 | 343 | uint32_t milliseconds = transformed_timestamp % 1000; |
349 | 344 |
|
350 | | - // Convert to UTC |
351 | 345 | struct tm *timeinfo = gmtime(&abs_time); |
352 | 346 | if (!timeinfo) { |
353 | 347 | snprintf(buffer, sizeof(buffer), "Invalid time"); |
|
0 commit comments