FreeBSD/contrib/ntp/ntpdc/ntpdc_ops.c
/*
 * printpeer - print detail information for a peer
 */
print detail information for a peer
print detail information for a peer
static void
printpeer(
	register struct info_peer *pp,
	FILE *fp
	)
{
	register int i;
	l_fp tempts;
	sockaddr_u srcadr, dstadr;
	SET_ADDRS(dstadr, srcadr, pp, dstadr, srcadr);
	(void) fprintf(fp, "remote %s, local %s\n",
		       stoa(&srcadr), stoa(&dstadr));
	(void) fprintf(fp, "hmode %s, pmode %s, stratum %d, precision %d\n",
		       modetoa(pp->hmode), modetoa(pp->pmode),
		       pp->stratum, pp->precision);
	(void) fprintf(fp,
		       "leap %c%c, refid [%s], rootdistance %s, rootdispersion %s\n",
		       pp->leap & 0x2 ? '1' : '0',
		       pp->leap & 0x1 ? '1' : '0',
		       refid_string(pp->refid, pp->stratum), fptoa(NTOHS_FP(pp->rootdelay), 5),
		       ufptoa(NTOHS_FP(pp->rootdispersion), 5));
	(void) fprintf(fp,
		       "ppoll %d, hpoll %d, keyid %lu, version %d, association %u\n",
		       pp->ppoll, pp->hpoll, (u_long)pp->keyid, pp->version, ntohs(pp->associd));
	(void) fprintf(fp,
		       "reach %03o, unreach %d, flash 0x%04x, ",
		       pp->reach, pp->unreach, pp->flash2);
	(void) fprintf(fp, "boffset %s, ttl/mode %d\n",
		       fptoa(NTOHS_FP(pp->estbdelay), 5), pp->ttl);
	(void) fprintf(fp, "timer %lds, flags", (long)ntohl(pp->timer));
	print_pflag(fp, pp->flags); 
	NTOHL_FP(&pp->reftime, &tempts);
	(void) fprintf(fp, "reference time:      %s\n",
		       prettydate(&tempts));
	NTOHL_FP(&pp->org, &tempts);
	(void) fprintf(fp, "originate timestamp: %s\n",
		       prettydate(&tempts));
	NTOHL_FP(&pp->rec, &tempts);
	(void) fprintf(fp, "receive timestamp:   %s\n",
		       prettydate(&tempts));
	NTOHL_FP(&pp->xmt, &tempts);
	(void) fprintf(fp, "transmit timestamp:  %s\n",
		       prettydate(&tempts));
	(void) fprintf(fp, "filter delay: ");
	for (i = 0; i < NTP_SHIFT; i++) {
		(void) fprintf(fp, " %-8.8s",
			       fptoa(NTOHS_FP(pp->filtdelay[i]), 5));
		if (i == (NTP_SHIFT>>1)-1)
		    (void) fprintf(fp, "\n              ");
	}
	(void) fprintf(fp, "\n");
	(void) fprintf(fp, "filter offset:");
	for (i = 0; i < NTP_SHIFT; i++) {
		NTOHL_FP(&pp->filtoffset[i], &tempts);
		(void) fprintf(fp, " %-8.8s", lfptoa(&tempts, 6));
		if (i == (NTP_SHIFT>>1)-1)
		    (void) fprintf(fp, "\n              ");
	}
	(void) fprintf(fp, "\n");
	(void) fprintf(fp, "filter order: ");
	for (i = 0; i < NTP_SHIFT; i++) {
		(void) fprintf(fp, " %-8d", pp->order[i]);
		if (i == (NTP_SHIFT>>1)-1)
		    (void) fprintf(fp, "\n              ");
	}
	(void) fprintf(fp, "\n");
	NTOHL_FP(&pp->offset, &tempts);
	(void) fprintf(fp,
		       "offset %s, delay %s, error bound %s, filter error %s\n",
		       lfptoa(&tempts, 6), fptoa(NTOHS_FP(pp->delay), 5),
		       ufptoa(NTOHS_FP(pp->dispersion), 5),
		       ufptoa(NTOHS_FP(pp->selectdisp), 5));
}
static void printpeer ( register struct info_peer * pp , FILE * fp ) { register int i ; l_fp tempts ; sockaddr_u srcadr , dstadr ; SET_ADDRS ( dstadr , srcadr , pp , dstadr , srcadr ) ; ( void ) fprintf ( fp , " \n " , stoa ( & srcadr ) , stoa ( & dstadr ) ) ; ( void ) fprintf ( fp , " \n " , modetoa ( pp -> hmode ) , modetoa ( pp -> pmode ) , pp -> stratum , pp -> precision ) ; ( void ) fprintf ( fp , " \n " , pp -> leap & 0x2 ? ' ' : ' ' , pp -> leap & 0x1 ? ' ' : ' ' , refid_string ( pp -> refid , pp -> stratum ) , fptoa ( NTOHS_FP ( pp -> rootdelay ) , 5 ) , ufptoa ( NTOHS_FP ( pp -> rootdispersion ) , 5 ) ) ; ( void ) fprintf ( fp , " \n " , pp -> ppoll , pp -> hpoll , ( u_long ) pp -> keyid , pp -> version , ntohs ( pp -> associd ) ) ; ( void ) fprintf ( fp , " " , pp -> reach , pp -> unreach , pp -> flash2 ) ; ( void ) fprintf ( fp , " \n " , fptoa ( NTOHS_FP ( pp -> estbdelay ) , 5 ) , pp -> ttl ) ; ( void ) fprintf ( fp , " " , ( long ) ntohl ( pp -> timer ) ) ; print_pflag ( fp , pp -> flags ) ; NTOHL_FP ( & pp -> reftime , & tempts ) ; ( void ) fprintf ( fp , " \n " , prettydate ( & tempts ) ) ; NTOHL_FP ( & pp -> org , & tempts ) ; ( void ) fprintf ( fp , " \n " , prettydate ( & tempts ) ) ; NTOHL_FP ( & pp -> rec , & tempts ) ; ( void ) fprintf ( fp , " \n " , prettydate ( & tempts ) ) ; NTOHL_FP ( & pp -> xmt , & tempts ) ; ( void ) fprintf ( fp , " \n " , prettydate ( & tempts ) ) ; ( void ) fprintf ( fp , " " ) ; for ( i = 0 ; i < NTP_SHIFT ; i ++ ) { ( void ) fprintf ( fp , " " , fptoa ( NTOHS_FP ( pp -> filtdelay [ i ] ) , 5 ) ) ; if ( i == ( NTP_SHIFT >> 1 ) - 1 ) ( void ) fprintf ( fp , " \n " ) ; } ( void ) fprintf ( fp , " \n " ) ; ( void ) fprintf ( fp , " " ) ; for ( i = 0 ; i < NTP_SHIFT ; i ++ ) { NTOHL_FP ( & pp -> filtoffset [ i ] , & tempts ) ; ( void ) fprintf ( fp , " " , lfptoa ( & tempts , 6 ) ) ; if ( i == ( NTP_SHIFT >> 1 ) - 1 ) ( void ) fprintf ( fp , " \n " ) ; } ( void ) fprintf ( fp , " \n " ) ; ( void ) fprintf ( fp , " " ) ; for ( i = 0 ; i < NTP_SHIFT ; i ++ ) { ( void ) fprintf ( fp , " " , pp -> order [ i ] ) ; if ( i == ( NTP_SHIFT >> 1 ) - 1 ) ( void ) fprintf ( fp , " \n " ) ; } ( void ) fprintf ( fp , " \n " ) ; NTOHL_FP ( & pp -> offset , & tempts ) ; ( void ) fprintf ( fp , " \n " , lfptoa ( & tempts , 6 ) , fptoa ( NTOHS_FP ( pp -> delay ) , 5 ) , ufptoa ( NTOHS_FP ( pp -> dispersion ) , 5 ) , ufptoa ( NTOHS_FP ( pp -> selectdisp ) , 5 ) ) ; }
printpeer - print detail information for a peer
printpeer - print detail information for a peer