Esempio n. 1
0
/*****************************************************************************
 *  
 *  ntpq_get_assoc_clocktype
 *
 *  This function returns a clocktype value for a given association number 
 *  (not ID!):
 *
 *  NTP_CLOCKTYPE_UNKNOWN   Unknown clock type
 *  NTP_CLOCKTYPE_BROADCAST Broadcast server
 *  NTP_CLOCKTYPE_LOCAL     Local clock
 *  NTP_CLOCKTYPE_UNICAST   Unicast server
 *  NTP_CLOCKTYPE_MULTICAST Multicast server
 * 
 ****************************************************************************/
int ntpq_get_assoc_clocktype ( associd_t assoc_number )
{
	int type = 0;
	int i, rc = 0;
	sockaddr_u dum_store;
	char value[LENHOSTNAME];
	char resultbuf[1024];

	if ( assoc_number < 0 || assoc_number > numassoc )
		return -1;
	if ( peervar_assoc != assoc_cache[assoc_number].assid ) {
		i = ntpq_read_assoc_peervars(
		    assoc_cache[assoc_number].assid, resultbuf,
		    sizeof(resultbuf));
		if ( i <= 0 )
			return -1;
		rc = ntpq_getvar(resultbuf, i, "dstadr", value,
				 LENHOSTNAME );
	} else {
		rc = ntpq_get_peervar("dstadr",value,LENHOSTNAME);
	}

	if (0 != rc && decodenetnum(value, &dum_store)) {
		type = ntpq_decodeaddrtype(&dum_store);
		return type;
	}
	return -1;
}
Esempio n. 2
0
/*****************************************************************************
 *  
 *  ntpq_get_assoc_clocktype
 *
 *  This function returns a clocktype value for a given association number 
 *  (not ID!):
 *
 *  NTP_CLOCKTYPE_UNKNOWN   Unknown clock type
 *  NTP_CLOCKTYPE_BROADCAST Broadcast server
 *  NTP_CLOCKTYPE_LOCAL     Local clock
 *  NTP_CLOCKTYPE_UNICAST   Unicast server
 *  NTP_CLOCKTYPE_MULTICAST Multicast server
 * 
 ****************************************************************************/
int
ntpq_get_assoc_clocktype(
	int assoc_index
	)
{
	associd_t	associd;
	int		i;
	int		rc;
	sockaddr_u	dum_store;
	char		dstadr[LENHOSTNAME];
	char		resultbuf[NTPQ_BUFLEN];

	if (assoc_index < 0 || assoc_index >= numassoc)
		return -1;

	associd = assoc_cache[assoc_index].assid;
	if (associd == peervar_assoc) {
		rc = ntpq_get_peervar("dstadr", dstadr, sizeof(dstadr));
	} else {
		i = ntpq_read_assoc_peervars(associd, resultbuf,
					     sizeof(resultbuf));
		if (i <= 0)
			return -1;
		rc = ntpq_getvar(resultbuf, i, "dstadr", dstadr,
				 sizeof(dstadr));
	}

	if (0 != rc && decodenetnum(dstadr, &dum_store))
		return ntpq_decodeaddrtype(&dum_store);

	return -1;
}
Esempio n. 3
0
/*****************************************************************************
 *  
 *  ntpq_get_assoc_peervars
 *
 *  This function requests the peer variables of the specified association 
 *  from a NTP host. In order to access the variable values, the function 
 *  ntpq_get_peervar must be used.
 *
 ****************************************************************************
 * Parameters:
 *	associd		int	requested associaton ID 
 *
 * Returns:
 *	int		1 (one) if the peervars have been read
 * 			- OR - 
 *			0 (zero) if an error occured and the variable set
 *			could not be read
 ****************************************************************************/
 int  ntpq_get_assoc_peervars( associd_t associd )
{
	peervarlen = ntpq_read_assoc_peervars( associd, peervars, 
					       sizeof(peervars ) );
	if ( peervarlen <= 0 ) {
		peervar_assoc = 0;
		return 0;
	} else {
		peervar_assoc = associd;
		return 1;
	}
}