src/ntpd.c: Add unit number to refclock name
authorJohan Kiviniemi <devel@johan.kiviniemi.name>
Thu, 4 Oct 2012 17:56:34 +0000 (20:56 +0300)
committerJohan Kiviniemi <devel@johan.kiviniemi.name>
Thu, 4 Oct 2012 18:21:08 +0000 (21:21 +0300)
There can be multiple instances of the same refclock with different unit
numbers. The unit number needs to be a part of the peer name, otherwise
the code will try to write the measurements from multiple peers to the
same RRD file.

src/ntpd.c

index 8bbf74d..15e60a5 100644 (file)
@@ -857,8 +857,11 @@ static int ntpd_read (void)
 
                        if (refclock_id < refclock_names_num)
                        {
-                               sstrncpy (peername, refclock_names[refclock_id],
-                                               sizeof (peername));
+                               /* The unit number is in the lowest byte. */
+                               ssnprintf (peername, sizeof (peername),
+                                               "%s%i",
+                                               refclock_names[refclock_id],
+                                               ntohl (ptr->srcadr) & 0xFF);
                        }
                        else
                        {