if (s == NSR_UnresolvedName) {
unresolved++;
} else if (s != NSR_Success) {
- LOG(LOGS_ERR, "Could not add source %s", source->params.name);
+ LOG(LOGS_ERR, "Could not add source %s : %s",
+ source->params.name, NSR_StatusToString(s));
/* Mark the source as not present */
source->params.name[0] = '\0';
/* ================================================== */
+const char *
+NSR_StatusToString(NSR_Status status)
+{
+ switch (status) {
+ case NSR_Success:
+ return "Success";
+ case NSR_NoSuchSource:
+ return "No such source";
+ case NSR_AlreadyInUse:
+ return "Already in use";
+ case NSR_TooManySources:
+ return "Too many sources";
+ case NSR_InvalidAF:
+ return "Invalid address";
+ case NSR_InvalidName:
+ return "Invalid name";
+ case NSR_UnresolvedName:
+ return "Unresolved name";
+ default:
+ return "?";
+ }
+}
+
+/* ================================================== */
+
void
NSR_SetSourceResolvingEndHandler(NSR_SourceResolvingEndHandler handler)
{
extern NSR_Status NSR_AddSourceByName(char *name, int port, int pool, NTP_Source_Type type,
SourceParameters *params, uint32_t *conf_id);
+extern const char *NSR_StatusToString(NSR_Status status);
+
/* Function type for handlers to be called back when an attempt
* (possibly unsuccessful) to resolve unresolved sources ends */
typedef void (*NSR_SourceResolvingEndHandler)(void);
return NSR_TooManySources;
}
+const char *
+NSR_StatusToString(NSR_Status status)
+{
+ return "NTP not supported";
+}
+
NSR_Status
NSR_RemoveSource(IPAddr *address)
{
TEST_CHECK(status == NSR_Success || status == NSR_AlreadyInUse);
}
+ TEST_CHECK(strlen(NSR_StatusToString(status)) > 0);
+
return status == NSR_Success;
}