1999-12-09 13:01:21 +00:00
|
|
|
/*
|
|
|
|
* refnumtoa - return asciized refclock addresses stored in local array space
|
|
|
|
*/
|
2014-12-20 22:52:39 +00:00
|
|
|
#include <config.h>
|
1999-12-09 13:01:21 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-12-04 21:33:17 +00:00
|
|
|
#include "ntp_net.h"
|
1999-12-09 13:01:21 +00:00
|
|
|
#include "lib_strbuf.h"
|
|
|
|
#include "ntp_stdlib.h"
|
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
const char *
|
1999-12-09 13:01:21 +00:00
|
|
|
refnumtoa(
|
2013-12-04 21:33:17 +00:00
|
|
|
sockaddr_u *num
|
1999-12-09 13:01:21 +00:00
|
|
|
)
|
|
|
|
{
|
2014-12-20 22:52:39 +00:00
|
|
|
u_int32 netnum;
|
|
|
|
char *buf;
|
|
|
|
const char *rclock;
|
2004-07-20 15:01:56 +00:00
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
if (!ISREFCLOCKADR(num))
|
|
|
|
return socktoa(num);
|
2004-07-20 15:01:56 +00:00
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
LIB_GETBUF(buf);
|
|
|
|
netnum = SRCADR(num);
|
|
|
|
rclock = clockname((int)((u_long)netnum >> 8) & 0xff);
|
1999-12-09 13:01:21 +00:00
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
if (rclock != NULL)
|
|
|
|
snprintf(buf, LIB_BUFLENGTH, "%s(%lu)",
|
|
|
|
rclock, (u_long)netnum & 0xff);
|
|
|
|
else
|
|
|
|
snprintf(buf, LIB_BUFLENGTH, "REFCLK(%lu,%lu)",
|
|
|
|
((u_long)netnum >> 8) & 0xff,
|
|
|
|
(u_long)netnum & 0xff);
|
2013-12-04 21:33:17 +00:00
|
|
|
|
1999-12-09 13:01:21 +00:00
|
|
|
return buf;
|
|
|
|
}
|