cmdmon: convert doffset request to float
This commit is contained in:
parent
e86b60a9d7
commit
52b29f673f
4 changed files with 12 additions and 16 deletions
8
candm.h
8
candm.h
|
@ -108,7 +108,8 @@
|
||||||
#define REQ_CLIENT_ACCESSES_BY_INDEX3 68
|
#define REQ_CLIENT_ACCESSES_BY_INDEX3 68
|
||||||
#define REQ_SELECT_DATA 69
|
#define REQ_SELECT_DATA 69
|
||||||
#define REQ_RELOAD_SOURCES 70
|
#define REQ_RELOAD_SOURCES 70
|
||||||
#define N_REQUEST_TYPES 71
|
#define REQ_DOFFSET2 71
|
||||||
|
#define N_REQUEST_TYPES 72
|
||||||
|
|
||||||
/* Structure used to exchange timespecs independent of time_t size */
|
/* Structure used to exchange timespecs independent of time_t size */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -308,8 +309,7 @@ typedef struct {
|
||||||
} REQ_Dfreq;
|
} REQ_Dfreq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t sec;
|
Float doffset;
|
||||||
int32_t usec;
|
|
||||||
int32_t EOR;
|
int32_t EOR;
|
||||||
} REQ_Doffset;
|
} REQ_Doffset;
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ typedef struct {
|
||||||
domain socket.
|
domain socket.
|
||||||
|
|
||||||
Version 6 (no authentication) : changed format of client accesses by index
|
Version 6 (no authentication) : changed format of client accesses by index
|
||||||
(using new request/reply types) and manual timestamp, added new fields and
|
(two times), delta offset, and manual timestamp, added new fields and
|
||||||
flags to NTP source request and report, made length of manual list constant,
|
flags to NTP source request and report, made length of manual list constant,
|
||||||
added new commands: authdata, ntpdata, onoffline, refresh, reset,
|
added new commands: authdata, ntpdata, onoffline, refresh, reset,
|
||||||
selectdata, serverstats, shutdown, sourcename
|
selectdata, serverstats, shutdown, sourcename
|
||||||
|
|
7
client.c
7
client.c
|
@ -1008,19 +1008,16 @@ process_cmd_dfreq(CMD_Request *msg, char *line)
|
||||||
static int
|
static int
|
||||||
process_cmd_doffset(CMD_Request *msg, char *line)
|
process_cmd_doffset(CMD_Request *msg, char *line)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
|
||||||
double doffset;
|
double doffset;
|
||||||
|
|
||||||
msg->command = htons(REQ_DOFFSET);
|
msg->command = htons(REQ_DOFFSET2);
|
||||||
|
|
||||||
if (sscanf(line, "%lf", &doffset) != 1) {
|
if (sscanf(line, "%lf", &doffset) != 1) {
|
||||||
LOG(LOGS_ERR, "Invalid value");
|
LOG(LOGS_ERR, "Invalid value");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UTI_DoubleToTimeval(doffset, &tv);
|
msg->data.doffset.doffset = UTI_FloatHostToNetwork(doffset);
|
||||||
msg->data.doffset.sec = htonl(tv.tv_sec);
|
|
||||||
msg->data.doffset.usec = htonl(tv.tv_usec);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
cmdmon.c
10
cmdmon.c
|
@ -143,6 +143,7 @@ static const char permissions[] = {
|
||||||
PERMIT_AUTH, /* CLIENT_ACCESSES_BY_INDEX3 */
|
PERMIT_AUTH, /* CLIENT_ACCESSES_BY_INDEX3 */
|
||||||
PERMIT_AUTH, /* SELECT_DATA */
|
PERMIT_AUTH, /* SELECT_DATA */
|
||||||
PERMIT_AUTH, /* RELOAD_SOURCES */
|
PERMIT_AUTH, /* RELOAD_SOURCES */
|
||||||
|
PERMIT_AUTH, /* DOFFSET2 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
@ -856,13 +857,10 @@ handle_dfreq(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||||
static void
|
static void
|
||||||
handle_doffset(CMD_Request *rx_message, CMD_Reply *tx_message)
|
handle_doffset(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||||
{
|
{
|
||||||
long sec, usec;
|
|
||||||
double doffset;
|
double doffset;
|
||||||
sec = (int32_t)ntohl(rx_message->data.doffset.sec);
|
doffset = UTI_FloatNetworkToHost(rx_message->data.doffset.doffset);
|
||||||
usec = (int32_t)ntohl(rx_message->data.doffset.usec);
|
|
||||||
doffset = (double) sec + 1.0e-6 * (double) usec;
|
|
||||||
LOG(LOGS_INFO, "Accumulated delta offset of %.6f seconds", doffset);
|
|
||||||
LCL_AccumulateOffset(doffset, 0.0);
|
LCL_AccumulateOffset(doffset, 0.0);
|
||||||
|
LOG(LOGS_INFO, "Accumulated delta offset of %.6f seconds", doffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
@ -1637,7 +1635,7 @@ read_from_cmd_socket(int sock_fd, int event, void *anything)
|
||||||
handle_dfreq(&rx_message, &tx_message);
|
handle_dfreq(&rx_message, &tx_message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REQ_DOFFSET:
|
case REQ_DOFFSET2:
|
||||||
handle_doffset(&rx_message, &tx_message);
|
handle_doffset(&rx_message, &tx_message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ static const struct request_length request_lengths[] = {
|
||||||
REQ_LENGTH_ENTRY(del_source, null), /* DEL_SOURCE */
|
REQ_LENGTH_ENTRY(del_source, null), /* DEL_SOURCE */
|
||||||
REQ_LENGTH_ENTRY(null, null), /* WRITERTC */
|
REQ_LENGTH_ENTRY(null, null), /* WRITERTC */
|
||||||
REQ_LENGTH_ENTRY(dfreq, null), /* DFREQ */
|
REQ_LENGTH_ENTRY(dfreq, null), /* DFREQ */
|
||||||
REQ_LENGTH_ENTRY(doffset, null), /* DOFFSET */
|
{ 0, 0 }, /* DOFFSET - not supported */
|
||||||
REQ_LENGTH_ENTRY(null, tracking), /* TRACKING */
|
REQ_LENGTH_ENTRY(null, tracking), /* TRACKING */
|
||||||
REQ_LENGTH_ENTRY(sourcestats, sourcestats), /* SOURCESTATS */
|
REQ_LENGTH_ENTRY(sourcestats, sourcestats), /* SOURCESTATS */
|
||||||
REQ_LENGTH_ENTRY(null, rtc), /* RTCREPORT */
|
REQ_LENGTH_ENTRY(null, rtc), /* RTCREPORT */
|
||||||
|
@ -128,6 +128,7 @@ static const struct request_length request_lengths[] = {
|
||||||
client_accesses_by_index), /* CLIENT_ACCESSES_BY_INDEX3 */
|
client_accesses_by_index), /* CLIENT_ACCESSES_BY_INDEX3 */
|
||||||
REQ_LENGTH_ENTRY(select_data, select_data), /* SELECT_DATA */
|
REQ_LENGTH_ENTRY(select_data, select_data), /* SELECT_DATA */
|
||||||
REQ_LENGTH_ENTRY(null, null), /* RELOAD_SOURCES */
|
REQ_LENGTH_ENTRY(null, null), /* RELOAD_SOURCES */
|
||||||
|
REQ_LENGTH_ENTRY(doffset, null), /* DOFFSET2 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint16_t reply_lengths[] = {
|
static const uint16_t reply_lengths[] = {
|
||||||
|
|
Loading…
Reference in a new issue