ntp.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1991, 2000, 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#ifndef _NTP_H
#define _NTP_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/* $Revision: 3.4.1.5 $ $Date: 89/04/10 15:55:42 $ */
/*
* $Log: ntp.h,v $
* Revision 3.4.1.5 89/04/10 15:55:42 louie
* Window shift mask inside of conditional code on XTAL so we get the correct
* value if configured without a crystal controled clock (!!)
*
* Revision 3.4.1.4 89/03/31 16:34:50 louie
* Add bit in flags which allow a peer to be synced to. Changed a char to a bit
* field so that it is always signed.
*
* Revision 3.4.1.3 89/03/29 12:26:18 louie
* Removed some unused #defines. Replaced MAXSTRATUM with NTP_INFIN per new
* spec. The variable 'mode' in the peer structure has been renamed 'hmode'
* per the new spec.
*
* Revision 3.4.1.2 89/03/22 18:28:18 louie
* patch3: Use new RCS headers.
*
* Revision 3.4.1.1 89/03/20 00:02:53 louie
* 1
*
* Revision 3.4 89/03/17 18:37:00 louie
* Latest test release.
*
* Revision 3.3.1.1 89/03/17 18:23:49 louie
* Change CLOCK_FACTOR to be a power of 2.
*
* Revision 3.3 89/03/15 14:19:36 louie
* New baseline for next release.
*
* Revision 3.2.1.2 89/03/15 13:46:52 louie
* The version number for that particular flavor of ntpd <--> ntpdc interaction
* is now defined by NTPDC_VERSION. The packet format for the ntpdc program
* has changed slightly to improve robustness when dealing with multiple packets
* of status data.
*
* Revision 3.2.1.1 89/03/09 17:11:24 louie
* patch1: Updated constants, which were previously in incorrect units.
*
* Revision 3.2 89/03/07 18:21:45 louie
* New version of UNIX NTP daemon and software based on the 6 March 1989
* draft of the new NTP protocol specification. This version doesn't
* implement authentication, and accepts and send only NTP Version 1
* packets.
*
* Revision 3.1.1.1 89/02/15 08:54:42 louie
* *** empty log message ***
*
*
* Revision 3.1 89/01/30 14:43:07 louie
* Second UNIX NTP test release.
*
* Revision 3.0 88/12/12 16:01:07 louie
* Test release of new UNIX NTP software. This version should conform to the
* revised NTP protocol specification.
*
*/
#ifndef FD_SET
#define NFDBITS 32
#define FD_SETSIZE 32
#endif
#ifndef NBBY
#endif
#define MAXNETIF 10
struct intf {
int fd;
char *name;
struct sockaddr_in sin;
struct sockaddr_in bcast;
struct sockaddr_in mask;
int uses;
int if_flags;
};
extern int nintf;
/*
* Definitions for the masses
*/
/*
* Daemon specific (ntpd.c)
*/
#ifndef WAYTOOBIG
/* really wrong */
#endif
#ifndef XTAL
#endif
#ifndef NTPINITFILE
#define NTPINITFILE "/etc/ntp.conf"
#endif
struct list {
int members;
};
/*
* Definitions outlined in the NTP spec
*/
#define NTP_VERSION 1
#define NTP_INFIN 15
#define NTP_MAXAGE 86400
/* clock selection */
#if XTAL == 0
#define PEER_SHIFT 4
#define NTP_WINDOW_SHIFT_MASK 0x0f
#else
#define PEER_SHIFT 8
#define NTP_WINDOW_SHIFT_MASK 0xff
#endif
/*
* 5.1 Uniform Phase Adjustments
* Clock parameters
*/
#if XTAL
#else
#define CLOCK_ADJ 0
#endif
#define CLOCK_TRACK 8
#define CLOCK_COMP 4
#define CLOCK_FACTOR 18
/*
* Structure definitions for NTP fixed point values
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Integer Part |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Fraction Part |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Integer Part | Fraction Part |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct l_fixedpt {
};
struct s_fixedpt {
};
/*
* ================= Table 3.3. Packet Variables =================
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |LI | VN | Mode| Stratum | Poll | Precision |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Synchronizing Distance |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Synchronizing Dispersion |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Reference Clock Identifier |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* | Reference Timestamp (64 bits) |
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* | Originate Timestamp (64 bits) |
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* | Receive Timestamp (64 bits) |
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* | Transmit Timestamp (64 bits) |
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encryption Keyid (32 bits, when A bit set) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | |
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define MAC_OCTETS_DES 8
#define MAC_OCTETS_MD5 16
#define MAC_OCTETS_MIN MAC_OCTETS_DES
#define MAC_OCTETS_MAX MAC_OCTETS_MD5
struct ntpdata {
int precision:8;
struct s_fixedpt dispersion;
};
/*
* Leap Second Codes (high order two bits)
*/
/*
* Clock Status Bits that Encode Version
*/
#define NTPVERSION_1 0x08
#define VERSIONMASK 0x38
#define LEAPMASK 0xc0
#define NTPMODEMASK 0x07
/*
* Code values
*/
#define MODE_UNSPEC 0 /* unspecified */
/*
* Stratum Definitions
*/
#define UNSPECIFIED 0
/* ================= table 3.2 Peer Variables ================= */
struct ntp_peer {
int flags; /* local flags */
#define PEER_FL_CONFIG 1
#define PEER_FL_AUTHENABLE 2
int sock; /* index into sockets to derive */
/* peer.dstadr and peer.dstport */
short precision; /* receive */
long stopwatch; /* <<local>> for timing */
/*
* first order offsets
*/
struct filter {
short samples; /* <<local>> */
double offset[PEER_SHIFT];
double delay[PEER_SHIFT];
} filter; /* filter, clear */
double estdelay; /* filter */
double estoffset; /* filter */
double estdisp; /* filter */
};
/* ================= table 3.1: System Variables ================= */
struct sysdata { /* procedure */
short precision; /* system */
int hold; /* clock update */
int maxpeers; /* <<local>> */
};
#define NTPDC_VERSION 2
/*
* These structures are used to pass information to the ntpdc (control)
* program. They are unique to this implementation and not part of the
* NTP specification.
*/
struct clockinfo {
int precision:8;
long estdisp; /* scaled by 1000 */
long estdelay; /* in milliseconds */
long estoffset; /* in milliseconds */
struct info_filter {
short index;
short filler;
} info_filter;
};
struct ntpinfo {
};
/*
* Definition of a mode 6 packet.
*/
struct ntp_control {
};
/*
* Decoding for the r_m_e_op field
*/
#define CTL_RESPONSE 0x80
#define CTL_ERROR 0x40
#define CTL_MORE 0x20
#define CTL_OP_MASK 0x1f
/*
* Opcodes
*/
#define CTL_OP_UNSPEC 0
#define CTL_OP_READSTAT 1
#define CTL_OP_READVAR 2
#define CTL_OP_WRITEVAR 3
#define CTL_OP_READCLOCK 4
#define CTL_OP_WRITECLOCK 5
#define CTL_OP_SETTRAP 6
#define CTL_OP_ASYNCMSG 7
#define CTL_OP_UNSETTRAP 31
/*
* A mode 7 packet is used exchanging data between an NTP server
* and a client for purposes other than time synchronization, e.g.
* monitoring, statistics gathering and configuration. A mode 7
* packet has the following format:
*/
struct ntp_private {
};
#define RESP_BIT 0x80
#define MORE_BIT 0x40
#define AUTH_BIT 0x80
#ifdef __cplusplus
}
#endif
#endif /* _NTP_H */