mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:55:07 -05:00
ntp+refclock: add functions to modify offset option
This commit is contained in:
10
ntp_core.c
10
ntp_core.c
@@ -3024,6 +3024,16 @@ NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
NCR_ModifyOffset(NCR_Instance inst, double new_offset)
|
||||||
|
{
|
||||||
|
inst->offset_correction = new_offset;
|
||||||
|
LOG(LOGS_INFO, "Source %s new offset %f",
|
||||||
|
UTI_IPToString(&inst->remote_addr.ip_addr), new_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
NCR_ModifyPolltarget(NCR_Instance inst, int new_poll_target)
|
NCR_ModifyPolltarget(NCR_Instance inst, int new_poll_target)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ extern void NCR_ModifyMaxdelaydevratio(NCR_Instance inst, double new_max_delay_d
|
|||||||
|
|
||||||
extern void NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum);
|
extern void NCR_ModifyMinstratum(NCR_Instance inst, int new_min_stratum);
|
||||||
|
|
||||||
|
extern void NCR_ModifyOffset(NCR_Instance inst, double new_offset);
|
||||||
|
|
||||||
extern void NCR_ModifyPolltarget(NCR_Instance inst, int new_poll_target);
|
extern void NCR_ModifyPolltarget(NCR_Instance inst, int new_poll_target);
|
||||||
|
|
||||||
extern void NCR_InitiateSampleBurst(NCR_Instance inst, int n_good_samples, int n_total_samples);
|
extern void NCR_InitiateSampleBurst(NCR_Instance inst, int n_good_samples, int n_total_samples);
|
||||||
|
|||||||
@@ -1444,6 +1444,20 @@ NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NSR_ModifyOffset(IPAddr *address, double new_offset)
|
||||||
|
{
|
||||||
|
int slot;
|
||||||
|
|
||||||
|
if (!find_slot(address, &slot))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
NCR_ModifyOffset(get_record(slot)->data, new_offset);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
int
|
int
|
||||||
NSR_ModifyPolltarget(IPAddr *address, int new_poll_target)
|
NSR_ModifyPolltarget(IPAddr *address, int new_poll_target)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ extern int NSR_ModifyMaxdelaydevratio(IPAddr *address, double new_max_delay_rati
|
|||||||
|
|
||||||
extern int NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum);
|
extern int NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum);
|
||||||
|
|
||||||
|
extern int NSR_ModifyOffset(IPAddr *address, double new_offset);
|
||||||
|
|
||||||
extern int NSR_ModifyPolltarget(IPAddr *address, int new_poll_target);
|
extern int NSR_ModifyPolltarget(IPAddr *address, int new_poll_target);
|
||||||
|
|
||||||
extern int NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples, IPAddr *mask, IPAddr *address);
|
extern int NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples, IPAddr *mask, IPAddr *address);
|
||||||
|
|||||||
16
refclock.c
16
refclock.c
@@ -321,6 +321,22 @@ RCL_ReportSource(RPT_SourceReport *report, struct timespec *now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
RCL_ModifyOffset(uint32_t ref_id, double offset)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARR_GetSize(refclocks); i++) {
|
||||||
|
RCL_Instance inst = get_refclock(i);
|
||||||
|
if (inst->ref_id == ref_id) {
|
||||||
|
inst->offset = offset;
|
||||||
|
LOG(LOGS_INFO, "Source %s new offset %f", UTI_RefidToString(ref_id), offset);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RCL_SetDriverData(RCL_Instance instance, void *data)
|
RCL_SetDriverData(RCL_Instance instance, void *data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ extern void RCL_Finalise(void);
|
|||||||
extern int RCL_AddRefclock(RefclockParameters *params);
|
extern int RCL_AddRefclock(RefclockParameters *params);
|
||||||
extern void RCL_StartRefclocks(void);
|
extern void RCL_StartRefclocks(void);
|
||||||
extern void RCL_ReportSource(RPT_SourceReport *report, struct timespec *now);
|
extern void RCL_ReportSource(RPT_SourceReport *report, struct timespec *now);
|
||||||
|
extern int RCL_ModifyOffset(uint32_t ref_id, double offset);
|
||||||
|
|
||||||
/* functions used by drivers */
|
/* functions used by drivers */
|
||||||
extern void RCL_SetDriverData(RCL_Instance instance, void *data);
|
extern void RCL_SetDriverData(RCL_Instance instance, void *data);
|
||||||
|
|||||||
12
stubs.c
12
stubs.c
@@ -320,6 +320,12 @@ NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
NSR_ModifyOffset(IPAddr *address, double new_offset)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
NSR_ModifyPolltarget(IPAddr *address, int new_poll_target)
|
NSR_ModifyPolltarget(IPAddr *address, int new_poll_target)
|
||||||
{
|
{
|
||||||
@@ -419,6 +425,12 @@ RCL_ReportSource(RPT_SourceReport *report, struct timespec *now)
|
|||||||
memset(report, 0, sizeof (*report));
|
memset(report, 0, sizeof (*report));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
RCL_ModifyOffset(uint32_t ref_id, double offset)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* !FEAT_REFCLOCK */
|
#endif /* !FEAT_REFCLOCK */
|
||||||
|
|
||||||
#ifndef FEAT_SIGND
|
#ifndef FEAT_SIGND
|
||||||
|
|||||||
Reference in New Issue
Block a user