From 49c88898ce71bc10e4dc9c5de1c2b646346bd51c Mon Sep 17 00:00:00 2001 From: ProudGecko Date: Fri, 20 Oct 2017 09:12:41 -0400 Subject: [PATCH] Fix for bit ordering of li, vn, and mode The original bit order was wrong for the first byte of the NTP packet. For example, settings ntp[0] = 0x1C, results in li = 0, vn = 7, mode = 0. The correct answers are li = 0, vn = 3, mode = 4. --- source/c/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/c/main.c b/source/c/main.c index d3f225a..dc3b355 100644 --- a/source/c/main.c +++ b/source/c/main.c @@ -47,9 +47,9 @@ int main( int argc, char* argv[ ] ) typedef struct { - unsigned li : 2; // Only two bits. Leap indicator. - unsigned vn : 3; // Only three bits. Version number of the protocol. unsigned mode : 3; // Only three bits. Mode. Client will pick mode 3 for client. + unsigned vn : 3; // Only three bits. Version number of the protocol. + unsigned li : 2; // Only two bits. Leap indicator. uint8_t stratum; // Eight bits. Stratum level of the local clock. uint8_t poll; // Eight bits. Maximum interval between successive messages.