/***************************************************************************** * * 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; }
/***************************************************************************** * * 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; }