Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST ONLY] NTP: test a p_ntp_time_fmt() update #1164

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

#include "extract.h"

#define JAN_1970 INT64_T_CONSTANT(2208988800) /* 1970 - 1900 in seconds */
#define DIFF_1970_1900 INT64_T_CONSTANT(2208988800) /* 1970 - 1900 in seconds */
/* RFC4330 - 3. NTP Timestamp Format - 6h 28m 16s UTC on 7 February 2036 */
#define DIFF_2036_1970 INT64_T_CONSTANT(2085978496) /* 2036 - 1970 in seconds */

void
p_ntp_time_fmt(netdissect_options *ndo, const char *fmt,
Expand All @@ -50,11 +52,15 @@ p_ntp_time_fmt(netdissect_options *ndo, const char *fmt,
* print the UTC time in human-readable format.
*/
if (i) {
int64_t seconds_64bit = (int64_t)i - JAN_1970;
int64_t seconds_64bit;
time_t seconds;
char time_buf[128];
const char *time_string;

if ((i & 0x80000000) != 0)
seconds_64bit = (int64_t)i - DIFF_1970_1900;
else
seconds_64bit = (int64_t)i + DIFF_2036_1970;
seconds = (time_t)seconds_64bit;
if (seconds != seconds_64bit) {
/*
Expand Down
30 changes: 15 additions & 15 deletions tests/lspping-fec-ldp-v.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 1
TimeStamp Sent: 1087208228.000027564 (1934-06-15T10:17:08Z)
TimeStamp Sent: 1087208228.000027564 (2070-07-21T16:45:24Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -22,8 +22,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 1
TimeStamp Sent: 1087208228.000027564 (1934-06-15T10:17:08Z)
TimeStamp Received: 1087208228.000027928 (1934-06-15T10:17:08Z)
TimeStamp Sent: 1087208228.000027564 (2070-07-21T16:45:24Z)
TimeStamp Received: 1087208228.000027928 (2070-07-21T16:45:24Z)
4 2004-06-14 10:17:08.878375 MPLS (label 100704, tc 6, [S], ttl 64)
IP (tos 0xc0, ttl 64, id 40725, offset 0, flags [none], proto TCP (6), length 71)
12.4.4.4.2006 > 12.1.1.1.179: Flags [P.], cksum 0x6c0d (correct), seq 399708866:399708885, ack 708613212, win 16384, options [nop,nop,TS val 84784455 ecr 130411], length 19: BGP
Expand All @@ -39,7 +39,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 2
TimeStamp Sent: 1087208229.000029880 (1934-06-15T10:17:09Z)
TimeStamp Sent: 1087208229.000029880 (2070-07-21T16:45:25Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -51,8 +51,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 2
TimeStamp Sent: 1087208229.000029880 (1934-06-15T10:17:09Z)
TimeStamp Received: 1087208229.000030186 (1934-06-15T10:17:09Z)
TimeStamp Sent: 1087208229.000029880 (2070-07-21T16:45:25Z)
TimeStamp Received: 1087208229.000030186 (2070-07-21T16:45:25Z)
8 2004-06-14 10:17:10.128607 MPLS (label 100688, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40729, offset 0, flags [none], proto UDP (17), length 76)
12.4.4.4.4786 > 127.0.0.1.3503:
Expand All @@ -61,7 +61,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 3
TimeStamp Sent: 1087208230.000029928 (1934-06-15T10:17:10Z)
TimeStamp Sent: 1087208230.000029928 (2070-07-21T16:45:26Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -73,8 +73,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 3
TimeStamp Sent: 1087208230.000029928 (1934-06-15T10:17:10Z)
TimeStamp Received: 1087208230.000030250 (1934-06-15T10:17:10Z)
TimeStamp Sent: 1087208230.000029928 (2070-07-21T16:45:26Z)
TimeStamp Received: 1087208230.000030250 (2070-07-21T16:45:26Z)
10 2004-06-14 10:17:11.128577 MPLS (label 100688, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40731, offset 0, flags [none], proto UDP (17), length 76)
12.4.4.4.4786 > 127.0.0.1.3503:
Expand All @@ -83,7 +83,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 4
TimeStamp Sent: 1087208231.000029918 (1934-06-15T10:17:11Z)
TimeStamp Sent: 1087208231.000029918 (2070-07-21T16:45:27Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -95,8 +95,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 4
TimeStamp Sent: 1087208231.000029918 (1934-06-15T10:17:11Z)
TimeStamp Received: 1087208231.000030237 (1934-06-15T10:17:11Z)
TimeStamp Sent: 1087208231.000029918 (2070-07-21T16:45:27Z)
TimeStamp Received: 1087208231.000030237 (2070-07-21T16:45:27Z)
12 2004-06-14 10:17:12.128655 MPLS (label 100688, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40733, offset 0, flags [none], proto UDP (17), length 76)
12.4.4.4.4786 > 127.0.0.1.3503:
Expand All @@ -105,7 +105,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 5
TimeStamp Sent: 1087208232.000029937 (1934-06-15T10:17:12Z)
TimeStamp Sent: 1087208232.000029937 (2070-07-21T16:45:28Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -117,5 +117,5 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 5
TimeStamp Sent: 1087208232.000029937 (1934-06-15T10:17:12Z)
TimeStamp Received: 1087208232.000030273 (1934-06-15T10:17:12Z)
TimeStamp Sent: 1087208232.000029937 (2070-07-21T16:45:28Z)
TimeStamp Received: 1087208232.000030273 (2070-07-21T16:45:28Z)
30 changes: 15 additions & 15 deletions tests/lspping-fec-ldp-vv.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 1
TimeStamp Sent: 1087208228.000027564 (1934-06-15T10:17:08Z)
TimeStamp Sent: 1087208228.000027564 (2070-07-21T16:45:24Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -24,8 +24,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 1
TimeStamp Sent: 1087208228.000027564 (1934-06-15T10:17:08Z)
TimeStamp Received: 1087208228.000027928 (1934-06-15T10:17:08Z)
TimeStamp Sent: 1087208228.000027564 (2070-07-21T16:45:24Z)
TimeStamp Received: 1087208228.000027928 (2070-07-21T16:45:24Z)
4 2004-06-14 10:17:08.878375 MPLS (label 100704, tc 6, [S], ttl 64)
IP (tos 0xc0, ttl 64, id 40725, offset 0, flags [none], proto TCP (6), length 71)
12.4.4.4.2006 > 12.1.1.1.179: Flags [P.], cksum 0x6c0d (correct), seq 399708866:399708885, ack 708613212, win 16384, options [nop,nop,TS val 84784455 ecr 130411], length 19: BGP
Expand All @@ -41,7 +41,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 2
TimeStamp Sent: 1087208229.000029880 (1934-06-15T10:17:09Z)
TimeStamp Sent: 1087208229.000029880 (2070-07-21T16:45:25Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -55,8 +55,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 2
TimeStamp Sent: 1087208229.000029880 (1934-06-15T10:17:09Z)
TimeStamp Received: 1087208229.000030186 (1934-06-15T10:17:09Z)
TimeStamp Sent: 1087208229.000029880 (2070-07-21T16:45:25Z)
TimeStamp Received: 1087208229.000030186 (2070-07-21T16:45:25Z)
8 2004-06-14 10:17:10.128607 MPLS (label 100688, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40729, offset 0, flags [none], proto UDP (17), length 76)
12.4.4.4.4786 > 127.0.0.1.3503: [udp sum ok]
Expand All @@ -65,7 +65,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 3
TimeStamp Sent: 1087208230.000029928 (1934-06-15T10:17:10Z)
TimeStamp Sent: 1087208230.000029928 (2070-07-21T16:45:26Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -79,8 +79,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 3
TimeStamp Sent: 1087208230.000029928 (1934-06-15T10:17:10Z)
TimeStamp Received: 1087208230.000030250 (1934-06-15T10:17:10Z)
TimeStamp Sent: 1087208230.000029928 (2070-07-21T16:45:26Z)
TimeStamp Received: 1087208230.000030250 (2070-07-21T16:45:26Z)
10 2004-06-14 10:17:11.128577 MPLS (label 100688, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40731, offset 0, flags [none], proto UDP (17), length 76)
12.4.4.4.4786 > 127.0.0.1.3503: [udp sum ok]
Expand All @@ -89,7 +89,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 4
TimeStamp Sent: 1087208231.000029918 (1934-06-15T10:17:11Z)
TimeStamp Sent: 1087208231.000029918 (2070-07-21T16:45:27Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -103,8 +103,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 4
TimeStamp Sent: 1087208231.000029918 (1934-06-15T10:17:11Z)
TimeStamp Received: 1087208231.000030237 (1934-06-15T10:17:11Z)
TimeStamp Sent: 1087208231.000029918 (2070-07-21T16:45:27Z)
TimeStamp Received: 1087208231.000030237 (2070-07-21T16:45:27Z)
12 2004-06-14 10:17:12.128655 MPLS (label 100688, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40733, offset 0, flags [none], proto UDP (17), length 76)
12.4.4.4.4786 > 127.0.0.1.3503: [udp sum ok]
Expand All @@ -113,7 +113,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 5
TimeStamp Sent: 1087208232.000029937 (1934-06-15T10:17:12Z)
TimeStamp Sent: 1087208232.000029937 (2070-07-21T16:45:28Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 12
LDP IPv4 prefix subTLV (1), length: 5
Expand All @@ -127,5 +127,5 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 5
TimeStamp Sent: 1087208232.000029937 (1934-06-15T10:17:12Z)
TimeStamp Received: 1087208232.000030273 (1934-06-15T10:17:12Z)
TimeStamp Sent: 1087208232.000029937 (2070-07-21T16:45:28Z)
TimeStamp Received: 1087208232.000030273 (2070-07-21T16:45:28Z)
30 changes: 15 additions & 15 deletions tests/lspping-fec-rsvp-v.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 1
TimeStamp Sent: 1087208037.000131030 (1934-06-15T10:13:57Z)
TimeStamp Sent: 1087208037.000131030 (2070-07-21T16:42:13Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 24
RSVP IPv4 Session Query subTLV (3), length: 20
Expand All @@ -19,8 +19,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 1
TimeStamp Sent: 1087208037.000131030 (1934-06-15T10:13:57Z)
TimeStamp Received: 1087208037.000131348 (1934-06-15T10:13:57Z)
TimeStamp Sent: 1087208037.000131030 (2070-07-21T16:42:13Z)
TimeStamp Received: 1087208037.000131348 (2070-07-21T16:42:13Z)
3 2004-06-14 10:13:58.572787 MPLS (label 100704, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40271, offset 0, flags [none], proto UDP (17), length 88)
12.4.4.4.4529 > 127.0.0.1.3503:
Expand All @@ -29,7 +29,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 2
TimeStamp Sent: 1087208038.000133345 (1934-06-15T10:13:58Z)
TimeStamp Sent: 1087208038.000133345 (2070-07-21T16:42:14Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 24
RSVP IPv4 Session Query subTLV (3), length: 20
Expand All @@ -42,8 +42,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 2
TimeStamp Sent: 1087208038.000133345 (1934-06-15T10:13:58Z)
TimeStamp Received: 1087208038.000136480 (1934-06-15T10:13:58Z)
TimeStamp Sent: 1087208038.000133345 (2070-07-21T16:42:14Z)
TimeStamp Received: 1087208038.000136480 (2070-07-21T16:42:14Z)
5 2004-06-14 10:13:59.572866 MPLS (label 100704, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40273, offset 0, flags [none], proto UDP (17), length 88)
12.4.4.4.4529 > 127.0.0.1.3503:
Expand All @@ -52,7 +52,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 3
TimeStamp Sent: 1087208039.000133363 (1934-06-15T10:13:59Z)
TimeStamp Sent: 1087208039.000133363 (2070-07-21T16:42:15Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 24
RSVP IPv4 Session Query subTLV (3), length: 20
Expand All @@ -65,8 +65,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 3
TimeStamp Sent: 1087208039.000133363 (1934-06-15T10:13:59Z)
TimeStamp Received: 1087208039.000133684 (1934-06-15T10:13:59Z)
TimeStamp Sent: 1087208039.000133363 (2070-07-21T16:42:15Z)
TimeStamp Received: 1087208039.000133684 (2070-07-21T16:42:15Z)
7 2004-06-14 10:14:00.572959 MPLS (label 100704, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40275, offset 0, flags [none], proto UDP (17), length 88)
12.4.4.4.4529 > 127.0.0.1.3503:
Expand All @@ -75,7 +75,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 4
TimeStamp Sent: 1087208040.000133384 (1934-06-15T10:14:00Z)
TimeStamp Sent: 1087208040.000133384 (2070-07-21T16:42:16Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 24
RSVP IPv4 Session Query subTLV (3), length: 20
Expand All @@ -88,8 +88,8 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 4
TimeStamp Sent: 1087208040.000133384 (1934-06-15T10:14:00Z)
TimeStamp Received: 1087208040.000133697 (1934-06-15T10:14:00Z)
TimeStamp Sent: 1087208040.000133384 (2070-07-21T16:42:16Z)
TimeStamp Received: 1087208040.000133697 (2070-07-21T16:42:16Z)
9 2004-06-14 10:14:01.573010 MPLS (label 100704, tc 7, [S], ttl 255)
IP (tos 0x0, ttl 64, id 40278, offset 0, flags [none], proto UDP (17), length 88)
12.4.4.4.4529 > 127.0.0.1.3503:
Expand All @@ -98,7 +98,7 @@
Return Code: No return code or return code contained in the Error Code TLV (0)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 5
TimeStamp Sent: 1087208041.000133401 (1934-06-15T10:14:01Z)
TimeStamp Sent: 1087208041.000133401 (2070-07-21T16:42:17Z)
TimeStamp Received: no timestamp
Target FEC Stack TLV (1), length: 24
RSVP IPv4 Session Query subTLV (3), length: 20
Expand All @@ -111,5 +111,5 @@
Return Code: Replying router is an egress for the FEC at stack depth 0 (3)
Return Subcode: (0)
Sender Handle: 0x00000000, Sequence: 5
TimeStamp Sent: 1087208041.000133401 (1934-06-15T10:14:01Z)
TimeStamp Received: 1087208041.000133707 (1934-06-15T10:14:01Z)
TimeStamp Sent: 1087208041.000133401 (2070-07-21T16:42:17Z)
TimeStamp Received: 1087208041.000133707 (2070-07-21T16:42:17Z)
Loading