]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ntp/ntpdate/ntpdate.h
This commit was generated by cvs2svn to compensate for changes in r56067,
[FreeBSD/FreeBSD.git] / contrib / ntp / ntpdate / ntpdate.h
1 /*
2  * ntpdate.h - declarations for the ntpdate and ntptimeset programs
3  */
4
5 #include "ntp_malloc.h"
6
7 /*
8  * The server structure is a much simplified version of the
9  * peer structure, for ntpdate's use.  Since we always send
10  * in client mode and expect to receive in server mode, this
11  * leaves only a very limited number of things we need to
12  * remember about the server.
13  */
14 struct server {
15         struct server *next_server;     /* next server in build list */
16         struct sockaddr_in srcadr;      /* address of remote host */
17         u_char version;                 /* version to use */
18         u_char leap;                    /* leap indicator */
19         u_char stratum;                 /* stratum of remote server */
20         s_char precision;               /* server's clock precision */
21         u_char trust;                   /* trustability of the filtered data */
22         u_fp rootdelay;                 /* distance from primary clock */
23         u_fp rootdispersion;            /* peer clock dispersion */
24         u_int32 refid;                  /* peer reference ID */
25         l_fp reftime;                   /* time of peer's last update */
26         u_long event_time;              /* time for next timeout */
27         u_long last_xmit;               /* time of last transmit */
28         u_short xmtcnt;                 /* number of packets transmitted */
29         u_short rcvcnt;                 /* number of packets received */
30         u_char reach;                   /* reachability, NTP_WINDOW bits */
31         u_short filter_nextpt;          /* index into filter shift register */
32         s_fp filter_delay[NTP_SHIFT];   /* delay part of shift register */
33         l_fp filter_offset[NTP_SHIFT];  /* offset part of shift register */
34         s_fp filter_soffset[NTP_SHIFT]; /* offset in s_fp format, for disp */
35         u_fp filter_error[NTP_SHIFT];   /* error part of shift register */
36         l_fp org;                       /* peer's originate time stamp */
37         l_fp xmt;                       /* transmit time stamp */
38         u_fp delay;                     /* filter estimated delay */
39         u_fp dispersion;                /* filter estimated dispersion */
40         l_fp offset;                    /* filter estimated clock offset */
41         s_fp soffset;                   /* fp version of above */
42 };
43
44
45 /*
46  * ntpdate runs everything on a simple, short timeout.  It sends a
47  * packet and sets the timeout (by default, to a small value suitable
48  * for a LAN).  If it receives a response it sends another request.
49  * If it times out it shifts zeroes into the filter and sends another
50  * request.
51  *
52  * The timer routine is run often (once every 1/5 second currently)
53  * so that time outs are done with reasonable precision.
54  */
55 #define TIMER_HZ        (5)             /* 5 per second */
56
57 /*
58  * ntpdate will make a long adjustment using adjtime() if the times
59  * are close, or step the time if the times are farther apart.  The
60  * following defines what is "close".
61  */
62 #define NTPDATE_THRESHOLD       (FP_SECOND >> 1)        /* 1/2 second */
63
64 /*
65  * When doing adjustments, ntpdate actually overadjusts (currently
66  * by 50%, though this may change).  While this will make it take longer
67  * to reach a steady state condition, it will typically result in
68  * the clock keeping more accurate time, on average.  The amount of
69  * overshoot is limited.
70  */
71 #ifdef  NOTNOW
72 #define ADJ_OVERSHOOT   1/2     /* this is hard coded */
73 #endif  /* NOTNOW */
74 #define ADJ_MAXOVERSHOOT        0x10000000      /* 50 ms as a ts fraction */
75
76 /*
77  * Since ntpdate isn't aware of some of the things that normally get
78  * put in an NTP packet, we fix some values.
79  */
80 #define NTPDATE_PRECISION       (-6)            /* use this precision */
81 #define NTPDATE_DISTANCE        FP_SECOND       /* distance is 1 sec */
82 #define NTPDATE_DISP            FP_SECOND       /* so is the dispersion */
83 #define NTPDATE_REFID           (0)             /* reference ID to use */
84 #define PEER_MAXDISP    (64*FP_SECOND)  /* maximum dispersion (fp 64) */
85
86
87 /*
88  * Some defaults
89  */
90 #define DEFTIMEOUT      5               /* 5 timer increments */
91 #define DEFSAMPLES      4               /* get 4 samples per server */
92 #define DEFPRECISION    (-5)            /* the precision we claim */
93 #define DEFMAXPERIOD    60              /* maximum time to wait */
94 #define DEFMINSERVERS   3               /* minimum responding servers */
95 #define DEFMINVALID     1               /* mimimum servers with valid time */