domain socket.
Version 6 (no authentication) : changed format of client accesses by index
- (using new request/reply types), new fields and flags in NTP source request
- and report, new commands: ntpdata, refresh, serverstats
+ (using new request/reply types) and manual timestamp, new fields and flags
+ in NTP source request and report, new commands: ntpdata, refresh,
+ serverstats
*/
#define PROTO_VERSION_NUMBER 6
#define RPY_SERVER_STATS 14
#define RPY_CLIENT_ACCESSES_BY_INDEX2 15
#define RPY_NTP_DATA 16
-#define N_REPLY_TYPES 17
+#define RPY_MANUAL_TIMESTAMP2 17
+#define N_REPLY_TYPES 18
/* Status codes */
#define STT_SUCCESS 0
} RPY_Rtc;
typedef struct {
- uint32_t centiseconds;
+ Float offset;
Float dfreq_ppm;
Float new_afreq_ppm;
int32_t EOR;
time_t now, new_time;
CMD_Request request;
CMD_Reply reply;
- long offset_cs;
double dfreq_ppm, new_afreq_ppm;
double offset;
ts.tv_nsec = 0;
UTI_TimespecHostToNetwork(&ts, &request.data.settime.ts);
request.command = htons(REQ_SETTIME);
- if (request_reply(&request, &reply, RPY_MANUAL_TIMESTAMP, 1)) {
- offset_cs = ntohl(reply.data.manual_timestamp.centiseconds);
- offset = 0.01 * (double)(int32_t)offset_cs;
+ if (request_reply(&request, &reply, RPY_MANUAL_TIMESTAMP2, 1)) {
+ offset = UTI_FloatNetworkToHost(reply.data.manual_timestamp.offset);
dfreq_ppm = UTI_FloatNetworkToHost(reply.data.manual_timestamp.dfreq_ppm);
new_afreq_ppm = UTI_FloatNetworkToHost(reply.data.manual_timestamp.new_afreq_ppm);
printf("Clock was %.2f seconds fast. Frequency change = %.2fppm, new frequency = %.2fppm\n",
handle_settime(CMD_Request *rx_message, CMD_Reply *tx_message)
{
struct timespec ts;
- long offset_cs;
- double dfreq_ppm, new_afreq_ppm;
+ double offset, dfreq_ppm, new_afreq_ppm;
UTI_TimespecNetworkToHost(&rx_message->data.settime.ts, &ts);
if (!MNL_IsEnabled()) {
tx_message->status = htons(STT_NOTENABLED);
- } else if (MNL_AcceptTimestamp(&ts, &offset_cs, &dfreq_ppm, &new_afreq_ppm)) {
- tx_message->reply = htons(RPY_MANUAL_TIMESTAMP);
- tx_message->data.manual_timestamp.centiseconds = htonl((int32_t)offset_cs);
+ } else if (MNL_AcceptTimestamp(&ts, &offset, &dfreq_ppm, &new_afreq_ppm)) {
+ tx_message->reply = htons(RPY_MANUAL_TIMESTAMP2);
+ tx_message->data.manual_timestamp.offset = UTI_FloatHostToNetwork(offset);
tx_message->data.manual_timestamp.dfreq_ppm = UTI_FloatHostToNetwork(dfreq_ppm);
tx_message->data.manual_timestamp.new_afreq_ppm = UTI_FloatHostToNetwork(new_afreq_ppm);
} else {
/* ================================================== */
static void
-estimate_and_set_system(struct timespec *now, int offset_provided, double offset, long *offset_cs, double *dfreq_ppm, double *new_afreq_ppm)
+estimate_and_set_system(struct timespec *now, int offset_provided, double offset,
+ double *reg_offset, double *dfreq_ppm, double *new_afreq_ppm)
{
double agos[MAX_SAMPLES], offsets[MAX_SAMPLES];
double b0, b1;
0.0, skew);
}
- if (offset_cs) *offset_cs = (long)(0.5 + 100.0 * b0);
+ if (reg_offset) *reg_offset = b0;
if (dfreq_ppm) *dfreq_ppm = 1.0e6 * freq;
if (new_afreq_ppm) *new_afreq_ppm = LCL_ReadAbsoluteFrequency();
/* ================================================== */
int
-MNL_AcceptTimestamp(struct timespec *ts, long *offset_cs, double *dfreq_ppm, double *new_afreq_ppm)
+MNL_AcceptTimestamp(struct timespec *ts, double *reg_offset, double *dfreq_ppm, double *new_afreq_ppm)
{
struct timespec now;
double offset, diff;
samples[n_samples].orig_offset = offset;
++n_samples;
- estimate_and_set_system(&now, 1, offset, offset_cs, dfreq_ppm, new_afreq_ppm);
+ estimate_and_set_system(&now, 1, offset, reg_offset, dfreq_ppm, new_afreq_ppm);
return 1;
extern void MNL_Initialise(void);
extern void MNL_Finalise(void);
-extern int MNL_AcceptTimestamp(struct timespec *ts, long *offset_cs, double *dfreq_ppm, double *new_afreq_ppm);
+extern int MNL_AcceptTimestamp(struct timespec *ts, double *reg_offset, double *dfreq_ppm, double *new_afreq_ppm);
extern void MNL_Enable(void);
extern void MNL_Disable(void);
RPY_LENGTH_ENTRY(null), /* NULL */
RPY_LENGTH_ENTRY(n_sources), /* N_SOURCES */
RPY_LENGTH_ENTRY(source_data), /* SOURCE_DATA */
- RPY_LENGTH_ENTRY(manual_timestamp), /* MANUAL_TIMESTAMP */
+ 0, /* MANUAL_TIMESTAMP */
RPY_LENGTH_ENTRY(tracking), /* TRACKING */
RPY_LENGTH_ENTRY(sourcestats), /* SOURCESTATS */
RPY_LENGTH_ENTRY(rtc), /* RTC */
RPY_LENGTH_ENTRY(server_stats), /* SERVER_STATS */
RPY_LENGTH_ENTRY(client_accesses_by_index), /* CLIENT_ACCESSES_BY_INDEX2 */
RPY_LENGTH_ENTRY(ntp_data), /* NTP_DATA */
+ RPY_LENGTH_ENTRY(manual_timestamp), /* MANUAL_TIMESTAMP2 */
};
/* ================================================== */