freebsd-dev/contrib/ntp/libntp/refnumtoa.c

37 lines
673 B
C
Raw Normal View History

1999-12-09 13:01:21 +00:00
/*
* refnumtoa - return asciized refclock addresses stored in local array space
*/
#include <config.h>
1999-12-09 13:01:21 +00:00
#include <stdio.h>
#include "ntp_net.h"
1999-12-09 13:01:21 +00:00
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
const char *
1999-12-09 13:01:21 +00:00
refnumtoa(
sockaddr_u *num
1999-12-09 13:01:21 +00:00
)
{
u_int32 netnum;
char *buf;
const char *rclock;
2004-07-20 15:01:56 +00:00
if (!ISREFCLOCKADR(num))
return socktoa(num);
2004-07-20 15:01:56 +00:00
LIB_GETBUF(buf);
netnum = SRCADR(num);
rclock = clockname((int)((u_long)netnum >> 8) & 0xff);
1999-12-09 13:01:21 +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);
1999-12-09 13:01:21 +00:00
return buf;
}