sntp.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Masami Komiya <mkomiya@sonare.it> 2005
  4. */
  5. #ifndef __SNTP_H__
  6. #define __SNTP_H__
  7. #define NTP_SERVICE_PORT 123
  8. #define SNTP_PACKET_LEN 48
  9. /* Leap Indicator */
  10. #define NTP_LI_NOLEAP 0x0
  11. #define NTP_LI_61SECS 0x1
  12. #define NTP_LI_59SECS 0x2
  13. #define NTP_LI_ALARM 0x3
  14. /* Version */
  15. #define NTP_VERSION 4
  16. /* Mode */
  17. #define NTP_MODE_RESERVED 0
  18. #define NTP_MODE_SYMACTIVE 1 /* Symmetric Active */
  19. #define NTP_MODE_SYMPASSIVE 2 /* Symmetric Passive */
  20. #define NTP_MODE_CLIENT 3
  21. #define NTP_MODE_SERVER 4
  22. #define NTP_MODE_BROADCAST 5
  23. #define NTP_MODE_NTPCTRL 6 /* Reserved for NTP control message */
  24. #define NTP_MODE_PRIVATE 7 /* Reserved for private use */
  25. struct sntp_pkt_t {
  26. #if __LITTLE_ENDIAN
  27. uchar mode:3;
  28. uchar vn:3;
  29. uchar li:2;
  30. #else
  31. uchar li:2;
  32. uchar vn:3;
  33. uchar mode:3;
  34. #endif
  35. uchar stratum;
  36. uchar poll;
  37. uchar precision;
  38. uint root_delay;
  39. uint root_dispersion;
  40. uint reference_id;
  41. unsigned long long reference_timestamp;
  42. unsigned long long originate_timestamp;
  43. unsigned long long receive_timestamp;
  44. unsigned long long transmit_timestamp;
  45. } __attribute__((packed));
  46. void sntp_start(void); /* Begin SNTP */
  47. #endif /* __SNTP_H__ */