summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ae99655)
raw | patch | inline | side by side (parent: ae99655)
author | Johan Kiviniemi <devel@johan.kiviniemi.name> | |
Thu, 4 Oct 2012 21:38:52 +0000 (00:38 +0300) | ||
committer | Johan Kiviniemi <devel@johan.kiviniemi.name> | |
Thu, 4 Oct 2012 22:28:58 +0000 (01:28 +0300) |
src/ntpd.c | patch | blob | history |
diff --git a/src/ntpd.c b/src/ntpd.c
index 3e2b4ea5f12e949e34594bb01114f1fbf962f545..9841e3155a95c077ac7b84d8d975890e25d34caa 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
{
"Host",
"Port",
- "ReverseLookups"
+ "ReverseLookups",
+ "IncludeUnitID"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
static int do_reverse_lookups = 1;
+/* This option only exists for backward compatibility. If it is false and two
+ * ntpd peers use the same refclock driver, the plugin will try to write
+ * simultaneous measurements from both to the same type instance. */
+static int include_unit_id = 0;
+
# define NTPD_DEFAULT_HOST "localhost"
# define NTPD_DEFAULT_PORT "123"
static int sock_descr = -1;
else
do_reverse_lookups = 0;
}
+ else if (strcasecmp (key, "IncludeUnitID") == 0)
+ {
+ if (IS_TRUE (value))
+ include_unit_id = 1;
+ else
+ include_unit_id = 0;
+ }
else
{
return (-1);
{
struct in_addr addr_obj;
char *addr_str;
+ int name_refclock;
refclock_id = (ntohl (ptr->srcadr) >> 8) & 0x000000FF;
- if (refclock_id < refclock_names_num)
+ name_refclock = refclock_id < refclock_names_num;
+
+ if (name_refclock && include_unit_id)
{
/* The unit number is in the lowest byte. */
ssnprintf (peername, sizeof (peername),
refclock_names[refclock_id],
ntohl (ptr->srcadr) & 0xFF);
}
- else
+ else if (name_refclock && !include_unit_id)
+ {
+ sstrncpy (peername, refclock_names[refclock_id],
+ sizeof (peername));
+ }
+ else /* !name_refclock */
{
memset ((void *) &addr_obj, '\0', sizeof (addr_obj));
addr_obj.s_addr = ptr->srcadr;