Beispiel #1
0
/*
 * statustoa - return a descriptive string for a peer status
 */
char *
statustoa(
	int type,
	int st
	)
{
	char *	cb;
	char *	cc;
	u_char	pst;

	LIB_GETBUF(cb);

	switch (type) {

	case TYPE_SYS:
		snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s, %s",
			 getcode(CTL_SYS_LI(st), leap_codes),
			 getcode(CTL_SYS_SOURCE(st), sync_codes),
			 getevents(CTL_SYS_NEVNT(st)),
			 getcode(CTL_SYS_EVENT(st), sys_codes));
		break;
	
	case TYPE_PEER:
		pst = (u_char)CTL_PEER_STATVAL(st);
		snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s",
			 peer_st_flags(pst),
			 getcode(pst & 0x7, select_codes),
			 getevents(CTL_PEER_NEVNT(st)));
		if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) {
			cc = cb + strlen(cb);
			snprintf(cc, LIB_BUFLENGTH - (cc - cb), ", %s",
				 getcode(CTL_PEER_EVENT(st),
					 peer_codes));
		}
		break;
	
	case TYPE_CLOCK:
		snprintf(cb, LIB_BUFLENGTH, "%s, %s",
			 getevents(CTL_SYS_NEVNT(st)),
			 getcode((st) & 0xf, clock_codes));
		break;
	}

	return cb;
}
Beispiel #2
0
/*
 * statustoa - return a descriptive string for a peer status
 */
char *
statustoa(
	int type,
	int st
	)
{
	char *cb;
	u_char pst;

	LIB_GETBUF(cb);

	switch (type) {
	    case TYPE_SYS:
		strcpy(cb, getcode(CTL_SYS_LI(st), leap_codes));
		strcat(cb, ", ");
		strcat(cb, getcode(CTL_SYS_SOURCE(st), sync_codes));
		strcat(cb, ", ");
		strcat(cb, getevents(CTL_SYS_NEVNT(st)));
		strcat(cb, ", ");
		strcat(cb, getcode(CTL_SYS_EVENT(st), sys_codes));
		break;
	
	    case TYPE_PEER:

		/*
		 * Handcraft the bits
		 */
		pst = (u_char) CTL_PEER_STATVAL(st);
		if (pst & CTL_PST_CONFIG)
			strcpy(cb, "conf");
		if (pst & CTL_PST_AUTHENABLE) {
			if (pst & CTL_PST_CONFIG)
				strcat(cb, ", authenb");
			else
				strcat(cb, "authenb");
		}
		if (pst & CTL_PST_AUTHENTIC) {
			if (pst & (CTL_PST_CONFIG | CTL_PST_AUTHENABLE))
				strcat(cb, ", auth");
			else
				strcat(cb, "auth");
		}
		if (pst & CTL_PST_REACH) {
			if (pst & (CTL_PST_CONFIG | CTL_PST_AUTHENABLE |
			    CTL_PST_AUTHENTIC))
				strcat(cb, ", reach");
			else
				strcat(cb, "reach");
		}
		if (pst & CTL_PST_BCAST) {
			if (pst & (CTL_PST_CONFIG | CTL_PST_AUTHENABLE |
			    CTL_PST_AUTHENTIC | CTL_PST_REACH))
				strcat(cb, ", bcst");
			else
				strcat(cb, "bcst");
		}

		/*
		 * Now the codes
		 */
		strcat(cb, ", ");
		strcat(cb, getcode(pst & 0x7, select_codes));
		strcat(cb, ", ");
		strcat(cb, getevents(CTL_PEER_NEVNT(st)));
		if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) {
			strcat(cb, ", ");
			strcat(cb, getcode(CTL_PEER_EVENT(st),
			    peer_codes));
		}
		break;
	
	    case TYPE_CLOCK:
		strcat(cb, ", ");
		strcat(cb, getevents(CTL_SYS_NEVNT(st)));
		strcat(cb, ", ");
		strcat(cb, getcode((st) & 0xf, clock_codes));
		break;
	}
	return cb;
}