freebsd-src/libntp/refnumtoa.c

37 lines
804 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 <stdio.h>
#include "ntp_fp.h"
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
char *
refnumtoa(
2004-07-20 15:01:56 +00:00
struct sockaddr_storage* num
1999-12-09 13:01:21 +00:00
)
{
register u_int32 netnum;
register char *buf;
register const char *rclock;
2004-07-20 15:01:56 +00:00
1999-12-09 13:01:21 +00:00
LIB_GETBUF(buf);
2004-07-20 15:01:56 +00:00
if(num->ss_family == AF_INET) {
netnum = ntohl(((struct sockaddr_in*)num)->sin_addr.s_addr);
rclock = clockname((int)((u_long)netnum >> 8) & 0xff);
if (rclock != NULL)
(void)sprintf(buf, "%s(%lu)", rclock, (u_long)netnum & 0xff);
else
(void)sprintf(buf, "REFCLK(%lu,%lu)",
((u_long)netnum >> 8) & 0xff, (u_long)netnum & 0xff);
1999-12-09 13:01:21 +00:00
2004-07-20 15:01:56 +00:00
}
else {
(void)sprintf(buf, "refclock address type not implemented yet, use IPv4 refclock address.");
}
1999-12-09 13:01:21 +00:00
return buf;
}