Use mnemonics when checking reply flags and print out information in
debug mode about why the reply flags were rejected.
---
src/ntp.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/ntp.c b/src/ntp.c
index 7ef072c..e4267ea 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -199,8 +199,20 @@ static void decode_msg(void *base, size_t len, struct
timeval *tv)
transmit_delay = LOGTOD(msg->poll);
- if (msg->flags != 0x24)
+ if (NTP_FLAGS_LI_DECODE(msg->flags) == NTP_FLAG_LI_NOTINSYNC) {
+ DBG("ignoring unsynchronized peer");
return;
+ }
+
+ if (NTP_FLAGS_VN_DECODE(msg->flags) != 4) {
+ DBG("unsupported version %d", NTP_FLAGS_VN_DECODE(msg->flags));
+ return;
+ }
+
+ if (NTP_FLAGS_MD_DECODE(msg->flags) != NTP_FLAG_MD_SERVER) {
+ DBG("unsupported mode %d", NTP_FLAGS_MD_DECODE(msg->flags));
+ return;
+ }
org = transmit_timeval.tv_sec +
(1.0e-6 * transmit_timeval.tv_usec) + OFFSET_1900_1970;
--
1.7.10
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman