cmdmon: refactor handling of sources report

The NSR_ReportSource() and RCL_ReportSource() functions assume that the
provided report already has some data prefilled by SRC_ReportSource()
and it's assumed these functions cannot fail.

Change them to accept the required data (refid and IP address) as
a parameter, remove unneeded parameters, and return an error status
(if the refid/address doesn't exist) to be handled in cmdmon
handle_source_data(). Also, catch unexpected values of the source state
and mode to make chronyc report an error instead of incorrect data.
This commit is contained in:
Miroslav Lichvar
2025-11-19 14:12:09 +01:00
parent 662484cd0a
commit 0fec9e5cfa
8 changed files with 32 additions and 28 deletions

View File

@@ -68,7 +68,7 @@ extern void RCL_Initialise(void);
extern void RCL_Finalise(void);
extern int RCL_AddRefclock(RefclockParameters *params);
extern void RCL_StartRefclocks(void);
extern void RCL_ReportSource(RPT_SourceReport *report, struct timespec *now);
extern int RCL_ReportSource(uint32_t ref_id, RPT_SourceReport *report);
extern int RCL_ModifyOffset(uint32_t ref_id, double offset);
/* functions used by drivers */