summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.in14
-rw-r--r--include/audio.h2
-rw-r--r--include/binio.h10
-rw-r--r--include/icom.h2
-rw-r--r--include/isc/Makefile.in14
-rw-r--r--include/mbg_gps166.h1195
-rw-r--r--include/ntp.h35
-rw-r--r--include/ntp_calendar.h6
-rw-r--r--include/ntp_config.h5
-rw-r--r--include/ntp_filegen.h2
-rw-r--r--include/ntp_fp.h5
-rw-r--r--include/ntp_md5.h2
-rw-r--r--include/ntp_random.h3
-rw-r--r--include/ntp_stdlib.h10
-rw-r--r--include/ntpd.h17
-rw-r--r--include/parse.h49
-rw-r--r--include/parse_conf.h14
-rw-r--r--include/timepps-Solaris.h2
18 files changed, 938 insertions, 449 deletions
diff --git a/include/Makefile.in b/include/Makefile.in
index e50f270..cb21004 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -40,8 +40,7 @@ DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -52,6 +51,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_cacheversion.m4 \
$(top_srcdir)/sntp/m4/ntp_compiler.m4 \
$(top_srcdir)/sntp/m4/ntp_crosscompile.m4 \
+ $(top_srcdir)/sntp/m4/ntp_crypto_rand.m4 \
$(top_srcdir)/sntp/m4/ntp_debug.m4 \
$(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
$(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
@@ -69,6 +69,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -150,6 +152,7 @@ CHUTEST = @CHUTEST@
CONFIG_SHELL = @CONFIG_SHELL@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
CPPFLAGS_NTP = @CPPFLAGS_NTP@
CXX = @CXX@
CXXCPP = @CXXCPP@
@@ -184,7 +187,9 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
+LDADD_LIBEVENT = @LDADD_LIBEVENT@
LDADD_LIBNTP = @LDADD_LIBNTP@
+LDADD_LIBUTIL = @LDADD_LIBUTIL@
LDADD_NLIST = @LDADD_NLIST@
LDADD_NTP = @LDADD_NTP@
LDFLAGS = @LDFLAGS@
@@ -323,6 +328,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/include/audio.h b/include/audio.h
index 1b969bd..0d74226 100644
--- a/include/audio.h
+++ b/include/audio.h
@@ -9,6 +9,6 @@
/*
* Function prototypes
*/
-int audio_init (char *, int, int);
+int audio_init (const char *, int, int);
int audio_gain (int, int, int);
void audio_show (void);
diff --git a/include/binio.h b/include/binio.h
index d1ee944..cf98633 100644
--- a/include/binio.h
+++ b/include/binio.h
@@ -42,11 +42,21 @@ void put_lsb_short (unsigned char **, long);
long get_lsb_long (unsigned char **);
void put_lsb_long (unsigned char **, long);
+#define get_lsb_int16( _x_ ) ((int16_t) get_lsb_short( _x_ ))
+#define get_lsb_uint16( _x_ ) ((uint16_t) get_lsb_short( _x_ ))
+#define get_lsb_int32( _x_ ) ((int32_t) get_lsb_long( _x_ ))
+#define get_lsb_uint32( _x_ ) ((uint32_t) get_lsb_long( _x_ ))
+
long get_msb_short (unsigned char **);
void put_msb_short (unsigned char **, long);
long get_msb_long (unsigned char **);
void put_msb_long (unsigned char **, long);
+#define get_msb_int16( _x_ ) ((int16_t) get_msb_short( _x_ ))
+#define get_msb_uint16( _x_ ) ((uint16_t) get_msb_short( _x_ ))
+#define get_msb_int32( _x_ ) ((int32_t) get_msb_long( _x_ ))
+#define get_msb_uint32( _x_ ) ((uint32_t) get_msb_long( _x_ ))
+
#endif
/*
* History:
diff --git a/include/icom.h b/include/icom.h
index 66d12e5..b271afb 100644
--- a/include/icom.h
+++ b/include/icom.h
@@ -83,5 +83,5 @@
/*
* Function prototypes
*/
-int icom_init (char *, int, int);
+int icom_init (const char *, int, int);
int icom_freq (int, int, double);
diff --git a/include/isc/Makefile.in b/include/isc/Makefile.in
index af01dcd..ad0da46 100644
--- a/include/isc/Makefile.in
+++ b/include/isc/Makefile.in
@@ -40,8 +40,7 @@ DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -52,6 +51,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_cacheversion.m4 \
$(top_srcdir)/sntp/m4/ntp_compiler.m4 \
$(top_srcdir)/sntp/m4/ntp_crosscompile.m4 \
+ $(top_srcdir)/sntp/m4/ntp_crypto_rand.m4 \
$(top_srcdir)/sntp/m4/ntp_debug.m4 \
$(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
$(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
@@ -69,6 +69,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -112,6 +114,7 @@ CHUTEST = @CHUTEST@
CONFIG_SHELL = @CONFIG_SHELL@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
CPPFLAGS_NTP = @CPPFLAGS_NTP@
CXX = @CXX@
CXXCPP = @CXXCPP@
@@ -146,7 +149,9 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
+LDADD_LIBEVENT = @LDADD_LIBEVENT@
LDADD_LIBNTP = @LDADD_LIBNTP@
+LDADD_LIBUTIL = @LDADD_LIBUTIL@
LDADD_NLIST = @LDADD_NLIST@
LDADD_NTP = @LDADD_NTP@
LDFLAGS = @LDFLAGS@
@@ -285,6 +290,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/include/mbg_gps166.h b/include/mbg_gps166.h
index 974deba..b9b3d77 100644
--- a/include/mbg_gps166.h
+++ b/include/mbg_gps166.h
@@ -39,206 +39,459 @@
#define MBG_GPS166_H
-/***************************************************************************/
-/* */
-/* File: GPSSERIO.H 4.1 */
-/* */
-/* Project: Common C Library */
-/* */
-/* Compiler: Borland C++ */
-/* */
-/* Author: M. Burnicki, Meinberg Funkuhren */
-/* */
-/* */
-/* Description: */
-/* This file defines structures and codes to be used to access GPS166 */
-/* via its serial interface COM0. COM0 should be set to a high baud */
-/* rate, default is 19200. */
-/* */
-/* Standard GPS166 serial operation is to send a time string that is */
-/* compatible with Meinberg UA31 or PZF535 DCF77 radio remote clocks. */
-/* That string can be transmitted automatically once per second, once */
-/* per minute or on request per ASCII '?'. */
-/* */
-/* Parameter setup or parameter readout works using blocks of binary */
-/* data which have to be isolated from the standard string. A block of */
-/* data starts with a SOH code (ASCII Start Of Header, 0x01) followed */
-/* by a message header with constant length and a data portion with */
-/* variable length. The first field (cmd) of the message header holds */
-/* the command code rsp. the type of data to be transmitted. The next */
-/* field (len) gives the number of data bytes that are transmitted */
-/* after the header. This number ranges from 0 to sizeof( MSG_DATA ). */
-/* The third field (data_csum) holds a checksum of all data bytes and */
-/* the last field of the header finally holds the checksum of the. */
-/* header. */
-/* */
-/***************************************************************************/
-
-/* the control codes defined below are to be or'ed with a command/type code */
-
-#define GPS_REQACK 0x8000 /* to GPS166: request acknowledge */
-#define GPS_ACK 0x4000 /* from GPS166: acknowledge a command */
-#define GPS_NACK 0x2000 /* from GPS166: error receiving command */
-
-#define GPS_CTRL_MSK 0xF000 /* masks control code from command */
-
-
-/* The codes below specify commands/types of data to be supplied to GPS166: */
-
-/* GPS166 auto-message to host */
-/* þ host request, GPS166 response */
-/* þ þ host download to GPS166 */
-/* þ þ þ */
-enum { /* þ þ þ */
- /* system data */
- GPS_AUTO_ON = 0x000, /* þ þ þ X þ enable auto-messages from GPS166 */
- GPS_AUTO_OFF, /* þ þ þ X þ disable auto-messages from GPS166 */
- GPS_SW_REV, /* þ þ X þ þ request software revision */
- GPS_STAT, /* þ þ X þ þ request status of buffered variables */
- GPS_TIME, /* þ X þ þ X þ current time or capture or init board time */
- GPS_POS_XYZ, /* þ þ X þ X þ current position in ECEF coords */
- GPS_POS_LLA, /* þ þ X þ X þ current position in geographic coords */
- GPS_TZDL, /* þ þ X þ X þ time zone / daylight saving */
- GPS_PORT_PARM, /* þ þ X þ X þ parameters of the serial ports */
- GPS_SYNTH, /* þ þ X þ X þ synthesizer's frequency and phase */
- GPS_ANT_INFO, /* þ X þ X þ þ time diff after antenna disconnect */
- GPS_UCAP, /* þ X þ X þ þ user capture */
+/***************************************************************************
+ *
+ * Definitions taken from Meinberg's gpsserio.h and gpsdefs.h files.
+ *
+ * Author: Martin Burnicki, Meinberg Funkuhren
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Structures and codes to be used to access Meinberg GPS clocks via
+ * their serial interface COM0. COM0 should be set to a high baud rate,
+ * default is 19200.
+ *
+ * Standard Meinberg GPS serial operation is to send the Meinberg
+ * standard time string automatically once per second, once per
+ * minute, or on request per ASCII '?'.
+ *
+ * GPS parameter setup or parameter readout uses blocks of binary
+ * data which have to be isolated from the standard string. A block
+ * of data starts with a SOH code (ASCII Start Of Header, 0x01)
+ * followed by a message header with constant length and a block of
+ * data with variable length.
+ *
+ * The first field (cmd) of the message header holds the command
+ * code resp. the type of data to be transmitted. The next field (len)
+ * gives the number of data bytes that follow the header. This number
+ * ranges from 0 to sizeof( MSG_DATA ). The third field (data_csum)
+ * holds a checksum of all data bytes and the last field of the header
+ * finally holds the checksum of the header itself.
+ *
+ ***************************************************************************/
+
+/**
+ * @brief GPS epoch bias from ordinary time_t epoch
+ *
+ * The Unix time_t epoch is usually 1970-01-01 00:00 whereas
+ * the GPS epoch is 1980-01-06 00:00, so the difference is 10 years,
+ * plus 2 days due to leap years (1972 and 1976), plus the difference
+ * of the day-of-month (6 - 1), so:<br>
+ *
+ * time_t t = ( gps_week * ::SECS_PER_WEEK ) + sec_of_week + ::GPS_SEC_BIAS
+ */
+#define GPS_SEC_BIAS 315964800UL // ( ( ( 10UL * 365UL ) + 2 + 5 ) * SECS_PER_DAY )
+
+
+#ifndef _COM_HS_DEFINED
+ /**
+ * @brief Enumeration of handshake modes
+ */
+ enum COM_HANSHAKE_MODES { HS_NONE, HS_XONXOFF, HS_RTSCTS, N_COM_HS };
+ #define _COM_HS_DEFINED
+#endif
+
+#ifndef _COM_PARM_DEFINED
+ /**
+ * @brief A data type to configure a serial port's baud rate
+ *
+ * @see ::MBG_BAUD_RATES
+ */
+ typedef int32_t BAUD_RATE;
+
+ /**
+ * @brief Indices used to identify a parameter in the framing string
+ *
+ * @see ::MBG_FRAMING_STRS
+ */
+ enum MBG_FRAMING_STR_IDXS { F_DBITS, F_PRTY, F_STBITS };
+
+ /**
+ * @brief A structure to store the configuration of a serial port
+ */
+ typedef struct
+ {
+ BAUD_RATE baud_rate; ///< transmission speed, e.g. 19200L, see ::MBG_BAUD_RATES
+ char framing[4]; ///< ASCIIZ framing string, e.g. "8N1" or "7E2", see ::MBG_FRAMING_STRS
+ int16_t handshake; ///< handshake mode, yet only ::HS_NONE supported
+
+ } COM_PARM;
+
+ #define _COM_PARM_DEFINED
+#endif
+
+
+/**
+ * @brief Enumeration of modes supported for time string transmission
+ *
+ * This determines e.g. at which point in time a string starts
+ * to be transmitted via the serial port.
+ * Used with ::PORT_SETTINGS::mode.
+ *
+ * @see ::STR_MODE_MASKS
+ */
+enum STR_MODES
+{
+ STR_ON_REQ, ///< transmission on request by received '?' character only
+ STR_PER_SEC, ///< transmission automatically if second changes
+ STR_PER_MIN, ///< transmission automatically if minute changes
+ STR_AUTO, ///< transmission automatically if required, e.g. on capture event
+ STR_ON_REQ_SEC, ///< transmission if second changes and a request has been received before
+ N_STR_MODE ///< the number of known modes
+};
+
+
+/**
+ * The number of serial ports which are at least available
+ * even with very old GPS receiver models. For devices providing
+ * a ::RECEIVER_INFO structure the number of provided COM ports
+ * is available in ::RECEIVER_INFO::n_com_ports.
+ */
+#define DEFAULT_N_COM 2
+
+
+/**
+ * @brief A The structure used to store the configuration of two serial ports
+ *
+ * @deprecated This structure is deprecated, ::PORT_SETTINGS and related structures
+ * should be used instead, if supported by the device.
+ */
+typedef struct
+{
+ COM_PARM com[DEFAULT_N_COM]; ///< COM0 and COM1 settings
+ uint8_t mode[DEFAULT_N_COM]; ///< COM0 and COM1 output mode
+
+} PORT_PARM;
+
+
+/**
+ * @brief The type of a GPS command code
+ *
+ * @see ::GPS_CMD_CODES
+ */
+typedef uint16_t GPS_CMD;
+
+
+/**
+ * @brief Control codes to be or'ed with a particular command/type code
+ */
+enum GPS_CMD_CTRL_CODES
+{
+ GPS_REQACK = 0x8000, ///< to device: request acknowledge
+ GPS_ACK = 0x4000, ///< from device: acknowledge a command
+ GPS_NACK = 0x2000, ///< from device: error evaluating a command
+};
+
+#define GPS_CTRL_MSK 0xF000 ///< bit mask of all ::GPS_CMD_CTRL_CODES
+
+
+/**
+ * @brief Command codes for the binary protocol
+ *
+ * These codes specify commands and associated data types used by Meinberg's
+ * binary protocol to exchange data with a device via serial port, direct USB,
+ * or socket I/O.
+ *
+ * Some commands and associated data structures can be read (r) from a device, others
+ * can be written (w) to the device, and some can also be sent automatically (a) by
+ * a device after a ::GPS_AUTO_ON command has been sent to the device.
+ * The individual command codes are marked with (rwa) accordingly, where '-' is used
+ * to indicate that a particular mode is not supported.
+ *
+ * @note Not all command code are supported by all devices.
+ * See the hints for a particular command.
+ *
+ * @note If ::GPS_ALM, ::GPS_EPH or a code named ..._IDX is sent to retrieve
+ * some data from a device then an uint16_t parameter must be also supplied
+ * in order to specify the index number of the data set to be returned.
+ * The valid index range depends on the command code.
+ * For ::GPS_ALM and ::GPS_EPH the index is the SV number which may be 0 or
+ * ::MIN_SVNO_GPS to ::MAX_SVNO_GPS. If the number is 0 then all ::N_SVNO_GPS
+ * almanacs or ephemeris data structures are returned.
+ *
+ * @see ::GPS_CMD_CODES_TABLE
+ */
+enum GPS_CMD_CODES
+{ /* system data */
+ GPS_AUTO_ON = 0x000, ///< (-w-) no data, enable auto-msgs from device
+ GPS_AUTO_OFF, ///< (-w-) no data, disable auto-msgs from device
+ GPS_SW_REV, ///< (r--) deprecated, ::SW_REV, software revision, use only if ::GPS_RECEIVER_INFO not supp.
+ GPS_BVAR_STAT, ///< (r--) ::BVAR_STAT, status of buffered variables, only if ::GPS_MODEL_HAS_BVAR_STAT
+ GPS_TIME, ///< (-wa) ::TTM, current time or capture, or init board time
+ GPS_POS_XYZ, ///< (rw-) ::XYZ, current position in ECEF coordinates, only if ::GPS_MODEL_HAS_POS_XYZ
+ GPS_POS_LLA, ///< (rw-) ::LLA, current position in geographic coordinates, only if ::GPS_MODEL_HAS_POS_LLA
+ GPS_TZDL, ///< (rw-) ::TZDL, time zone / daylight saving, only if ::GPS_MODEL_HAS_TZDL
+ GPS_PORT_PARM, ///< (rw-) deprecated, ::PORT_PARM, use ::PORT_SETTINGS etc. if ::GPS_RECEIVER_INFO supported
+ GPS_SYNTH, ///< (rw-) ::SYNTH, synthesizer settings, only if ::GPS_HAS_SYNTH
+ GPS_ANT_INFO, ///< (r-a) ::ANT_INFO, time diff after antenna disconnect, only if ::GPS_MODEL_HAS_ANT_INFO
+ GPS_UCAP, ///< (r-a) ::TTM, user capture events, only if ::RECEIVER_INFO::n_ucaps > 0
/* GPS data */
- GPS_CFGH = 0x100, /* þ þ X þ X þ SVs' configuration and health codes */
- GPS_ALM, /* þ þ X þ X þ one SV's almanac */
- GPS_EPH, /* þ þ X þ X þ one SV's ephemeris */
- GPS_UTC, /* þ þ X þ X þ UTC correction parameters */
- GPS_IONO, /* þ þ X þ X þ ionospheric correction parameters */
- GPS_ASCII_MSG /* þ þ X þ þ the GPS ASCII message */
+ GPS_CFGH = 0x100, ///< (rw-) ::CFGH, SVs' configuration and health codes
+ GPS_ALM, ///< (rw-) req: uint16_t SV num, ::SV_ALM, one SV's almanac
+ GPS_EPH, ///< (rw-) req: uint16_t SV num, ::SV_EPH, one SV's ephemeris
+ GPS_UTC, ///< (rw-) ::UTC, GPS %UTC correction parameters
+ GPS_IONO, ///< (rw-) ::IONO, GPS ionospheric correction parameters
+ GPS_ASCII_MSG ///< (r--) ::ASCII_MSG, the GPS ASCII message
};
-/*
- * modelled after GPSDEFS.H Revision 1.5
- */
-/***************************************************************************/
-/* */
-/* File: GPSDEFS.H 4.1 */
-/* */
-/* Project: Common C Library */
-/* */
-/* Compiler: Borland C++ */
-/* */
-/* Author: M. Burnicki, Meinberg Funkuhren */
-/* */
-/* */
-/* Description: */
-/* General definitions to be used with GPS166 */
-/* GPS166 Rev. 1.23 or above */
-/* */
-/* Modifications: see file GPSLIB.TXT */
-/* */
-/***************************************************************************/
-#define _GPSDEFS_H
-/* the type of various checksums */
#ifndef _CSUM_DEFINED
- typedef unsigned short CSUM;
-# define _CSUM_DEFINED
+ typedef uint16_t CSUM; /* checksum used by some structures stored in non-volatile memory */
+ #define _CSUM_DEFINED
#endif
-/* the message header */
-typedef struct {
- unsigned short gps_cmd;
- unsigned short gps_len;
- unsigned short gps_data_csum;
- unsigned short gps_hdr_csum;
+/**
+ * @brief The header of a binary message.
+ */
+typedef struct
+{
+ GPS_CMD cmd; ///< see ::GPS_CMD_CODES
+ uint16_t len; ///< length of the data portion appended after the header
+ CSUM data_csum; ///< checksum of the data portion appended after the header
+ CSUM hdr_csum; ///< checksum of the preceding header bytes
+
} GPS_MSG_HDR;
-/* a struct used to hold the software revision information */
-typedef struct {
- unsigned short code; /* e.g. 0x0120 means rev. 1.20 */
- unsigned char name[17]; /* used to identify customized versions */
+#define GPS_ID_STR_LEN 16
+#define GPS_ID_STR_SIZE ( GPS_ID_STR_LEN + 1 )
+
+/**
+ * @brief Software revision information
+ *
+ * Contains a software revision code, plus an optional
+ * identifier for a customized version.
+ */
+typedef struct
+{
+ uint16_t code; ///< Version number, e.g. 0x0120 means v1.20
+ char name[GPS_ID_STR_SIZE]; ///< Optional string identifying a customized version
+ uint8_t reserved; ///< Reserved field to yield even structure size
+
} SW_REV;
-/* GPS ASCII message */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
- char s[23]; /* 22 chars GPS ASCII message plus trailing zero */
-} ASCII_MSG;
+/**
+ * @brief GNSS satellite numbers
+ *
+ * @todo: Check if MAX_SVNO_GLN is 94 instead of 95, and thus
+ * N_SVNO_GLN is 30 instead of 31, as reported by Wikipedia.
+ */
+enum GNSS_SVNOS
+{
+ MIN_SVNO_GPS = 1, ///< min. GPS satellite PRN number
+ MAX_SVNO_GPS = 32, ///< max. GPS satellite PRN number
+ N_SVNO_GPS = 32, ///< max. number of active GPS satellites
+
+ MIN_SVNO_WAAS = 33, ///< min. WAAS satellite number
+ MAX_SVNO_WAAS = 64, ///< max. WAAS satellite number
+ N_SVNO_WAAS = 32, ///< max. number of active WAAS satellites
+
+ MIN_SVNO_GLONASS = 65, ///< min. Glonass satellite number (64 + sat slot ID)
+ MAX_SVNO_GLONASS = 95, ///< max. Glonass satellite number (64 + sat slot ID)
+ N_SVNO_GLONASS = 31 ///< max. number of active Glonass satellites
+};
+
+
+typedef uint16_t SVNO; ///< the number of an SV (Space Vehicle, i.e. satellite)
+typedef uint16_t HEALTH; ///< an SV's 6 bit health code
+typedef uint16_t CFG; ///< an SV's 4 bit configuration code
+typedef uint16_t IOD; ///< Issue-Of-Data code
+
+
+/**
+ * @brief Status flags of battery buffered data
+ *
+ * Related to data received from the satellites, or data derived thereof.
+ *
+ * All '0' means OK, single bits set to '1' indicate
+ * the associated type of GPS data is not available.
+ *
+ * @see ::BVAR_FLAGS
+ */
+typedef uint16_t BVAR_STAT;
+
+#define _mbg_swab_bvar_stat( _p ) _mbg_swab16( (_p) )
-#define MIN_SVNO 1 /* min. SV number */
-#define MAX_SVNO 32 /* max. SV number */
-#define N_SVNO ( MAX_SVNO - MIN_SVNO + 1) /* number of possibly active SVs */
+/**
+ * @brief Enumeration of flag bits used to define ::BVAR_FLAGS
+ *
+ * For each bit which is set this means the associated data set in
+ * non-volatile memory is not available, or incomplete.
+ * Most data sets will just be re-collected from the data streams sent
+ * by the satellites. However, the receiver position has usually been
+ * computed earlier during normal operation, and will be re-computed
+ * when a sufficient number of satellites can be received.
+ *
+ * @see ::BVAR_STAT
+ * @see ::BVAR_FLAGS
+ * @see ::BVAR_FLAG_NAMES
+ */
+enum BVAR_FLAG_BITS
+{
+ BVAR_BIT_CFGH_INVALID, ///< Satellite configuration and health parameters incomplete
+ BVAR_BIT_ALM_NOT_COMPLETE, ///< Almanac parameters incomplete
+ BVAR_BIT_UTC_INVALID, ///< %UTC offset parameters incomplete
+ BVAR_BIT_IONO_INVALID, ///< Ionospheric correction parameters incomplete
+ BVAR_BIT_RCVR_POS_INVALID, ///< No valid receiver position available
+ N_BVAR_BIT ///< number of defined ::BVAR_STAT bits
+};
+
+
+/**
+ * @brief Bit masks associated with ::BVAR_FLAG_BITS
+ *
+ * Used with ::BVAR_STAT.
+ *
+ * @see ::BVAR_STAT
+ * @see ::BVAR_FLAG_BITS
+ * @see ::BVAR_FLAG_NAMES
+ */
+enum BVAR_FLAGS
+{
+ BVAR_CFGH_INVALID = ( 1UL << BVAR_BIT_CFGH_INVALID ), ///< see ::BVAR_BIT_CFGH_INVALID
+ BVAR_ALM_NOT_COMPLETE = ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ), ///< see ::BVAR_BIT_ALM_NOT_COMPLETE
+ BVAR_UTC_INVALID = ( 1UL << BVAR_BIT_UTC_INVALID ), ///< see ::BVAR_BIT_UTC_INVALID
+ BVAR_IONO_INVALID = ( 1UL << BVAR_BIT_IONO_INVALID ), ///< see ::BVAR_BIT_IONO_INVALID
+ BVAR_RCVR_POS_INVALID = ( 1UL << BVAR_BIT_RCVR_POS_INVALID ), ///< see ::BVAR_BIT_RCVR_POS_INVALID
+};
-typedef short SVNO; /* the number of a SV */
-typedef unsigned short HEALTH; /* a SV's health code */
-typedef unsigned short CFG; /* a SV's configuration code */
-typedef unsigned short IOD; /* Issue-Of-Data code */
-/* Date and time referred to the linear time scale defined by GPS. */
-/* GPS time is defined by the number of weeks since midnight from */
-/* January 5, 1980 to January 6, 1980 plus the number of seconds of */
-/* the current week plus fractions of a second. GPS time differs from */
-/* UTC because UTC is corrected with leap seconds while GPS time scale */
-/* is continuous. */
+/**
+ * @brief A structure used to hold time in GPS format
+ *
+ * Date and time refer to the linear time scale defined by GPS, with
+ * the epoch starting at %UTC midnight at the beginning of January 6, 1980.
+ *
+ * GPS time is counted by the week numbers since the epoch, plus second
+ * of the week, plus fraction of the second. The week number transmitted
+ * by the satellites rolls over from 1023 to 0, but Meinberg devices
+ * just continue to count the weeks beyond the 1024 week limit to keep
+ * the receiver's internal time.
+ *
+ * %UTC time differs from GPS time since a number of leap seconds have
+ * been inserted in the %UTC time scale after the GPS epoche. The number
+ * of leap seconds is disseminated by the satellites using the ::UTC
+ * parameter set, which also provides info on pending leap seconds.
+ */
+typedef struct
+{
+ uint16_t wn; ///< the week number since GPS has been installed
+ uint32_t sec; ///< the second of that week
+ uint32_t tick; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units
-typedef struct {
- unsigned short wn; /* the week number since GPS has been installed */
- unsigned long sec; /* the second of that week */
- unsigned long tick; /* fractions of a second; scale: 1E-7 */
} T_GPS;
-/* Local date and time computed from GPS time. The current number */
-/* of leap seconds have to be added to get UTC from GPS time. */
-/* Additional corrections could have been made according to the */
-/* time zone/daylight saving parameters (TZDL, see below) defined */
-/* by the user. The status field can be checked to see which corrections */
-/* have been applied. */
-
-#ifndef GPS166_TM_DEFINED
- typedef struct {
- short year; /* 0..9999 */
- char month; /* 1..12 */
- char mday; /* 1..31 */
- short yday; /* 1..366 */
- char wday; /* 0..6 == Sun..Sat */
- char hour; /* 0..23 */
- char minute; /* 0..59 */
- char second; /* 0..59 */
- long frac; /* fractions of a second, scale 1E-7 */
- long offs_from_utc; /* local time's offset from UTC */
- unsigned short status; /* flags */
- } TM;
-
- /* status flags used with conversion from GPS time to local time */
-
-# define TM_UTC 0x01 /* UTC correction has been made */
-# define TM_LOCAL 0x02 /* UTC has been converted to local time */
-# define TM_DL_ANN 0x04 /* state of daylight saving is going to change */
-# define TM_DL_ENB 0x08 /* daylight saving is enabled */
-# define TM_LS_ANN 0x10 /* leap second will be inserted */
-# define TM_LS_ENB 0x20 /* current second is leap second */
-
-# define GPS166_TM_DEFINED
-#endif
+/**
+ * @brief Local date and time computed from GPS time
+ *
+ * The current number of leap seconds have to be added to get %UTC
+ * from GPS time. Additional corrections could have been made according
+ * to the time zone/daylight saving parameters ::TZDL defined by the user.
+ * The status field can be checked to see which corrections
+ * have actually been applied.
+ *
+ * @note Conversion from GPS time to %UTC and/or local time can only be
+ * done if some valid ::UTC correction parameters are available in the
+ * receiver's non-volatile memory.
+ */
+typedef struct
+{
+ int16_t year; ///< year number, 0..9999
+ int8_t month; ///< month, 1..12
+ int8_t mday; ///< day of month, 1..31
+ int16_t yday; ///< day of year, 1..365, or 366 in case of leap year
+ int8_t wday; ///< day of week, 0..6 == Sun..Sat
+ int8_t hour; ///< hours, 0..23
+ int8_t min; ///< minutes, 0..59
+ int8_t sec; ///< seconds, 0..59, or 60 in case of inserted leap second
+ int32_t frac; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units
+ int32_t offs_from_utc; ///< local time offset from %UTC [sec]
+ uint16_t status; ///< status flags, see ::TM_GPS_STATUS_BIT_MASKS
+
+} TM_GPS;
+
+
+
+/**
+ * @brief Status flag bits used to define ::TM_GPS_STATUS_BIT_MASKS
+ *
+ * These bits report info on the time conversion from GPS time to %UTC
+ * and/or local time as well as device status info.
+ *
+ * @see ::TM_GPS_STATUS_BIT_MASKS
+ */
+enum TM_GPS_STATUS_BITS
+{
+ TM_BIT_UTC, ///< %UTC correction has been made
+ TM_BIT_LOCAL, ///< %UTC has been converted to local time according to ::TZDL settings
+ TM_BIT_DL_ANN, ///< state of daylight saving is going to change
+ TM_BIT_DL_ENB, ///< daylight saving is in effect
+ TM_BIT_LS_ANN, ///< leap second pending
+ TM_BIT_LS_ENB, ///< current second is leap second
+ TM_BIT_LS_ANN_NEG, ///< set in addition to ::TM_BIT_LS_ANN if leap sec is negative
+ TM_BIT_INVT, ///< invalid time, e.g. if RTC battery bas been empty
+
+ TM_BIT_EXT_SYNC, ///< synchronized externally
+ TM_BIT_HOLDOVER, ///< in holdover mode after previous synchronization
+ TM_BIT_ANT_SHORT, ///< antenna cable short circuited
+ TM_BIT_NO_WARM, ///< OCXO has not warmed up
+ TM_BIT_ANT_DISCONN, ///< antenna currently disconnected
+ TM_BIT_SYN_FLAG, ///< TIME_SYN output is low
+ TM_BIT_NO_SYNC, ///< time sync actually not verified
+ TM_BIT_NO_POS ///< position actually not verified, LOCK LED off
+};
-/* the status flags below are defined starting with rev. 1.32 */
+/**
+ * @brief Status flag masks used with ::TM_GPS::status
+ *
+ * These bits report info on the time conversion from GPS time to %UTC
+ * and/or local time as well as device status info.
+ *
+ * @see ::TM_GPS_STATUS_BITS
+ */
+enum TM_GPS_STATUS_BIT_MASKS
+{
+ TM_UTC = ( 1UL << TM_BIT_UTC ), ///< see ::TM_BIT_UTC
+ TM_LOCAL = ( 1UL << TM_BIT_LOCAL ), ///< see ::TM_BIT_LOCAL
+ TM_DL_ANN = ( 1UL << TM_BIT_DL_ANN ), ///< see ::TM_BIT_DL_ANN
+ TM_DL_ENB = ( 1UL << TM_BIT_DL_ENB ), ///< see ::TM_BIT_DL_ENB
+ TM_LS_ANN = ( 1UL << TM_BIT_LS_ANN ), ///< see ::TM_BIT_LS_ANN
+ TM_LS_ENB = ( 1UL << TM_BIT_LS_ENB ), ///< see ::TM_BIT_LS_ENB
+ TM_LS_ANN_NEG = ( 1UL << TM_BIT_LS_ANN_NEG ), ///< see ::TM_BIT_LS_ANN_NEG
+ TM_INVT = ( 1UL << TM_BIT_INVT ), ///< see ::TM_BIT_INVT
+
+ TM_EXT_SYNC = ( 1UL << TM_BIT_EXT_SYNC ), ///< see ::TM_BIT_EXT_SYNC
+ TM_HOLDOVER = ( 1UL << TM_BIT_HOLDOVER ), ///< see ::TM_BIT_HOLDOVER
+ TM_ANT_SHORT = ( 1UL << TM_BIT_ANT_SHORT ), ///< see ::TM_BIT_ANT_SHORT
+ TM_NO_WARM = ( 1UL << TM_BIT_NO_WARM ), ///< see ::TM_BIT_NO_WARM
+ TM_ANT_DISCONN = ( 1UL << TM_BIT_ANT_DISCONN ), ///< see ::TM_BIT_ANT_DISCONN
+ TM_SYN_FLAG = ( 1UL << TM_BIT_SYN_FLAG ), ///< see ::TM_BIT_SYN_FLAG
+ TM_NO_SYNC = ( 1UL << TM_BIT_NO_SYNC ), ///< see ::TM_BIT_NO_SYNC
+ TM_NO_POS = ( 1UL << TM_BIT_NO_POS ) ///< see ::TM_BIT_NO_POS
+};
-#define TM_ANT_DISCONN 0x1000 /* antenna currently disconnected */
-#define TM_SYN_FLAG 0x2000 /* TIME_SYN output is low */
-#define TM_NO_SYNC 0x4000 /* not sync'ed after reset */
-#define TM_NO_POS 0x8000 /* position not computed after reset, */
- /* LOCK LED off */
-/* a struct used to transmit information on date and time */
+/**
+ * @brief A structure used to transmit information on date and time
+ *
+ * This structure can be used to transfer the current time, in which
+ * case the channel field has to be set to -1, or an event capture time
+ * retrieved from the on-board FIFO, in which case the channel field
+ * contains the index of the time capture input, e.g. 0 or 1.
+ */
+typedef struct
+{
+ int16_t channel; ///< -1: the current on-board time; >= 0 the capture channel number
+ T_GPS t; ///< time in GPS scale and format
+ TM_GPS tm; ///< time converted to %UTC and/or local time according to ::TZDL settings
-typedef struct {
- short channel; /* -1: the current time; 0, 1: capture 0, 1 */
- T_GPS t; /* time in GPS format */
- TM tm; /* that time converted to local time */
} TTM;
@@ -249,282 +502,462 @@ typedef struct {
/* to geographic coordinates as defined by WGS84 (World Geodetic */
/* System from 1984). */
-#ifndef _XYZ_DEFINED
- /* sequence and number of components of a cartesian position */
- enum { XP, YP, ZP, N_XYZ };
+/**
+ * @brief Sequence and number of components of a cartesian position
+ */
+enum XYZ_FIELDS { XP, YP, ZP, N_XYZ }; // x, y, z
+
+/**
+ * @brief A position in cartesian coordinates
+ *
+ * Usually earth centered, earth fixed (ECEF) coordinates,
+ * in [m].
+ *
+ * @note In the original code this is an array of double.
+ *
+ * @see ::XYZ_FIELDS
+ */
+typedef l_fp XYZ[N_XYZ];
- /* a type of array holding a cartesian position */
- typedef l_fp XYZ[N_XYZ]; /* values are in [m] */
-# define _XYZ_DEFINED
-#endif
+/**
+ * @brief Sequence and number of components of a geographic position
+ */
+enum LLA_FIELDS { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */
+/**
+ * @brief A geographic position based on latitude, longitude, and altitude
+ *
+ * The geographic position associated to specific cartesian coordinates
+ * depends on the characteristics of the ellipsoid used for the computation,
+ * the so-called geographic datum. GPS uses the WGS84 (World Geodetic System
+ * from 1984) ellipsoid by default.
+ *
+ * lon, lat in [rad], alt in [m]
+ *
+ * @note In the original code this is an array of double.
+ *
+ * @see ::LLA_FIELDS
+ */
+typedef l_fp LLA[N_LLA];
-#ifndef _LLA_DEFINED
- /* sequence and number of components of a geographic position */
- enum { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */
- /* a type of array holding a geographic position */
- typedef l_fp LLA[N_LLA]; /* lon, lat in [rad], alt in [m] */
+/**
+ * @defgroup group_synth Synthesizer parameters
+ *
+ * Synthesizer frequency is expressed as a
+ * four digit decimal number (freq) to be multiplied by 0.1 Hz and an
+ * base 10 exponent (range). If the effective frequency is less than
+ * 10 kHz its phase is synchronized corresponding to the variable phase.
+ * Phase may be in a range from -360 deg to +360 deg with a resolution
+ * of 0.1 deg, so the resulting numbers to be stored are in a range of
+ * -3600 to +3600.
+ *
+ * Example:<br>
+ * Assume the value of freq is 2345 (decimal) and the value of phase is 900.
+ * If range == 0 the effective frequency is 234.5 Hz with a phase of +90 deg.
+ * If range == 1 the synthesizer will generate a 2345 Hz output frequency
+ * and so on.
+ *
+ * Limitations:<br>
+ * If freq == 0 the synthesizer is disabled. If range == 0 the least
+ * significant digit of freq is limited to 0, 3, 5 or 6. The resulting
+ * frequency is shown in the examples below:
+ * - freq == 1230 --> 123.0 Hz
+ * - freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz)
+ * - freq == 1235 --> 123.5 Hz
+ * - freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz)
+ *
+ * If range == ::MAX_SYNTH_RANGE the value of freq must not exceed 1000, so
+ * the output frequency is limited to 10 MHz (see ::MAX_SYNTH_FREQ_VAL).
+ *
+ * @{ */
-# define _LLA_DEFINED
-#endif
+#define N_SYNTH_FREQ_DIGIT 4 ///< number of digits to edit
+#define MAX_SYNTH_FREQ 1000 ///< if range == ::MAX_SYNTH_RANGE
-/* Synthesizer parameters. Synthesizer frequency is expressed as a */
-/* four digit decimal number (freq) to be multiplied by 0.1 Hz and an */
-/* base 10 exponent (range). If the effective frequency is less than */
-/* 10 kHz its phase is synchronized corresponding to the variable phase. */
-/* Phase may be in a range from -360° to +360° with a resolution of 0.1°, */
-/* so the resulting numbers to be stored are in a range of -3600 to +3600. */
-
-/* Example: */
-/* Assume the value of freq is 2345 (decimal) and the value of phase is 900. */
-/* If range == 0 the effective frequency is 234.5 Hz with a phase of +90°. */
-/* If range == 1 the synthesizer will generate a 2345 Hz output frequency */
-/* and so on. */
-
-/* Limitations: */
-/* If freq == 0 the synthesizer is disabled. If range == 0 the least */
-/* significant digit of freq is limited to 0, 3, 5 or 6. The resulting */
-/* frequency is shown in the examples below: */
-/* freq == 1230 --> 123.0 Hz */
-/* freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz) */
-/* freq == 1235 --> 123.5 Hz */
-/* freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz) */
-
-/* If range == MAX_RANGE the value of freq must not exceed 1200, so the */
-/* output frequency is limited to 12 MHz. */
-
-/* Phase will be ignored if the resulting frequency is greater or equal */
-/* to 10 kHz. */
-
-#define MAX_SYNTH_FREQ 1200 /* if range == MAX_SYNTH_RANGE */
#define MIN_SYNTH_RANGE 0
#define MAX_SYNTH_RANGE 5
-#define MAX_SYNTH_PHASE 3600
+#define N_SYNTH_RANGE ( MAX_SYNTH_RANGE - MIN_SYNTH_RANGE + 1 )
-typedef struct {
- short freq; /* four digits used; scale: 0.1; e.g. 1234 -> 123.4 Hz */
- short range; /* scale factor for freq; 0..MAX_SYNTH_RANGE */
- short phase; /* -MAX_SYNTH_PHASE..+MAX_SYNTH_PHASE; >0 -> pulses later */
-} SYNTH;
+#define N_SYNTH_PHASE_DIGIT 4
+#define MAX_SYNTH_PHASE 3600
+#define MAX_SYNTH_FREQ_EDIT 9999 ///< max sequence of digits when editing
-/* Time zone/daylight saving parameters. */
-/* the name of a time zone, 5 characters plus trailing zero */
-typedef char TZ_NAME[6];
+/**
+ * @brief The maximum frequency that can be configured for the synthesizer
+ */
+#define MAX_SYNTH_FREQ_VAL 10000000UL ///< 10 MHz
+/* == MAX_SYNTH_FREQ * 10^(MAX_SYNTH_RANGE-1) */
-typedef struct {
- long offs; /* offset from UTC to local time [sec] */
- long offs_dl; /* additional offset if daylight saving enabled [sec] */
- TM tm_on; /* date/time when daylight saving starts */
- TM tm_off; /* date/time when daylight saving ends */
- TZ_NAME name[2]; /* names without and with daylight saving enabled */
-} TZDL;
+/**
+ * @brief The synthesizer's phase is only be synchronized if the frequency is below this limit
+ */
+#define SYNTH_PHASE_SYNC_LIMIT 10000UL ///< 10 kHz
-/* The constant below is defined beginning with software rev. 1.29. */
-/* If the year in tzdl.tmon and tzdl.tm_off is or'ed with that constant, */
-/* the receiver automatically generates daylight saving year by year. */
-/* See GPSLIB.TXT for more information. */
+/**
+ * A Macro used to determine the position of the decimal point
+ * when printing the synthesizer frequency as 4 digit value
+ */
+#define _synth_dp_pos_from_range( _r ) \
+ ( ( ( N_SYNTH_RANGE - (_r) ) % ( N_SYNTH_FREQ_DIGIT - 1 ) ) + 1 )
+
+/**
+ * @brief Synthesizer frequency units
+ *
+ * An initializer for commonly displayed synthesizer frequency units
+ * (::N_SYNTH_RANGE strings)
+ */
+#define DEFAULT_FREQ_RANGES \
+{ \
+ "Hz", \
+ "kHz", \
+ "kHz", \
+ "kHz", \
+ "MHz", \
+ "MHz", \
+}
-#define DL_AUTO_FLAG 0x8000
-/* Example: */
-/* for automatic daylight saving enable/disable in Central Europe, */
-/* the variables are to be set as shown below: */
-/* offs = 3600L one hour from UTC */
-/* offs_dl = 3600L one additional hour if daylight saving enabled */
-/* tm_on = first Sunday from March 25, 02:00:00h ( year |= DL_AUTO_FLAG ) */
-/* tm_off = first Sunday from Sept 24, 03:00:00h ( year |= DL_AUTO_FLAG ) */
-/* name[0] == "MEZ " name if daylight saving not enabled */
-/* name[1] == "MESZ " name if daylight saving is enabled */
+/**
+ * @brief Synthesizer configuration parameters
+ */
+typedef struct
+{
+ int16_t freq; ///< four digits used; scale: 0.1 Hz; e.g. 1234 -> 123.4 Hz
+ int16_t range; ///< scale factor for freq; 0..::MAX_SYNTH_RANGE
+ int16_t phase; ///< -::MAX_SYNTH_PHASE..+::MAX_SYNTH_PHASE; >0 -> pulses later
+} SYNTH;
+#define _mbg_swab_synth( _p ) \
+{ \
+ _mbg_swab16( &(_p)->freq ); \
+ _mbg_swab16( &(_p)->range ); \
+ _mbg_swab16( &(_p)->phase ); \
+}
-/* the structure below was defined in rev. 1.31. It reflects the status */
-/* of the antenna, the times of last disconnect/reconnect and the boards */
-/* clock offset after the phase of disconnection. */
-typedef struct {
- short status; /* current status of antenna */
- TM tm_disconn; /* time of antenna disconnect */
- TM tm_reconn; /* time of antenna reconnect */
- long delta_t; /* clock offset at reconnect time, units: TICKS_PER_SEC */
-} ANT_INFO;
+/**
+ * @brief Enumeration of synthesizer states
+ */
+enum SYNTH_STATES
+{
+ SYNTH_DISABLED, ///< disbled by cfg, i.e. freq == 0.0
+ SYNTH_OFF, ///< not enabled after power-up
+ SYNTH_FREE, ///< enabled, but not synchronized
+ SYNTH_DRIFTING, ///< has initially been sync'd, but now running free
+ SYNTH_SYNC, ///< fully synchronized
+ N_SYNTH_STATE ///< the number of known states
+};
+
+/**
+ * @brief A structure used to report the synthesizer state
+ */
+typedef struct
+{
+ uint8_t state; ///< state code as enumerated in ::SYNTH_STATES
+ uint8_t flags; ///< reserved, currently always 0
-/* the status field may be set to one of the values below: */
+} SYNTH_STATE;
-enum {
- ANT_INVALID, /* struct not set yet because ant. has not been disconn. */
- ANT_DISCONN, /* ant. now disconn., tm_reconn and delta_t not set */
- ANT_RECONN /* ant. has been disconn. and reconn., all fields valid */
-};
+#define _mbg_swab_synth_state( _p ) _nop_macro_fnc()
+#define SYNTH_FLAG_PHASE_IGNORED 0x01
-/* Summary of configuration and health data of all SVs. */
+/** @} defgroup group_synth */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
- T_GPS tot_51; /* time of transmission, page 51 */
- T_GPS tot_63; /* time of transmission, page 63 */
- T_GPS t0a; /* complete reference time almanac */
- CFG cfg[N_SVNO]; /* SV configuration from page 63 */
- HEALTH health[N_SVNO]; /* SV health from pages 51, 63 */
-} CFGH;
+/**
+ * @defgroup group_tzdl Time zone / daylight saving parameters
+ *
+ * Example: <br>
+ * For automatic daylight saving enable/disable in Central Europe,
+ * the variables are to be set as shown below: <br>
+ * - offs = 3600L one hour from %UTC
+ * - offs_dl = 3600L one additional hour if daylight saving enabled
+ * - tm_on = first Sunday from March 25, 02:00:00h ( year |= ::DL_AUTO_FLAG )
+ * - tm_off = first Sunday from October 25, 03:00:00h ( year |= ::DL_AUTO_FLAG )
+ * - name[0] == "CET " name if daylight saving not enabled
+ * - name[1] == "CEST " name if daylight saving is enabled
+ *
+ * @{ */
+
+/**
+ * @brief The name of a time zone
+ *
+ * @note Up to 5 printable characters, plus trailing zero
+ */
+typedef char TZ_NAME[6];
+/**
+ * @brief Time zone / daylight saving parameters
+ *
+ * This structure is used to specify how a device converts on-board %UTC
+ * to local time, including computation of beginning and end of daylight
+ * saving time (DST), if required.
+ *
+ * @note The ::TZDL structure contains members of type ::TM_GPS to specify
+ * the times for beginning and end of DST. However, the ::TM_GPS::frac,
+ * ::TM_GPS::offs_from_utc, and ::TM_GPS::status fields of these ::TZDL::tm_on
+ * and ::TZDL::tm_off members are ignored for the conversion to local time,
+ * and thus should be 0.
+ */
+typedef struct
+{
+ int32_t offs; ///< standard offset from %UTC to local time [sec]
+ int32_t offs_dl; ///< additional offset if daylight saving enabled [sec]
+ TM_GPS tm_on; ///< date/time when daylight saving starts
+ TM_GPS tm_off; ///< date/time when daylight saving ends
+ TZ_NAME name[2]; ///< names without and with daylight saving enabled
+} TZDL;
+
+/**
+ * @brief A flag indicating automatic computation of DST
+ *
+ * If this flag is or'ed to the year numbers in ::TZDL::tm_on and ::TZDL::tm_off
+ * then daylight saving is computed automatically year by year.
+ */
+#define DL_AUTO_FLAG 0x8000
-/* UTC correction parameters */
+/** @} defgroup group_tzdl */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
- T_GPS t0t; /* Reference Time UTC Parameters [sec] */
- l_fp A0; /* ± Clock Correction Coefficient 0 [sec] */
- l_fp A1; /* ± Clock Correction Coefficient 1 [sec/sec] */
- u_short WNlsf; /* week number of nearest leap second */
- short DNt; /* the day number at the end of which LS is inserted */
- char delta_tls; /* */
- char delta_tlsf; /* */
+/**
+ * @brief Antenna status and error at reconnect information
+ *
+ * The structure below reflects the status of the antenna,
+ * the times of last disconnect/reconnect, and the board's
+ * clock offset when it has synchronized again after the
+ * disconnection interval.
+ *
+ * @note ::ANT_INFO::status changes back to ::ANT_RECONN only
+ * after the antenna has been reconnected <b>and</b> the
+ * receiver has re-synchronized to the satellite signal.
+ * In this case ::ANT_INFO::delta_t reports the time offset
+ * before resynchronization, i.e. how much the internal
+ * time has drifted while the antenna was disconnected.
+ */
+typedef struct
+{
+ int16_t status; ///< current status of antenna, see ::ANT_STATUS_CODES
+ TM_GPS tm_disconn; ///< time of antenna disconnect
+ TM_GPS tm_reconn; ///< time of antenna reconnect
+ int32_t delta_t; ///< clock offs at reconn. time in 1/::RECEIVER_INFO::ticks_per_sec units
-} UTC;
+} ANT_INFO;
-/* a struct used to hold the settings of a serial port */
-#ifndef _COM_PARM_DEFINED
- typedef long BAUD_RATE;
+/**
+ * @brief Status code used with ::ANT_INFO::status
+ */
+enum ANT_STATUS_CODES
+{
+ ANT_INVALID, ///< No other fields valid since antenna has not yet been disconnected
+ ANT_DISCONN, ///< Antenna is disconnected, tm_reconn and delta_t not yet set
+ ANT_RECONN, ///< Antenna has been disconnect, and receiver sync. after reconnect, so all fields valid
+ N_ANT_STATUS_CODES ///< the number of known status codes
+};
- /* indices used to identify a parameter in the framing string */
- enum { F_DBITS, F_PRTY, F_STBITS };
- /* types of handshake */
- enum { HS_NONE, HS_XONXOFF, HS_RTSCTS };
- typedef struct {
- BAUD_RATE baud_rate; /* e.g. 19200L */
- char framing[4]; /* e.g. "8N1" */
- short handshake; /* a numeric value, only HS_NONE supported yet */
- } COM_PARM;
+/**
+ * @brief Summary of configuration and health data of all satellites
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes
+ int16_t valid; ///< flag data are valid
+
+ T_GPS tot_51; ///< time of transmission, page 51
+ T_GPS tot_63; ///< time of transmission, page 63
+ T_GPS t0a; ///< complete reference time almanac
+
+ CFG cfg[N_SVNO_GPS]; ///< 4 bit SV configuration code from page 63
+ HEALTH health[N_SVNO_GPS]; ///< 6 bit SV health codes from pages 51, 63
+
+} CFGH;
+
-#define _COM_PARM_DEFINED
-#endif
+/**
+ * @brief GPS %UTC correction parameters
+ *
+ * %UTC correction parameters basically as sent by the GPS satellites.
+ *
+ * The csum field is only used by the card's firmware to check the
+ * consistency of the structure in non-volatile memory.
+ *
+ * The field labeled valid indicates if the parameter set is valid, i.e.
+ * if it contains data received from the satellites.
+ *
+ * t0t, A0 and A1 contain fractional correction parameters for the current
+ * GPS-%UTC time offset in addition to the whole seconds. This is evaluated
+ * by the receivers' firmware to convert GPS time to %UTC time.
+ *
+ * The delta_tls field contains the current full seconds offset between
+ * GPS time and %UTC, which corresponds to the number of leap seconds inserted
+ * into the %UTC time scale since GPS was put into operation in January 1980.
+ *
+ * delta_tlfs holds the number of "future" leap seconds, i.e. the %UTC offset
+ * after the next leap second event defined by WNlsf and DNt.
+ *
+ * The fields WNlsf and DNt specify the GPS week number and the day number
+ * in that week for the end of which a leap second has been scheduled.
+ *
+ * @note: The satellites transmit WNlsf only as a signed 8 bit value, so it
+ * can only define a point in time which is +/- 127 weeks off the current time.
+ * The firmware tries to expand this based on the current week number, but
+ * the result is ambiguous if the leap second occurs or occurred more
+ * than 127 weeks in the future or past.
+ *
+ * So the leap second date should <b>only</b> be evaluated and displayed
+ * in a user interface if the fields delta_tls and delta_tlsf have
+ * different values, in which case there is indeed a leap second announcement
+ * inside the +/- 127 week range.
+ *
+ * @note In the original code the type of A0 and A1 is double.
+ */
+typedef struct
+{
+ CSUM csum; ///< Checksum of the remaining bytes
+ int16_t valid; ///< Flag indicating %UTC parameters are valid
+ T_GPS t0t; ///< Reference Time %UTC Parameters [wn|sec]
+ l_fp A0; ///< +- Clock Correction Coefficient 0 [sec]
+ l_fp A1; ///< +- Clock Correction Coefficient 1 [sec/sec]
-/* the codes below define what has to comes out of the serial ports */
+ uint16_t WNlsf; ///< Week number of nearest leap second
+ int16_t DNt; ///< The day number at the end of which a leap second occurs
+ int8_t delta_tls; ///< Current %UTC offset to GPS system time [sec]
+ int8_t delta_tlsf; ///< Future %UTC offset to GPS system time after next leap second transition [sec]
-enum { STR_ON_REQ, STR_PER_SEC,
- STR_PER_MIN, N_STR_MODE_0, /* COM0 and COM1 */
- STR_UCAP = N_STR_MODE_0,
- STR_UCAP_REQ, N_STR_MODE_1 /* COM1 only */
- };
+} UTC;
-#define N_COM 2 /* the number of serial ports */
+/**
+ * @brief GPS ASCII message
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes */
+ int16_t valid; ///< flag data are valid
+ char s[23]; ///< 22 chars GPS ASCII message plus trailing zero
-/* the structure used to store the modes of both serial ports */
+} ASCII_MSG;
-typedef struct {
- COM_PARM com[N_COM]; /* COM0 and COM1 settings */
- u_char mode[N_COM]; /* COM0 and COM1 output mode */
-} PORT_PARM;
-/* Ephemeris parameters of one specific SV. Needed to compute the position */
-/* of a satellite at a given time with high precision. Valid for an */
-/* interval of 4 to 6 hours from start of transmission. */
-
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
-
- HEALTH health; /* health indication of transmitting SV [---] */
- IOD IODC; /* Issue Of Data, Clock */
- IOD IODE2; /* Issue of Data, Ephemeris (Subframe 2) */
- IOD IODE3; /* Issue of Data, Ephemeris (Subframe 3) */
- T_GPS tt; /* time of transmission */
- T_GPS t0c; /* Reference Time Clock [---] */
- T_GPS t0e; /* Reference Time Ephemeris [---] */
-
- l_fp sqrt_A; /* Square Root of semi-major Axis [sqrt(m)] */
- l_fp e; /* Eccentricity [---] */
- l_fp M0; /* ± Mean Anomaly at Ref. Time [rad] */
- l_fp omega; /* ± Argument of Perigee [rad] */
- l_fp OMEGA0; /* ± Longit. of Asc. Node of orbit plane [rad] */
- l_fp OMEGADOT; /* ± Rate of Right Ascension [rad/sec] */
- l_fp deltan; /* ± Mean Motion Diff. from computed value [rad/sec] */
- l_fp i0; /* ± Inclination Angle [rad] */
- l_fp idot; /* ± Rate of Inclination Angle [rad/sec] */
- l_fp crc; /* ± Cosine Corr. Term to Orbit Radius [m] */
- l_fp crs; /* ± Sine Corr. Term to Orbit Radius [m] */
- l_fp cuc; /* ± Cosine Corr. Term to Arg. of Latitude [rad] */
- l_fp cus; /* ± Sine Corr. Term to Arg. of Latitude [rad] */
- l_fp cic; /* ± Cosine Corr. Term to Inclination Angle [rad] */
- l_fp cis; /* ± Sine Corr. Term to Inclination Angle [rad] */
-
- l_fp af0; /* ± Clock Correction Coefficient 0 [sec] */
- l_fp af1; /* ± Clock Correction Coefficient 1 [sec/sec] */
- l_fp af2; /* ± Clock Correction Coefficient 2 [sec/sec²] */
- l_fp tgd; /* ± estimated group delay differential [sec] */
-
- u_short URA; /* predicted User Range Accuracy */
-
- u_char L2code; /* code on L2 channel [---] */
- u_char L2flag; /* L2 P data flag [---] */
+/**
+ * @brief Ephemeris parameters of one specific satellite
+ *
+ * Needed to compute the position of a satellite at a given time with
+ * high precision. Valid for an interval of 4 to 6 hours from start
+ * of transmission.
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes
+ int16_t valid; ///< flag data are valid
+
+ HEALTH health; ///< health indication of transmitting SV [---]
+ IOD IODC; ///< Issue Of Data, Clock
+ IOD IODE2; ///< Issue of Data, Ephemeris (Subframe 2)
+ IOD IODE3; ///< Issue of Data, Ephemeris (Subframe 3)
+ T_GPS tt; ///< time of transmission
+ T_GPS t0c; ///< Reference Time Clock [---]
+ T_GPS t0e; ///< Reference Time Ephemeris [---]
+
+ l_fp sqrt_A; ///< Square Root of semi-major Axis [sqrt(m)]
+ l_fp e; ///< Eccentricity [---]
+ l_fp M0; ///< +- Mean Anomaly at Ref. Time [rad]
+ l_fp omega; ///< +- Argument of Perigee [rad]
+ l_fp OMEGA0; ///< +- Longit. of Asc. Node of orbit plane [rad]
+ l_fp OMEGADOT; ///< +- Rate of Right Ascension [rad/sec]
+ l_fp deltan; ///< +- Mean Motion Diff. from computed value [rad/sec]
+ l_fp i0; ///< +- Inclination Angle [rad]
+ l_fp idot; ///< +- Rate of Inclination Angle [rad/sec]
+ l_fp crc; ///< +- Cosine Corr. Term to Orbit Radius [m]
+ l_fp crs; ///< +- Sine Corr. Term to Orbit Radius [m]
+ l_fp cuc; ///< +- Cosine Corr. Term to Arg. of Latitude [rad]
+ l_fp cus; ///< +- Sine Corr. Term to Arg. of Latitude [rad]
+ l_fp cic; ///< +- Cosine Corr. Term to Inclination Angle [rad]
+ l_fp cis; ///< +- Sine Corr. Term to Inclination Angle [rad]
+
+ l_fp af0; ///< +- Clock Correction Coefficient 0 [sec]
+ l_fp af1; ///< +- Clock Correction Coefficient 1 [sec/sec]
+ l_fp af2; ///< +- Clock Correction Coefficient 2 [sec/sec^2]
+ l_fp tgd; ///< +- estimated group delay differential [sec]
+
+ uint16_t URA; ///< predicted User Range Accuracy
+
+ uint8_t L2code; ///< code on L2 channel [---]
+ uint8_t L2flag; ///< L2 P data flag [---]
} EPH;
-/* Almanac parameters of one specific SV. A reduced precision set of */
-/* parameters used to check if a satellite is in view at a given time. */
-/* Valid for an interval of more than 7 days from start of transmission. */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
- HEALTH health; /* [---] */
- T_GPS t0a; /* Reference Time Almanac [sec] */
+/**
+ * @brief Almanac parameters of one specific satellite
+ *
+ * A reduced precision set of parameters used to check if a satellite
+ * is in view at a given time. Valid for an interval of more than 7 days
+ * from start of transmission.
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes
+ int16_t valid; ///< flag data are valid
+
+ HEALTH health; ///< [---]
+ T_GPS t0a; ///< Reference Time Almanac [sec]
+
+ l_fp sqrt_A; ///< Square Root of semi-major Axis [sqrt(m)]
+ l_fp e; ///< Eccentricity [---]
- l_fp sqrt_A; /* Square Root of semi-major Axis [sqrt(m)] */
- l_fp e; /* Eccentricity [---] */
+ l_fp M0; ///< +- Mean Anomaly at Ref. Time [rad]
+ l_fp omega; ///< +- Argument of Perigee [rad]
+ l_fp OMEGA0; ///< +- Longit. of Asc. Node of orbit plane [rad]
+ l_fp OMEGADOT; ///< +- Rate of Right Ascension [rad/sec]
+ l_fp deltai; ///< +- [rad]
+ l_fp af0; ///< +- Clock Correction Coefficient 0 [sec]
+ l_fp af1; ///< +- Clock Correction Coefficient 1 [sec/sec]
- l_fp M0; /* ± Mean Anomaly at Ref. Time [rad] */
- l_fp omega; /* ± Argument of Perigee [rad] */
- l_fp OMEGA0; /* ± Longit. of Asc. Node of orbit plane [rad] */
- l_fp OMEGADOT; /* ± Rate of Right Ascension [rad/sec] */
- l_fp deltai; /* ± [rad] */
- l_fp af0; /* ± Clock Correction Coefficient 0 [sec] */
- l_fp af1; /* ± Clock Correction Coefficient 1 [sec/sec] */
} ALM;
-/* ionospheric correction parameters */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
+/**
+ * @brief Ionospheric correction parameters
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes
+ int16_t valid; ///< flag data are valid
- l_fp alpha_0; /* Ionosph. Corr. Coeff. Alpha 0 [sec] */
- l_fp alpha_1; /* Ionosph. Corr. Coeff. Alpha 1 [sec/deg] */
- l_fp alpha_2; /* Ionosph. Corr. Coeff. Alpha 2 [sec/deg^2] */
- l_fp alpha_3; /* Ionosph. Corr. Coeff. Alpha 3 [sec/deg^3] */
+ l_fp alpha_0; ///< Ionosph. Corr. Coeff. Alpha 0 [sec]
+ l_fp alpha_1; ///< Ionosph. Corr. Coeff. Alpha 1 [sec/deg]
+ l_fp alpha_2; ///< Ionosph. Corr. Coeff. Alpha 2 [sec/deg^2]
+ l_fp alpha_3; ///< Ionosph. Corr. Coeff. Alpha 3 [sec/deg^3]
- l_fp beta_0; /* Ionosph. Corr. Coeff. Beta 0 [sec] */
- l_fp beta_1; /* Ionosph. Corr. Coeff. Beta 1 [sec/deg] */
- l_fp beta_2; /* Ionosph. Corr. Coeff. Beta 2 [sec/deg^2] */
- l_fp beta_3; /* Ionosph. Corr. Coeff. Beta 3 [sec/deg^3] */
+ l_fp beta_0; ///< Ionosph. Corr. Coeff. Beta 0 [sec]
+ l_fp beta_1; ///< Ionosph. Corr. Coeff. Beta 1 [sec/deg]
+ l_fp beta_2; ///< Ionosph. Corr. Coeff. Beta 2 [sec/deg^2]
+ l_fp beta_3; ///< Ionosph. Corr. Coeff. Beta 3 [sec/deg^3]
} IONO;
-void mbg_tm_str (char **, TM *, int);
+
+
+void mbg_tm_str (char **, TM_GPS *, int, int);
void mbg_tgps_str (char **, T_GPS *, int);
void get_mbg_header (unsigned char **, GPS_MSG_HDR *);
void put_mbg_header (unsigned char **, GPS_MSG_HDR *);
@@ -534,7 +967,7 @@ void get_mbg_svno (unsigned char **, SVNO *);
void get_mbg_health (unsigned char **, HEALTH *);
void get_mbg_cfg (unsigned char **, CFG *);
void get_mbg_tgps (unsigned char **, T_GPS *);
-void get_mbg_tm (unsigned char **, TM *);
+void get_mbg_tm (unsigned char **, TM_GPS *);
void get_mbg_ttm (unsigned char **, TTM *);
void get_mbg_synth (unsigned char **, SYNTH *);
void get_mbg_tzdl (unsigned char **, TZDL *);
@@ -548,7 +981,7 @@ void get_mbg_eph (unsigned char **, EPH *);
void get_mbg_alm (unsigned char **, ALM *);
void get_mbg_iono (unsigned char **, IONO *);
-unsigned long mbg_csum (unsigned char *, unsigned int);
+CSUM mbg_csum (unsigned char *, unsigned int);
#endif
/*
diff --git a/include/ntp.h b/include/ntp.h
index 38343f2..4ffc35f 100644
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -435,7 +435,7 @@ struct peer {
#define STRATUM_UNSPEC ((u_char)16) /* unspecified */
/*
- * Values for peer.flags
+ * Values for peer.flags (u_int)
*/
#define FLAG_CONFIG 0x0001 /* association was configured */
#define FLAG_PREEMPT 0x0002 /* preemptable association */
@@ -453,8 +453,9 @@ struct peer {
#define FLAG_XB 0x2000 /* interleaved broadcast */
#define FLAG_XBOGUS 0x4000 /* interleaved bogus packet */
#ifdef OPENSSL
-#define FLAG_ASSOC 0x8000 /* autokey request */
+# define FLAG_ASSOC 0x8000 /* autokey request */
#endif /* OPENSSL */
+#define FLAG_TSTAMP_PPS 0x10000 /* PPS source provides absolute timestamp */
/*
* Definitions for the clear() routine. We use memset() to clear
@@ -713,17 +714,19 @@ struct pkt {
*/
#define LOOP_DRIFTINIT 1 /* iniitialize frequency */
#define LOOP_KERN_CLEAR 2 /* set initial frequency offset */
-#define LOOP_MAX 3 /* set step offset */
-#define LOOP_PANIC 4 /* set panic offseet */
-#define LOOP_PHI 5 /* set dispersion rate */
-#define LOOP_MINSTEP 6 /* set step timeout */
-#define LOOP_MINPOLL 7 /* set min poll interval (log2 s) */
-#define LOOP_ALLAN 8 /* set minimum Allan intercept */
-#define LOOP_HUFFPUFF 9 /* set huff-n'-puff filter length */
-#define LOOP_FREQ 10 /* set initial frequency */
-#define LOOP_CODEC 11 /* set audio codec frequency */
-#define LOOP_LEAP 12 /* insert leap after second 23:59 */
-#define LOOP_TICK 13 /* sim. low precision clock */
+#define LOOP_MAX 3 /* set both step offsets */
+#define LOOP_MAX_BACK 4 /* set bacward-step offset */
+#define LOOP_MAX_FWD 5 /* set forward-step offset */
+#define LOOP_PANIC 6 /* set panic offseet */
+#define LOOP_PHI 7 /* set dispersion rate */
+#define LOOP_MINSTEP 8 /* set step timeout */
+#define LOOP_MINPOLL 9 /* set min poll interval (log2 s) */
+#define LOOP_ALLAN 10 /* set minimum Allan intercept */
+#define LOOP_HUFFPUFF 11 /* set huff-n'-puff filter length */
+#define LOOP_FREQ 12 /* set initial frequency */
+#define LOOP_CODEC 13 /* set audio codec frequency */
+#define LOOP_LEAP 14 /* insert leap after second 23:59 */
+#define LOOP_TICK 15 /* sim. low precision clock */
/*
* Configuration items for the stats printer
@@ -875,13 +878,13 @@ struct endpoint {
*/
#define AM_ERR -1 /* error */
#define AM_NOMATCH 0 /* no match */
-#define AM_PROCPKT 1 /* server/symmetric packet */
-#define AM_BCST 2 /* broadcast packet */
+#define AM_PROCPKT 1 /* server/symmetric packet */
+#define AM_BCST 2 /* broadcast packet */
#define AM_FXMIT 3 /* client packet */
#define AM_MANYCAST 4 /* manycast or pool */
#define AM_NEWPASS 5 /* new passive */
#define AM_NEWBCL 6 /* new broadcast */
-#define AM_POSSBCL 7 /* discard broadcast */
+#define AM_POSSBCL 7 /* discard broadcast */
/* NetInfo configuration locations */
#ifdef HAVE_NETINFO
diff --git a/include/ntp_calendar.h b/include/ntp_calendar.h
index 3ee1ff7..3afb627 100644
--- a/include/ntp_calendar.h
+++ b/include/ntp_calendar.h
@@ -83,13 +83,15 @@ extern systime_func_ptr ntpcal_set_timefunc(systime_func_ptr);
#define SECSPERMIN (60) /* seconds per minute */
#define MINSPERHR (60) /* minutes per hour */
#define HRSPERDAY (24) /* hours per day */
+#define DAYSPERWEEK (7) /* days per week */
#define DAYSPERYEAR (365) /* days per year */
#define SECSPERHR (SECSPERMIN * MINSPERHR)
#define SECSPERDAY (SECSPERHR * HRSPERDAY)
+#define SECSPERWEEK (DAYSPERWEEK * SECSPERDAY)
#define SECSPERYEAR (365 * SECSPERDAY) /* regular year */
#define SECSPERLEAPYEAR (366 * SECSPERDAY) /* leap year */
-#define SECSPERAVGYEAR 31556952 /* mean year length over 400yrs */
+#define SECSPERAVGYEAR 31556952 /* mean year length over 400yrs */
/*
* Gross hacks. I have illicit knowlege that there won't be overflows
@@ -113,7 +115,7 @@ extern uint32_t caltontp (const struct calendar *);
* Convert between 'time_t' and 'vint64'
*/
extern vint64 time_to_vint64(const time_t *);
-extern time_t vint64_to_time(const vint64 *);
+extern time_t vint64_to_time(const vint64 *);
/*
* Get the build date & time. ATTENTION: The time zone is not specified!
diff --git a/include/ntp_config.h b/include/ntp_config.h
index 900688c..a74cd55 100644
--- a/include/ntp_config.h
+++ b/include/ntp_config.h
@@ -239,6 +239,7 @@ struct config_tree_tag {
int_fifo * reset_counters;
sim_fifo * sim_details;
+ int mdnstries;
};
@@ -286,7 +287,7 @@ attr_val *create_attr_dval(int attr, double value);
attr_val *create_attr_ival(int attr, int value);
attr_val *create_attr_uval(int attr, u_int value);
attr_val *create_attr_rangeval(int attr, int first, int last);
-attr_val *create_attr_sval(int attr, char *s);
+attr_val *create_attr_sval(int attr, const char *s);
filegen_node *create_filegen_node(int filegen_token,
attr_val_fifo *options);
string_node *create_string_node(char *str);
@@ -316,7 +317,7 @@ int dump_all_config_trees(FILE *df, int comment);
#endif
#if defined(HAVE_SETRLIMIT)
-void ntp_rlimit(int, rlim_t, int, char *);
+void ntp_rlimit(int, rlim_t, int, const char *);
#endif
#endif /* !defined(NTP_CONFIG_H) */
diff --git a/include/ntp_filegen.h b/include/ntp_filegen.h
index f5ba8af..549bedb 100644
--- a/include/ntp_filegen.h
+++ b/include/ntp_filegen.h
@@ -52,5 +52,5 @@ extern void filegen_statsdir(void);
extern FILEGEN *filegen_get (const char *);
extern void filegen_register (const char *, const char *, FILEGEN *);
#ifdef DEBUG
-extern void filegen_unregister(char *);
+extern void filegen_unregister(const char *);
#endif
diff --git a/include/ntp_fp.h b/include/ntp_fp.h
index 1b97e8b..7806932 100644
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -264,10 +264,13 @@ typedef u_int32 u_fp;
* headers. So far the problem has only been seen with gcc, but it
* may also affect Sun compilers, in which case the defined(__GNUC__)
* term should be removed.
+ * XSCALE also generates bad code for these, at least with GCC 3.3.5.
+ * This is unrelated to math.h, but the same solution applies.
*/
#if defined(HAVE_U_INT64) && \
!(defined(__SVR4) && defined(__sun) && \
- defined(sparc) && defined(__GNUC__))
+ defined(sparc) && defined(__GNUC__) || \
+ defined(__arm__) && defined(__XSCALE__) && defined(__GNUC__))
#include <math.h> /* ldexp() */
diff --git a/include/ntp_md5.h b/include/ntp_md5.h
index 9f43378..2306b9a 100644
--- a/include/ntp_md5.h
+++ b/include/ntp_md5.h
@@ -24,7 +24,7 @@
typedef MD5_CTX EVP_MD_CTX;
# define EVP_get_digestbynid(t) NULL
-# define EVP_md5(v) NULL
+# define EVP_md5() NULL
# define EVP_MD_CTX_init(c)
# define EVP_MD_CTX_set_flags(c, f)
# define EVP_DigestInit(c, dt) (MD5Init(c), 1)
diff --git a/include/ntp_random.h b/include/ntp_random.h
index 3f89831..fa77f65 100644
--- a/include/ntp_random.h
+++ b/include/ntp_random.h
@@ -1,6 +1,9 @@
#include <ntp_types.h>
+void ntp_crypto_srandom(void);
+int ntp_crypto_random_buf(void *buf, size_t nbytes);
+
long ntp_random (void);
void ntp_srandom (unsigned long);
void ntp_srandomdev (void);
diff --git a/include/ntp_stdlib.h b/include/ntp_stdlib.h
index 7c884fc..38180f0 100644
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -96,14 +96,14 @@ extern int ymd2yd (int, int, int);
/* a_md5encrypt.c */
extern int MD5authdecrypt (int, u_char *, u_int32 *, int, int);
extern int MD5authencrypt (int, u_char *, u_int32 *, int);
-extern void MD5auth_setkey (keyid_t, int, const u_char *, int);
+extern void MD5auth_setkey (keyid_t, int, const u_char *, size_t);
extern u_int32 addr2refid (sockaddr_u *);
/* emalloc.c */
#ifndef EREALLOC_CALLSITE /* ntp_malloc.h defines */
extern void * ereallocz (void *, size_t, size_t, int);
#define erealloczsite(p, n, o, z, f, l) ereallocz(p, n, o, (z))
-extern void * emalloc (size_t);
+#define emalloc(n) ereallocz(NULL, n, 0, FALSE)
#define emalloc_zero(c) ereallocz(NULL, (c), 0, TRUE)
#define erealloc(p, c) ereallocz(p, (c), 0, FALSE)
#define erealloc_zero(p, n, o) ereallocz(p, n, (o), TRUE)
@@ -129,11 +129,11 @@ extern char * estrdup_impl (const char *, const char *, int);
extern int atoint (const char *, long *);
extern int atouint (const char *, u_long *);
extern int hextoint (const char *, u_long *);
-extern char * humanlogtime (void);
-extern char * humantime (time_t);
+extern const char * humanlogtime (void);
+extern const char * humantime (time_t);
extern char * mfptoa (u_int32, u_int32, short);
extern char * mfptoms (u_int32, u_int32, short);
-extern const char * modetoa (int);
+extern const char * modetoa (size_t);
extern const char * eventstr (int);
extern const char * ceventstr (int);
extern const char * res_match_flags(u_short);
diff --git a/include/ntpd.h b/include/ntpd.h
index 51d8f2a..f0bbeb0 100644
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -78,7 +78,7 @@ extern int mprintf_event (int, struct peer *, const char *, ...)
struct ctl_var {
u_short code;
u_short flags;
- char *text;
+ const char *text;
};
/*
* Flag values
@@ -188,6 +188,7 @@ extern void unpeer (struct peer *);
extern void clear_all (void);
extern int score_all (struct peer *);
extern struct peer *findmanycastpeer(struct recvbuf *);
+extern void peer_cleanup (void);
/* ntp_crypto.c */
#ifdef AUTOKEY
@@ -218,7 +219,7 @@ extern struct value tai_leap;
/* ntp_proto.c */
extern void transmit (struct peer *);
extern void receive (struct recvbuf *);
-extern void peer_clear (struct peer *, char *);
+extern void peer_clear (struct peer *, const char *);
extern void process_packet (struct peer *, struct pkt *, u_int);
extern void clock_select (void);
@@ -285,7 +286,7 @@ extern void record_loop_stats (double, double, double, double, int);
extern void record_clock_stats (sockaddr_u *, const char *);
extern int mprintf_clock_stats(sockaddr_u *, const char *, ...)
NTP_PRINTF(2, 3);
-extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int poll, int precision, double root_delay, double root_dispersion, u_int32 refid);
+extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int ppoll, int precision, double root_delay, double root_dispersion, u_int32 refid);
extern void check_leap_file (int is_daily_check, u_int32 ntptime, const time_t * systime);
extern void record_crypto_stats (sockaddr_u *, const char *);
#ifdef DEBUG
@@ -385,7 +386,8 @@ extern endpt * ep_list; /* linked list */
/* ntp_loopfilter.c */
extern double drift_comp; /* clock frequency (s/s) */
extern double clock_stability; /* clock stability (s/s) */
-extern double clock_max; /* max offset before step (s) */
+extern double clock_max_back; /* max backward offset before step (s) */
+extern double clock_max_fwd; /* max forward offset before step (s) */
extern double clock_panic; /* max offset before panic (s) */
extern double clock_phi; /* dispersion rate (s/s) */
extern double clock_minstep; /* step timeout (s) */
@@ -403,8 +405,9 @@ extern int kern_enable; /* kernel support enabled */
extern int hardpps_enable; /* kernel PPS discipline enabled */
extern int ext_enable; /* external clock enabled */
extern int cal_enable; /* refclock calibrate enable */
-extern int allow_panic; /* allow panic correction */
-extern int mode_ntpdate; /* exit on first clock set */
+extern int allow_panic; /* allow panic correction (-g) */
+extern int force_step_once; /* always step time once at startup (-G) */
+extern int mode_ntpdate; /* exit on first clock set (-q) */
extern int peer_ntpdate; /* count of ntpdate peers */
/*
@@ -518,7 +521,7 @@ extern u_int32 conf_file_sum; /* Simple sum of characters */
/* ntp_signd.c */
#ifdef HAVE_NTP_SIGND
-extern void send_via_ntp_signd(struct recvbuf *, int, keyid_t, int,
+extern void send_via_ntp_signd(struct recvbuf *, int, keyid_t, int,
struct pkt *);
#endif
diff --git a/include/parse.h b/include/parse.h
index 3a98408..ca6855d 100644
--- a/include/parse.h
+++ b/include/parse.h
@@ -4,7 +4,7 @@
* parse.h,v 4.12 2007/01/14 08:36:03 kardel RELEASE_20070114_A
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -105,6 +105,13 @@ extern unsigned int splclock (void);
#endif
/*
+ * some constants useful for GPS time conversion
+ */
+#define GPSORIGIN 2524953600UL /* NTP origin - GPS origin in seconds */
+#define GPSWRAP 990U /* assume week count less than this in the previous epoch */
+#define GPSWEEKS 1024U /* number of weeks until the GPS epch rolls over */
+
+/*
* state flags
*/
#define PARSEB_POWERUP 0x00000001 /* no synchronisation */
@@ -127,7 +134,7 @@ extern unsigned int splclock (void);
/*
* optional status information
*/
-#define PARSEB_ALTERNATE 0x00001000 /* alternate antenna used */
+#define PARSEB_CALLBIT 0x00001000 /* "call bit" used to signalize irregularities in the control facilities */
#define PARSEB_POSITION 0x00002000 /* position available */
#define PARSEB_MESSAGE 0x00004000 /* addtitional message data */
/*
@@ -145,7 +152,7 @@ extern unsigned int splclock (void);
#define PARSEB_PPS 0x20000000 /* valid PPS sample */
#define PARSE_TCINFO (PARSEB_ANNOUNCE|PARSEB_POWERUP|PARSEB_NOSYNC|PARSEB_DST|\
- PARSEB_UTC|PARSEB_LEAPS|PARSEB_ALTERNATE|PARSEB_S_LEAP|\
+ PARSEB_UTC|PARSEB_LEAPS|PARSEB_CALLBIT|PARSEB_S_LEAP|\
PARSEB_S_LOCATION|PARSEB_TIMECODE|PARSEB_MESSAGE)
#define PARSE_POWERUP(x) ((x) & PARSEB_POWERUP)
@@ -156,7 +163,7 @@ extern unsigned int splclock (void);
#define PARSE_UTC(x) ((x) & PARSEB_UTC)
#define PARSE_LEAPADD(x) (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPADD))
#define PARSE_LEAPDEL(x) (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPDEL))
-#define PARSE_ALTERNATE(x) ((x) & PARSEB_ALTERNATE)
+#define PARSE_CALLBIT(x) ((x) & PARSEB_CALLBIT)
#define PARSE_LEAPSECOND(x) (PARSE_SYNC(x) && ((x) & PARSEB_LEAP_SECOND))
#define PARSE_S_LEAP(x) ((x) & PARSEB_S_LEAP)
@@ -229,13 +236,13 @@ typedef struct parsetime parsetime_t;
#define PARSE_IO_CSIZE 0x00000003
#define PARSE_IO_CS5 0x00000000
#define PARSE_IO_CS6 0x00000001
-#define PARSE_IO_CS7 0x00000002
-#define PARSE_IO_CS8 0x00000003
+#define PARSE_IO_CS7 0x00000002
+#define PARSE_IO_CS8 0x00000003
/*
* ioctl structure
*/
-union parsectl
+union parsectl
{
struct parsegettc
{
@@ -258,7 +265,7 @@ union parsectl
u_long parse_cs; /* character size (needed for stripping) */
} parsesetcs;
};
-
+
typedef union parsectl parsectl_t;
/*------ for conversion routines --------*/
@@ -266,7 +273,7 @@ typedef union parsectl parsectl_t;
struct parse /* parse module local data */
{
int parse_flags; /* operation and current status flags */
-
+
int parse_ioflags; /* io handling flags (5-8 Bit control currently) */
/*
@@ -286,7 +293,7 @@ struct parse /* parse module local data */
char *parse_ldata; /* last data buffer */
unsigned short parse_ldsize; /* last data buffer length */
u_long parse_badformat; /* number of unparsable pakets */
-
+
timestamp_t parse_lastchar; /* last time a character was received */
parsetime_t parse_dtime; /* external data prototype */
};
@@ -337,15 +344,19 @@ typedef struct clocktime clocktime_t;
#define SYNC_ZERO 0x00
#define SYNC_ONE 0x01
+typedef u_long parse_inp_fnc_t(parse_t *, char, timestamp_t *);
+typedef u_long parse_cvt_fnc_t(unsigned char *, int, struct format *, clocktime_t *, void *);
+typedef u_long parse_pps_fnc_t(parse_t *, int, timestamp_t *);
+
struct clockformat
{
/* special input protocol - implies fixed format */
- u_long (*input) (parse_t *, unsigned int, timestamp_t *);
+ parse_inp_fnc_t *input;
/* conversion routine */
- u_long (*convert) (unsigned char *, int, struct format *, clocktime_t *, void *);
+ parse_cvt_fnc_t *convert;
/* routine for handling RS232 sync events (time stamps) */
/* PPS input routine */
- u_long (*syncpps) (parse_t *, int, timestamp_t *);
+ parse_pps_fnc_t *syncpps;
/* time code synthesizer */
void *data; /* local parameters */
@@ -361,7 +372,7 @@ typedef struct clockformat clockformat_t;
*/
extern int parse_ioinit (parse_t *);
extern void parse_ioend (parse_t *);
-extern int parse_ioread (parse_t *, unsigned int, timestamp_t *);
+extern int parse_ioread (parse_t *, char, timestamp_t *);
extern int parse_iopps (parse_t *, int, timestamp_t *);
extern void parse_iodone (parse_t *);
extern int parse_timecode (parsectl_t *, parse_t *);
@@ -369,8 +380,8 @@ extern int parse_getfmt (parsectl_t *, parse_t *);
extern int parse_setfmt (parsectl_t *, parse_t *);
extern int parse_setcs (parsectl_t *, parse_t *);
-extern unsigned int parse_restart (parse_t *, unsigned int);
-extern unsigned int parse_addchar (parse_t *, unsigned int);
+extern unsigned int parse_restart (parse_t *, char);
+extern unsigned int parse_addchar (parse_t *, char);
extern unsigned int parse_end (parse_t *);
extern int Strok (const unsigned char *, const unsigned char *);
@@ -379,9 +390,9 @@ extern int Stoi (const unsigned char *, long *, int);
extern time_t parse_to_unixtime (clocktime_t *, u_long *);
extern u_long updatetimeinfo (parse_t *, u_long);
extern void syn_simple (parse_t *, timestamp_t *, struct format *, u_long);
-extern u_long pps_simple (parse_t *, int, timestamp_t *);
-extern u_long pps_one (parse_t *, int, timestamp_t *);
-extern u_long pps_zero (parse_t *, int, timestamp_t *);
+extern parse_pps_fnc_t pps_simple;
+extern parse_pps_fnc_t pps_one;
+extern parse_pps_fnc_t pps_zero;
extern int parse_timedout (parse_t *, timestamp_t *, struct timeval *);
#endif
diff --git a/include/parse_conf.h b/include/parse_conf.h
index 319dd54..d17d616 100644
--- a/include/parse_conf.h
+++ b/include/parse_conf.h
@@ -4,7 +4,7 @@
* parse_conf.h,v 4.7 2005/06/25 10:58:45 kardel RELEASE_20050625_A
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,13 +41,13 @@
/*
* field location structure
*/
-#define O_DAY 0
+#define O_DAY 0
#define O_MONTH 1
-#define O_YEAR 2
-#define O_HOUR 3
-#define O_MIN 4
-#define O_SEC 5
-#define O_WDAY 6
+#define O_YEAR 2
+#define O_HOUR 3
+#define O_MIN 4
+#define O_SEC 5
+#define O_WDAY 6
#define O_FLAGS 7
#define O_ZONE 8
#define O_UTCHOFFSET 9
diff --git a/include/timepps-Solaris.h b/include/timepps-Solaris.h
index a2b1fbe..bcae382 100644
--- a/include/timepps-Solaris.h
+++ b/include/timepps-Solaris.h
@@ -413,7 +413,7 @@ time_pps_getparams(
}
punit = (pps_unit_t *)handle;
- memcpy(params, &punit->params, sizeof(params));
+ memcpy(params, &punit->params, sizeof(*params));
return (0);
}