home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xntp3.zip / include / ntp_refclock.h < prev    next >
C/C++ Source or Header  |  1991-10-30  |  3KB  |  122 lines

  1. /*
  2.  * ntp_refclock.h - definitions for reference clock support
  3.  */
  4.  
  5. /*
  6.  * Macros to determine the clock type and unit numbers from a
  7.  * 127.127.t.u address.
  8.  */
  9. #define    REFCLOCKTYPE(srcadr)    ((SRCADR(srcadr) >> 8) & 0xff)
  10. #define REFCLOCKUNIT(srcadr)    (SRCADR(srcadr) & 0xff)
  11.  
  12. /*
  13.  * Struct refclock provides the interface between the reference
  14.  * clock support and particular clock drivers.  There are entries
  15.  * to open and close a unit, optional values to specify the
  16.  * timer interval for calls to the transmit procedure and to
  17.  * specify a polling routine to be called when the transmit
  18.  * procedure executes.  There is an entry which is called when
  19.  * the transmit routine is about to shift zeroes into the
  20.  * filter register, and entries for stuffing fudge factors into
  21.  * the driver and getting statistics from it.
  22.  */
  23. struct refclock {
  24.     int (*clock_start)();        /* start a clock unit */
  25.     void (*clock_shutdown)();    /* shut a clock down */
  26.     void (*clock_poll)();        /* called from the xmit routine */
  27.     void (*clock_leap)();        /* inform driver a leap has occured */
  28.     void (*clock_control)();    /* set fudge values, return stats */
  29.     void (*clock_init)();        /* initialize driver data at startup */
  30.     void (*clock_buginfo)();    /* get clock dependent bug info */
  31.     u_long clock_xmitinterval;    /* timer setting for xmit routine */
  32.     u_long clock_flags;        /* flag values */
  33. };
  34.  
  35. /*
  36.  * Definitions for default values
  37.  */
  38. #define    noentry        0
  39. #define    STDPOLL        (1<<NTP_MINPOLL)
  40. #define    NOPOLL        0
  41.  
  42. /*
  43.  * Definitions for flags
  44.  */
  45. #define    NOFLAGS            0
  46. #define    REF_FLAG_BCLIENT    0x1    /* clock prefers to run as a bclient */
  47.  
  48. /*
  49.  * Flag values
  50.  */
  51. #define    CLK_HAVETIME1    0x1
  52. #define    CLK_HAVETIME2    0x2
  53. #define    CLK_HAVEVAL1    0x4
  54. #define    CLK_HAVEVAL2    0x8
  55.  
  56. #define    CLK_FLAG1    0x1
  57. #define    CLK_FLAG2    0x2
  58. #define    CLK_FLAG3    0x4
  59. #define    CLK_FLAG4    0x8
  60.  
  61. #define    CLK_HAVEFLAG1    0x10
  62. #define    CLK_HAVEFLAG2    0x20
  63. #define    CLK_HAVEFLAG3    0x40
  64. #define    CLK_HAVEFLAG4    0x80
  65.  
  66. /*
  67.  * Structure for returning clock status
  68.  */
  69. struct refclockstat {
  70.     u_char type;
  71.     u_char flags;
  72.     u_char haveflags;
  73.     u_char lencode;
  74.     char *lastcode;
  75.     u_long polls;
  76.     u_long noresponse;
  77.     u_long badformat;
  78.     u_long baddata;
  79.     u_long timereset;
  80.     char *clockdesc;    /* description of clock, in ASCII */
  81.     l_fp fudgetime1;
  82.     l_fp fudgetime2;
  83.     long fudgeval1;
  84.     long fudgeval2;
  85.     u_char currentstatus;
  86.     u_char lastevent;
  87.     u_char unused[2];
  88. };
  89.  
  90.  
  91. /*
  92.  * Reference clock I/O structure.  Used to provide an interface between
  93.  * the reference clock drivers and the I/O module.
  94.  */
  95. struct refclockio {
  96.     struct refclockio *next;
  97.     void (*clock_recv)();
  98.     caddr_t srcclock;    /* pointer to clock structure */
  99.     int datalen;
  100.     int fd;
  101.     u_long recvcount;
  102. };
  103.  
  104.  
  105. /*
  106.  * Sizes of things we return for debugging
  107.  */
  108. #define    NCLKBUGVALUES        16
  109. #define    NCLKBUGTIMES        32
  110.  
  111. /*
  112.  * Structure for returning debugging info
  113.  */
  114. struct refclockbug {
  115.     u_char nvalues;
  116.     u_char ntimes;
  117.     u_short svalues;
  118.     u_long stimes;
  119.     u_long values[NCLKBUGVALUES];
  120.     l_fp times[NCLKBUGTIMES];
  121. };
  122.