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_request.h < prev    next >
C/C++ Source or Header  |  1992-08-04  |  23KB  |  707 lines

  1. /*
  2.  * ntp_request.h - definitions for the xntpd remote query facility
  3.  */
  4.  
  5. /*
  6.  * A mode 7 packet is used exchanging data between an NTP server
  7.  * and a client for purposes other than time synchronization, e.g.
  8.  * monitoring, statistics gathering and configuration.  A mode 7
  9.  * packet has the following format:
  10.  *
  11.  *    0              1              2              3
  12.  *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  13.  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  14.  *   |R|M| VN  | Mode|A|  Sequence   | Implementation|   Req Code    |
  15.  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  16.  *   |  Err  | Number of data items  |  MBZ  |   Size of data item   |
  17.  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  18.  *   |                                     |
  19.  *   |            Data (Minimum 0 octets, maximum 500 octets)        |
  20.  *   |                                     |
  21.  *                            [...]
  22.  *   |                                     |
  23.  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  24.  *   |               Encryption Keyid (when A bit set)               |
  25.  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  26.  *   |                                     |
  27.  *   |          Message Authentication Code (when A bit set)         |
  28.  *   |                                     |
  29.  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  30.  *
  31.  * where the fields are (note that the client sends requests, the server
  32.  * responses):
  33.  *
  34.  * Response Bit:  This packet is a response (if clear, packet is a request).
  35.  *
  36.  * More Bit:    Set for all packets but the last in a response which
  37.  *        requires more than one packet.
  38.  *
  39.  * Version Number: 2 for current version
  40.  *
  41.  * Mode:    Always 7
  42.  *
  43.  * Authenticated bit: If set, this packet is authenticated.
  44.  *
  45.  * Sequence number: For a multipacket response, contains the sequence
  46.  *        number of this packet.  0 is the first in the sequence,
  47.  *        127 (or less) is the last.  The More Bit must be set in
  48.  *        all packets but the last.
  49.  *
  50.  * Implementation number: The number of the implementation this request code
  51.  *        is defined by.  An implementation number of zero is used
  52.  *        for requst codes/data formats which all implementations
  53.  *        agree on.  Implementation number 255 is reserved (for
  54.  *        extensions, in case we run out).
  55.  *
  56.  * Request code: An implementation-specific code which specifies the
  57.  *        operation to be (which has been) performed and/or the
  58.  *        format and semantics of the data included in the packet.
  59.  *
  60.  * Err:        Must be 0 for a request.  For a response, holds an error
  61.  *        code relating to the request.  If nonzero, the operation
  62.  *        requested wasn't performed.
  63.  *
  64.  *        0 - no error
  65.  *        1 - incompatable implementation number
  66.  *        2 - unimplemented request code
  67.  *        3 - format error (wrong data items, data size, packet size etc.)
  68.  *        4 - no data available (e.g. request for details on unknown peer)
  69.  *        5-6 I don't know
  70.  *        7 - authentication failure (i.e. permission denied)
  71.  *
  72.  * Number of data items: number of data items in packet.  0 to 500
  73.  *
  74.  * MBZ:        A reserved data field, must be zero in requests and responses.
  75.  *
  76.  * Size of data item: size of each data item in packet.  0 to 500
  77.  *
  78.  * Data:    Variable sized area containing request/response data.  For
  79.  *        requests and responses the size in octets must be greater
  80.  *        than or equal to the product of the number of data items
  81.  *        and the size of a data item.  For requests the data area
  82.  *        must be exactly 40 octets in length.  For responses the
  83.  *        data area may be any length between 0 and 500 octets
  84.  *        inclusive.
  85.  *
  86.  * Message Authentication Code: Same as NTP spec, in definition and function.
  87.  *        May optionally be included in requests which require
  88.  *        authentication, is never included in responses.
  89.  *
  90.  * The version number, mode and keyid have the same function and are
  91.  * in the same location as a standard NTP packet.  The request packet
  92.  * is the same size as a standard NTP packet to ease receive buffer
  93.  * management, and to allow the same encryption procedure to be used
  94.  * both on mode 7 and standard NTP packets.  The mac is included when
  95.  * it is required that a request be authenticated, the keyid should be
  96.  * zero in requests in which the mac is not included.
  97.  *
  98.  * The data format depends on the implementation number/request code pair
  99.  * and whether the packet is a request or a response.  The only requirement
  100.  * is that data items start in the octet immediately following the size
  101.  * word and that data items be concatenated without padding between (i.e.
  102.  * if the data area is larger than data_items*size, all padding is at
  103.  * the end).  Padding is ignored, other than for encryption purposes.
  104.  * Implementations using encryption might want to include a time stamp
  105.  * or other data in the request packet padding.  The key used for requests
  106.  * is implementation defined, but key 15 is suggested as a default.
  107.  */
  108.  
  109. /*
  110.  * A request packet.  These are almost a fixed length.
  111.  */
  112. struct req_pkt {
  113.     u_char rm_vn_mode;        /* response, more, version, mode */
  114.     u_char auth_seq;        /* key, sequence number */
  115.     u_char implementation;        /* implementation number */
  116.     u_char request;            /* request number */
  117.     u_short err_nitems;        /* error code/number of data items */
  118.     u_short mbz_itemsize;        /* item size */
  119.     char data[32];            /* data area */
  120.     l_fp tstamp;            /* time stamp, for authentication */
  121.     u_long keyid;            /* encryption key */
  122.     char mac[MAX_MAC_LEN-sizeof(u_long)]; /* (optional) 8 byte auth code */
  123. };
  124.  
  125. /*
  126.  * Input packet lengths.  One with the mac, one without.
  127.  */
  128. #define    REQ_LEN_MAC    (sizeof(struct req_pkt))
  129. #define    REQ_LEN_NOMAC    (sizeof(struct req_pkt) - MAX_MAC_LEN)
  130.  
  131. /*
  132.  * A response packet.  The length here is variable, this is a
  133.  * maximally sized one.  Note that this implementation doesn't
  134.  * authenticate responses.
  135.  */
  136. #define    RESP_HEADER_SIZE    (8)
  137. #define    RESP_DATA_SIZE        (500)
  138.  
  139. struct resp_pkt {
  140.     u_char rm_vn_mode;        /* response, more, version, mode */
  141.     u_char auth_seq;        /* key, sequence number */
  142.     u_char implementation;        /* implementation number */
  143.     u_char request;            /* request number */
  144.     u_short err_nitems;        /* error code/number of data items */
  145.     u_short mbz_itemsize;        /* item size */
  146.     char data[RESP_DATA_SIZE];    /* data area */
  147. };
  148.  
  149.  
  150. /*
  151.  * Information error codes
  152.  */
  153. #define    INFO_OKAY    0
  154. #define    INFO_ERR_IMPL    1    /* incompatable implementation */
  155. #define    INFO_ERR_REQ    2    /* unknown request code */
  156. #define    INFO_ERR_FMT    3    /* format error */
  157. #define    INFO_ERR_NODATA    4    /* no data for this request */
  158. #define    INFO_ERR_AUTH    7    /* authentication failure */
  159.  
  160. /*
  161.  * Maximum sequence number.
  162.  */
  163. #define    MAXSEQ    127
  164.  
  165.  
  166. /*
  167.  * Bit setting macros for multifield items.
  168.  */
  169. #define    RESP_BIT    0x80
  170. #define    MORE_BIT    0x40
  171.  
  172. #define    ISRESPONSE(rm_vn_mode)    (((rm_vn_mode)&RESP_BIT)!=0)
  173. #define    ISMORE(rm_vn_mode)    (((rm_vn_mode)&MORE_BIT)!=0)
  174. #define INFO_VERSION(rm_vn_mode)    (((rm_vn_mode)>>3)&0x7)
  175. #define    INFO_MODE(rm_vn_mode)    ((rm_vn_mode)&0x7)
  176.  
  177. #define    RM_VN_MODE(resp, more)    ((u_char)(((resp)?RESP_BIT:0)\
  178.                 |((more)?MORE_BIT:0)\
  179.                 |((NTP_VERSION)<<3)\
  180.                 |(MODE_PRIVATE)))
  181.  
  182. #define    INFO_IS_AUTH(auth_seq)    (((auth_seq) & 0x80) != 0)
  183. #define    INFO_SEQ(auth_seq)    ((auth_seq)&0x7f)
  184. #define    AUTH_SEQ(auth, seq)    ((u_char)((((auth)!=0)?0x80:0)|((seq)&0x7f)))
  185.  
  186. #define    INFO_ERR(err_nitems)    ((ntohs(err_nitems)>>12)&0xf)
  187. #define    INFO_NITEMS(err_nitems)    (ntohs(err_nitems)&0xfff)
  188. #define    ERR_NITEMS(err, nitems)    (htons((((u_short)(err)<<12)&0xf000)\
  189.                 |((u_short)(nitems)&0xfff)))
  190.  
  191. #define    INFO_MBZ(mbz_itemsize)    ((ntohs(mbz_itemsize)>>12)&0xf)
  192. #define    INFO_ITEMSIZE(mbz_itemsize)    (ntohs(mbz_itemsize)&0xfff)
  193. #define    MBZ_ITEMSIZE(itemsize)    (htons((u_short)(itemsize)))
  194.  
  195.  
  196. /*
  197.  * Implementation numbers.  One for universal use and one for xntpd.
  198.  */
  199. #define    IMPL_UNIV    0
  200. #define    IMPL_XNTPD    2
  201.  
  202. /*
  203.  * Some limits related to authentication.  Frames which are
  204.  * authenticated must include a time stamp which differs from
  205.  * the receive time stamp by no more than 10 seconds.
  206.  */
  207. #define    INFO_TS_MAXSKEW_UI    10
  208. #define    INFO_TS_MAXSKEW_UF    0
  209.  
  210. /*
  211.  * Universal request codes go here.  There aren't any.
  212.  */
  213.  
  214. /*
  215.  * XNTPD request codes go here.
  216.  */
  217. #define    REQ_PEER_LIST        0    /* return list of peers */
  218. #define    REQ_PEER_LIST_SUM    1    /* return summary info for all peers */
  219. #define    REQ_PEER_INFO        2    /* get standard information on peer */
  220. #define    REQ_PEER_STATS        3    /* get statistics for peer */
  221. #define    REQ_SYS_INFO        4    /* get system information */
  222. #define    REQ_SYS_STATS        5    /* get system stats */
  223. #define    REQ_IO_STATS        6    /* get I/O stats */
  224. #define REQ_MEM_STATS        7    /* stats related to peer list maint */
  225. #define    REQ_LOOP_INFO        8    /* info from the loop filter */
  226. #define    REQ_TIMER_STATS        9    /* get timer stats */
  227. #define    REQ_CONFIG        10    /* configure a new peer */
  228. #define    REQ_UNCONFIG        11    /* unconfigure an existing peer */
  229. #define    REQ_SET_SYS_FLAG    12    /* set system flags */
  230. #define    REQ_CLR_SYS_FLAG    13    /* clear system flags */
  231. #define    REQ_MONITOR        14    /* monitor clients */
  232. #define    REQ_NOMONITOR        15    /* stop monitoring clients */
  233. #define    REQ_GET_RESTRICT    16    /* return restrict list */
  234. #define    REQ_RESADDFLAGS        17    /* add flags to restrict list */
  235. #define    REQ_RESSUBFLAGS        18    /* remove flags from restrict list */
  236. #define    REQ_UNRESTRICT        19    /* remove entry from restrict list */
  237. #define    REQ_MON_GETLIST        20    /* return data collected by monitor */
  238. #define    REQ_RESET_STATS        21    /* reset stat counters */
  239. #define    REQ_RESET_PEER        22    /* reset peer stat counters */
  240. #define    REQ_REREAD_KEYS        23    /* reread the encryption key file */
  241. #define    REQ_DO_DIRTY_HACK    24    /* historical interest */
  242. #define    REQ_DONT_DIRTY_HACK    25    /* Ibid. */
  243. #define    REQ_TRUSTKEY        26    /* add a trusted key */
  244. #define    REQ_UNTRUSTKEY        27    /* remove a trusted key */
  245. #define    REQ_AUTHINFO        28    /* return authentication info */
  246. #define REQ_TRAPS        29    /* return currently set traps */
  247. #define    REQ_ADD_TRAP        30    /* add a trap */
  248. #define    REQ_CLR_TRAP        31    /* clear a trap */
  249. #define    REQ_REQUEST_KEY        32    /* define a new request keyid */
  250. #define    REQ_CONTROL_KEY        33    /* define a new control keyid */
  251. #define    REQ_GET_CTLSTATS    34    /* get stats from the control module */
  252. #define    REQ_GET_LEAPINFO    35    /* get leap information */
  253. #define    REQ_GET_CLOCKINFO    36    /* get clock information */
  254. #define    REQ_SET_CLKFUDGE    37    /* set clock fudge factors */
  255. #define    REQ_SET_MAXSKEW        38    /* set the maximum skew factor */
  256. #define    REQ_GET_CLKBUGINFO    39    /* get clock debugging info */
  257. #define    REQ_SET_SELECT_CODE    40    /* set selection algorithm */
  258. #define    REQ_SET_PRECISION    41    /* set clock precision */
  259.  
  260.  
  261. /*
  262.  * Flags in the information returns
  263.  */
  264. #define    INFO_FLAG_CONFIG    0x1
  265. #define    INFO_FLAG_SYSPEER    0x2
  266. #define    INFO_FLAG_MINPOLL    0x4
  267. #define    INFO_FLAG_REFCLOCK    0x8
  268. #define    INFO_FLAG_BCLIENT    0x10
  269. #define    INFO_FLAG_AUTHENABLE    0x20
  270. #define    INFO_FLAG_SEL_CANDIDATE    0x40
  271. #define    INFO_FLAG_SHORTLIST    0x80
  272.  
  273. /*
  274.  * Peer list structure.  Used to return raw lists of peers.  It goes
  275.  * without saying that everything returned is in network byte order.
  276.  */
  277. struct info_peer_list {
  278.     u_long address;        /* address of peer */
  279.     u_short port;        /* port number of peer */
  280.     u_char hmode;        /* mode for this peer */
  281.     u_char flags;        /* flags (from above) */
  282. };
  283.  
  284.  
  285. /*
  286.  * Peer summary structure.  Sort of the info that ntpdc returns by default.
  287.  */
  288. struct info_peer_summary {
  289.     u_long dstadr;        /* local address (zero for undetermined) */
  290.     u_long srcadr;        /* source address */
  291.     u_short srcport;    /* source port */
  292.     u_char stratum;        /* stratum of peer */
  293.     s_char hpoll;        /* host polling interval */
  294.     s_char ppoll;        /* peer polling interval */
  295.     u_char reach;        /* reachability register */
  296.     u_char flags;        /* flags, from above */
  297.     u_char hmode;        /* peer mode */
  298.     s_fp delay;        /* peer.estdelay */
  299.     l_fp offset;        /* peer.estoffset */
  300.     u_fp dispersion;    /* peer.estdisp */
  301. };
  302.  
  303.  
  304. /*
  305.  * Peer information structure.
  306.  */
  307. struct info_peer {
  308.     u_long dstadr;        /* local address */
  309.     u_long srcadr;        /* remote address */
  310.     u_short srcport;    /* remote port */
  311.     u_char flags;        /* peer flags */
  312.     u_char leap;        /* peer.leap */
  313.     u_char hmode;        /* peer.hmode */
  314.     u_char pmode;        /* peer.pmode */
  315.     u_char stratum;        /* peer.stratum */
  316.     u_char ppoll;        /* peer.ppoll */
  317.     u_char hpoll;        /* peer.hpoll */
  318.     s_char precision;    /* peer.precision */
  319.     u_char version;        /* peer.version */
  320.     u_char valid;        /* peer.valid */
  321.     u_char reach;        /* peer.reach */
  322.     u_char unreach;        /* peer.unreach */
  323.     u_char trust;        /* peer.trust */
  324.     u_char unused1;
  325.     u_char unused2;
  326.     u_char unused3;
  327.     u_short associd;    /* association ID */
  328.     u_long keyid;        /* auth key in use */
  329.     u_long pkeyid;        /* peer.pkeyid */
  330.     u_long refid;        /* peer.refid */
  331.     u_long timer;        /* peer.timer */
  332.     s_fp rootdelay;        /* peer.distance */
  333.     u_fp rootdispersion;    /* peer.dispersion */
  334.     l_fp reftime;        /* peer.reftime */
  335.     l_fp org;        /* peer.org */
  336.     l_fp rec;        /* peer.rec */
  337.     l_fp xmt;        /* peer.xmt */
  338.     s_fp filtdelay[NTP_SHIFT];    /* delay shift register */
  339.     l_fp filtoffset[NTP_SHIFT];    /* offset shift register */
  340.     u_char order[NTP_SHIFT];    /* order of peers from last filter */
  341.     s_fp delay;        /* peer.estdelay */
  342.     u_fp dispersion;    /* peer.estdisp */
  343.     l_fp offset;        /* peer.estoffset */
  344.     u_long bdelay[NTP_SHIFT];    /* broadcast delay filters */
  345.     u_long estbdelay;    /* broadcast delay */
  346. };
  347.  
  348.  
  349. /*
  350.  * Peer statistics structure
  351.  */
  352. struct info_peer_stats {
  353.     u_long dstadr;        /* local address */
  354.     u_long srcadr;        /* remote address */
  355.     u_short srcport;    /* remote port */
  356.     u_short flags;        /* peer flags */
  357.     u_long timereset;    /* time counters were reset */
  358.     u_long timereceived;    /* time since a packet received */
  359.     u_long timetosend;    /* time until a packet sent */
  360.     u_long timereachable;    /* time peer has been reachable */
  361.     u_long sent;        /* number sent */
  362.     u_long received;    /* number received */
  363.     u_long processed;    /* number processed */
  364.     u_long badlength;    /* rejected due to bad length */
  365.     u_long badauth;        /* rejected due to bad auth */
  366.     u_long bogusorg;    /* funny org time stamps */
  367.     u_long oldpkt;        /* duplicate packets */
  368.     u_long baddelay;    /* dropped due to bad delays */
  369.     u_long seldelay;    /* not selected due to delay */
  370.     u_long seldisp;        /* not selected due to dispersion */
  371.     u_long selbroken;    /* not selected because of brokenness */
  372.     u_long selold;        /* not selected because too old */
  373.     u_char candidate;    /* order after falseticker candidate select */
  374.     u_char falseticker;    /* order after resort for falseticker */
  375.     u_char select;        /* order after select */
  376.     u_char select_total;    /* number who made it to selection */
  377. };
  378.  
  379.  
  380. /*
  381.  * Loop filter variables
  382.  */
  383. struct info_loop {
  384.     l_fp last_offset;
  385.     l_fp drift_comp;
  386.     u_long compliance;
  387.     u_long watchdog_timer;
  388. };
  389.  
  390.  
  391. /*
  392.  * System info.  Mostly the sys.* variables, plus a few unique to
  393.  * the implementation.
  394.  */
  395. struct info_sys {
  396.     u_long peer;        /* system peer address */
  397.     u_char peer_mode;    /* mode we are syncing to peer in */
  398.     u_char leap;        /* system leap bits */
  399.     u_char stratum;        /* our stratum */
  400.     s_char precision;    /* local clock precision */
  401.     s_fp rootdelay;        /* distance from sync source */
  402.     u_fp rootdispersion;    /* dispersion from sync source */
  403.     u_long refid;        /* reference ID of sync source */
  404.     l_fp reftime;        /* system reference time */
  405.     u_long poll;        /* system poll interval */
  406.     u_short flags;        /* system flags */
  407.     u_char selection;    /* selection algorithm code */
  408.     u_char unused;
  409.     l_fp bdelay;        /* default broadcast delay, a ts fraction */
  410.     l_fp authdelay;        /* default authentication delay */
  411.     u_fp maxskew;        /* maximum skew parameter (obsolete) */
  412. };
  413.  
  414.  
  415. /*
  416.  * System stats.  These are collected in the protocol module
  417.  */
  418. struct info_sys_stats {
  419.     u_long timeup;        /* time we have been up and running */
  420.     u_long timereset;    /* time since these were last cleared */
  421.     u_long badstratum;    /* packets claiming an invalid stratum */
  422.     u_long oldversionpkt;    /* old version packets received */
  423.     u_long newversionpkt;    /* new version packets received */
  424.     u_long unknownversion;    /* don't know version packets */
  425.     u_long badlength;    /* packets with bad length */
  426.     u_long processed;    /* packets processed */
  427.     u_long badauth;        /* packets dropped because of authorization */
  428.     u_long wanderhold;
  429. };
  430.  
  431.  
  432. /*
  433.  * Peer memory statistics.  Collected in the peer module.
  434.  */
  435. struct info_mem_stats {
  436.     u_long timereset;    /* time since reset */
  437.     u_short totalpeermem;
  438.     u_short freepeermem;
  439.     u_long findpeer_calls;
  440.     u_long allocations;
  441.     u_long demobilizations;
  442.     u_char hashcount[HASH_SIZE];
  443. };
  444.  
  445.  
  446. /*
  447.  * I/O statistics.  Collected in the I/O module
  448.  */
  449. struct info_io_stats {
  450.     u_long timereset;    /* time since reset */
  451.     u_short totalrecvbufs;    /* total receive bufs */
  452.     u_short freerecvbufs;    /* free buffers */
  453.     u_short fullrecvbufs;    /* full buffers */
  454.     u_short lowwater;    /* number of times we've added buffers */
  455.     u_long dropped;        /* dropped packets */
  456.     u_long ignored;        /* ignored packets */
  457.     u_long received;    /* received packets */
  458.     u_long sent;        /* packets sent */
  459.     u_long notsent;        /* packets not sent */
  460.     u_long interrupts;    /* interrupts we've handled */
  461.     u_long int_received;    /* received by interrupt handler */
  462. };
  463.  
  464.  
  465. /*
  466.  * Timer stats.  Guess where from.
  467.  */
  468. struct info_timer_stats {
  469.     u_long timereset;    /* time since reset */
  470.     u_long alarms;        /* alarms we've handled */
  471.     u_long overflows;    /* timer overflows */
  472.     u_long xmtcalls;    /* calls to xmit */
  473. };
  474.  
  475.  
  476. /*
  477.  * Structure for passing peer configuration information
  478.  */
  479. struct conf_peer {
  480.     u_long peeraddr;    /* address to poll */
  481.     u_char hmode;        /* mode, either broadcast, active or client */
  482.     u_char version;        /* version number to poll with */
  483.     u_char flags;        /* flags for this request */
  484.     u_char unused;
  485.     u_long keyid;        /* key to use for this association */
  486. };
  487.  
  488. #define    CONF_FLAG_AUTHENABLE    0x1
  489. #define    CONF_FLAG_MINPOLL    0x2
  490.  
  491. /*
  492.  * Structure for passing peer deletion information.  Currently
  493.  * we only pass the address and delete all configured peers with
  494.  * this addess.
  495.  */
  496. struct conf_unpeer {
  497.     u_long peeraddr;    /* address of peer */
  498. };
  499.  
  500.  
  501. /*
  502.  * Structure for carrying system flags.
  503.  */
  504. struct conf_sys_flags {
  505.     u_long flags;
  506. };
  507.  
  508. /*
  509.  * System flags we can set/clear
  510.  */
  511. #define    SYS_FLAG_BCLIENT    0x1
  512. #define    SYS_FLAG_AUTHENTICATE    0x2
  513.  
  514. /*
  515.  * Structure used for returning restrict entries
  516.  */
  517. struct info_restrict {
  518.     u_long addr;            /* match address */
  519.     u_long mask;            /* match mask */
  520.     u_long count;            /* number of packets matched */
  521.     u_short flags;            /* restrict flags */
  522.     u_short mflags;            /* match flags */
  523. };
  524.  
  525.  
  526. /*
  527.  * Structure used for specifying restrict entries
  528.  */
  529. struct conf_restrict {
  530.     u_long addr;            /* match address */
  531.     u_long mask;            /* match mask */
  532.     u_short flags;            /* restrict flags */
  533.     u_short mflags;            /* match flags */
  534. };
  535.  
  536.  
  537. /*
  538.  * Structure used for returning monitor data
  539.  */
  540. struct info_monitor {    
  541.     u_long lasttime;        /* last packet from this host */
  542.     u_long firsttime;        /* first time we received a packet */
  543.     u_long count;            /* count of packets received */
  544.     u_long addr;            /* host address */
  545.     u_short port;            /* port number of last reception */
  546.     u_char mode;            /* mode of last packet */
  547.     u_char version;            /* version number of last packet */
  548. };
  549.  
  550.  
  551. /*
  552.  * Structure used for passing indication of flags to clear
  553.  */
  554. struct reset_flags {
  555.     u_long flags;
  556. };
  557.  
  558. #define    RESET_FLAG_ALLPEERS    0x01
  559. #define    RESET_FLAG_IO        0x02
  560. #define    RESET_FLAG_SYS        0x04
  561. #define    RESET_FLAG_MEM        0x08
  562. #define    RESET_FLAG_TIMER    0x10
  563. #define    RESET_FLAG_AUTH        0x20
  564. #define    RESET_FLAG_CTL        0x40
  565.  
  566. #define    RESET_ALLFLAGS \
  567.     (RESET_FLAG_ALLPEERS|RESET_FLAG_IO|RESET_FLAG_SYS \
  568.     |RESET_FLAG_MEM|RESET_FLAG_TIMER|RESET_FLAG_AUTH|RESET_FLAG_CTL)
  569.  
  570. /*
  571.  * Structure used to return information concerning the authentication
  572.  * module.
  573.  */
  574. struct info_auth {
  575.     u_long timereset;    /* time counters were reset */
  576.     u_long numkeys;        /* number of keys we know */
  577.     u_long numfreekeys;    /* number of free keys */
  578.     u_long keylookups;    /* calls to authhavekey() */
  579.     u_long keynotfound;    /* requested key unknown */
  580.     u_long encryptions;    /* number of encryptions */
  581.     u_long decryptions;    /* number of decryptions */
  582.     u_long decryptok;    /* number of successful decryptions */
  583.     u_long keyuncached;    /* calls to encrypt/decrypt with uncached key */
  584. };
  585.  
  586.  
  587. /*
  588.  * Structure used to pass trap information to the client
  589.  */
  590. struct info_trap {
  591.     u_long local_address;    /* local interface address */
  592.     u_long trap_address;    /* remote client's address */
  593.     u_short trap_port;    /* remote port number */
  594.     u_short sequence;    /* sequence number */
  595.     u_long settime;        /* time trap last set */
  596.     u_long origtime;    /* time trap originally set */
  597.     u_long resets;        /* number of resets on this trap */
  598.     u_long flags;        /* trap flags, as defined in ntp_control.h */
  599. };
  600.  
  601. /*
  602.  * Structure used to pass add/clear trap information to the client
  603.  */
  604. struct conf_trap {
  605.     u_long local_address;    /* local interface address */
  606.     u_long trap_address;    /* remote client's address */
  607.     u_short trap_port;    /* remote client's port */
  608.     u_short unused;
  609. };
  610.  
  611.  
  612. /*
  613.  * Structure used to return statistics from the control module
  614.  */
  615. struct info_control {
  616.     u_long ctltimereset;
  617.     u_long numctlreq;        /* number of requests we've received */
  618.     u_long numctlbadpkts;        /* number of bad control packets */
  619.     u_long numctlresponses;        /* # resp packets sent */
  620.     u_long numctlfrags;        /* # of fragments sent */
  621.     u_long numctlerrors;        /* number of error responses sent */
  622.     u_long numctltooshort;        /* number of too short input packets */
  623.     u_long numctlinputresp;        /* number of responses on input */
  624.     u_long numctlinputfrag;        /* number of fragments on input */
  625.     u_long numctlinputerr;        /* # input pkts with err bit set */
  626.     u_long numctlbadoffset;        /* # input pkts with nonzero offset */
  627.     u_long numctlbadversion;    /* # input pkts with unknown version */
  628.     u_long numctldatatooshort;    /* data too short for count */
  629.     u_long numctlbadop;        /* bad op code found in packet */
  630.     u_long numasyncmsgs;        /* # async messages we've sent */
  631. };
  632.  
  633.  
  634. /*
  635.  * Structure used to return leap information.
  636.  */
  637. struct info_leap {
  638.     u_char sys_leap;        /* current sys_leap */
  639.     u_char leap_indicator;        /* current leap indicator */
  640.     u_char leap_warning;        /* current leap warning */
  641.     u_char leap_bits;        /* leap flags */
  642.     u_long leap_timer;        /* seconds to next interrupt */
  643.     u_long leap_processcalls;    /* calls to the leap process */
  644.     u_long leap_notclose;        /* found leap was not close */
  645.     u_long leap_monthofleap;    /* in month of leap */
  646.     u_long leap_dayofleap;        /* in day of leap */
  647.     u_long leap_hoursfromleap;    /* leap within two hours */
  648.     u_long leap_happened;        /* leap second happened */
  649. };
  650.  
  651. #define    INFO_LEAP_MASK    0x3        /* flag for leap_bits */
  652. #define    INFO_LEAP_SEENSTRATUM1    0x4    /* server has seen stratum 1 */
  653.  
  654. /*
  655.  * Structure used to return clock information
  656.  */
  657. struct info_clock {
  658.     u_long clockadr;
  659.     u_char type;
  660.     u_char flags;
  661.     u_char lastevent;
  662.     u_char currentstatus;
  663.     u_long polls;
  664.     u_long noresponse;
  665.     u_long badformat;
  666.     u_long baddata;
  667.     u_long timestarted;
  668.     l_fp fudgetime1;
  669.     l_fp fudgetime2;
  670.     long fudgeval1;
  671.     long fudgeval2;
  672. };
  673.  
  674.  
  675. /*
  676.  * Structure used for setting clock fudge factors
  677.  */
  678. struct conf_fudge {
  679.     u_long clockadr;
  680.     u_long which;
  681.     l_fp fudgetime;
  682.     long fudgeval_flags;
  683. };
  684.  
  685. #define    FUDGE_TIME1    1
  686. #define    FUDGE_TIME2    2
  687. #define    FUDGE_VAL1    3
  688. #define    FUDGE_VAL2    4
  689. #define    FUDGE_FLAGS    5
  690.  
  691.  
  692. /*
  693.  * Structure used for returning clock debugging info
  694.  */
  695. #define    NUMCBUGVALUES    16
  696. #define    NUMCBUGTIMES    32
  697.  
  698. struct info_clkbug {
  699.     u_long clockadr;
  700.     u_char nvalues;
  701.     u_char ntimes;
  702.     u_short svalues;
  703.     u_long stimes;
  704.     u_long values[NUMCBUGVALUES];
  705.     l_fp times[NUMCBUGTIMES];
  706. };
  707.