statestr.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* pretty printing of status information
*/
#include <stdio.h>
#include "ntp_stdlib.h"
#include "ntp_fp.h"
#include "ntp.h"
#include "lib_strbuf.h"
#include "ntp_refclock.h"
#include "ntp_control.h"
#include "ntp_string.h"
/*
* Structure for turning various constants into a readable string.
*/
struct codestring {
int code;
const char *string;
};
/*
* Leap values
*/
static
struct codestring leap_codes[] = {
{ LEAP_NOWARNING, "leap_none" },
{ LEAP_ADDSECOND, "leap_add_sec" },
{ LEAP_DELSECOND, "leap_del_sec" },
{ LEAP_NOTINSYNC, "sync_alarm" },
{ -1, "leap" }
};
/*
* Clock source
*/
static
struct codestring sync_codes[] = {
{ CTL_SST_TS_UNSPEC, "sync_unspec" },
{ CTL_SST_TS_ATOM, "sync_atomic" },
{ CTL_SST_TS_LF, "sync_lf_clock" },
{ CTL_SST_TS_HF, "sync_hf_clock" },
{ CTL_SST_TS_UHF, "sync_uhf_clock" },
{ CTL_SST_TS_LOCAL, "sync_local_proto" },
{ CTL_SST_TS_NTP, "sync_ntp" },
{ CTL_SST_TS_UDPTIME, "sync_udp/time" },
{ CTL_SST_TS_WRSTWTCH, "sync_wristwatch" },
{ CTL_SST_TS_TELEPHONE, "sync_telephone" },
{ -1, "sync" }
};
/*
* Peer selection
*/
static
struct codestring select_codes[] = {
{ CTL_PST_SEL_REJECT, "sel_reject" },
{ CTL_PST_SEL_SANE, "sel_sane" },
{ CTL_PST_SEL_CORRECT, "sel_correct" },
{ CTL_PST_SEL_SELCAND, "sel_candidate" },
{ CTL_PST_SEL_SYNCCAND, "sel_sync" },
{ CTL_PST_SEL_DISTSYSPEER, "sel_sys.peer, hi_dist" },
{ CTL_PST_SEL_SYSPEER, "sel_sys.peer" },
{ -1, "sel" }
};
/*
* Clock status
*/
static
struct codestring clock_codes[] = {
{ CTL_CLK_OKAY, "clk_okay" },
{ CTL_CLK_NOREPLY, "clk_noreply" },
{ CTL_CLK_BADFORMAT, "clk_badformat" },
{ CTL_CLK_FAULT, "clk_fault" },
{ CTL_CLK_PROPAGATION, "clk_propagation" },
{ CTL_CLK_BADDATE, "clk_baddate" },
{ CTL_CLK_BADTIME, "clk_badtime" },
{ -1, "clk" }
};
/*
* System Events
*/
static
struct codestring sys_codes[] = {
{ EVNT_UNSPEC, "event_unspec" },
{ EVNT_SYSRESTART, "event_restart" },
{ EVNT_SYSFAULT, "event_fault" },
{ EVNT_SYNCCHG, "event_sync_chg" },
{ EVNT_PEERSTCHG, "event_peer/strat_chg" },
{ EVNT_CLOCKRESET, "event_clock_reset" },
{ EVNT_BADDATETIM, "event_bad_date" },
{ EVNT_CLOCKEXCPT, "event_clock_excptn" },
{ -1, "event" }
};
/*
* Peer Events
*/
static
struct codestring peer_codes[] = {
{ EVNT_UNSPEC, "event_unspec" },
#if 0
#endif
{ -1, "event" }
};
/* Forwards */
static char *getcode P((int, struct codestring *));
static char *getevents P((int));
/*
* getcode - return string corresponding to code
*/
static char *
int code;
struct codestring *codetab;
{
static char buf[30];
codetab++;
}
return buf;
}
/*
* getevents - return a descriptive string for the event count
*/
static char *
int cnt;
{
static char buf[20];
if (cnt == 0)
return "no events";
return buf;
}
/*
* statustoa - return a descriptive string for a peer status
*/
char *
int type;
int st;
{
char *cb;
LIB_GETBUF(cb);
switch (type) {
case TYPE_SYS:
break;
case TYPE_PEER:
/*
* Handcraft the bits
*/
if (!(pst & CTL_PST_REACH)) {
} else {
}
if (pst & CTL_PST_CONFIG)
if (pst & CTL_PST_AUTHENABLE) {
else
}
/*
* Now the codes
*/
}
peer_codes));
}
break;
case TYPE_CLOCK:
break;
}
return cb;
}
const char *
int num;
{
}
const char *
int num;
{
}
const char *
int status;
{
}
const char *
int status;
{
}
const char *
int status;
{
}