sntp.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * (C) Masami Komiya <mkomiya@sonare.it> 2005
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2, or (at
  7. * your option) any later version.
  8. */
  9. #ifndef __SNTP_H__
  10. #define __SNTP_H__
  11. #define NTP_SERVICE_PORT 123
  12. #define SNTP_PACKET_LEN 48
  13. /* Leap Indicator */
  14. #define NTP_LI_NOLEAP 0x0
  15. #define NTP_LI_61SECS 0x1
  16. #define NTP_LI_59SECS 0x2
  17. #define NTP_LI_ALARM 0x3
  18. /* Version */
  19. #define NTP_VERSION 4
  20. /* Mode */
  21. #define NTP_MODE_RESERVED 0
  22. #define NTP_MODE_SYMACTIVE 1 /* Symmetric Active */
  23. #define NTP_MODE_SYMPASSIVE 2 /* Symmetric Passive */
  24. #define NTP_MODE_CLIENT 3
  25. #define NTP_MODE_SERVER 4
  26. #define NTP_MODE_BROADCAST 5
  27. #define NTP_MODE_NTPCTRL 6 /* Reserved for NTP control message */
  28. #define NTP_MODE_PRIVATE 7 /* Reserved for private use */
  29. struct sntp_pkt_t {
  30. #if __LITTLE_ENDIAN
  31. uchar mode:3;
  32. uchar vn:3;
  33. uchar li:2;
  34. #else
  35. uchar li:2;
  36. uchar vn:3;
  37. uchar mode:3;
  38. #endif
  39. uchar stratum;
  40. uchar poll;
  41. uchar precision;
  42. uint root_delay;
  43. uint root_dispersion;
  44. uint reference_id;
  45. unsigned long long reference_timestamp;
  46. unsigned long long originate_timestamp;
  47. unsigned long long receive_timestamp;
  48. unsigned long long transmit_timestamp;
  49. };
  50. extern void SntpStart (void); /* Begin SNTP */
  51. #endif /* __SNTP_H__ */