#include "ntp_types.h"
typedef union ctl_pkt_u_tag {
u_char data[480 + MAX_MAC_LEN];
u_int32 u32[(480 + MAX_MAC_LEN) / sizeof(u_int32)];
} ctl_pkt_u;
struct ntp_control {
u_char li_vn_mode;
u_char r_m_e_op;
u_short sequence;
u_short status;
associd_t associd;
u_short offset;
u_short count;
ctl_pkt_u u;
};
#define CTL_HEADER_LEN (offsetof(struct ntp_control, u))
#define CTL_MAX_DATA_LEN 468
#define CTL_MAXTRAPS 3
#define CTL_TRAPTIME (60*60)
#define CTL_MAXAUTHSIZE 64
#define CTL_RESPONSE 0x80
#define CTL_ERROR 0x40
#define CTL_MORE 0x20
#define CTL_OP_MASK 0x1f
#define CTL_ISRESPONSE(r_m_e_op) ((CTL_RESPONSE & (r_m_e_op)) != 0)
#define CTL_ISMORE(r_m_e_op) ((CTL_MORE & (r_m_e_op)) != 0)
#define CTL_ISERROR(r_m_e_op) ((CTL_ERROR & (r_m_e_op)) != 0)
#define CTL_OP(r_m_e_op) (CTL_OP_MASK & (r_m_e_op))
#define CTL_OP_UNSPEC 0
#define CTL_OP_READSTAT 1
#define CTL_OP_READVAR 2
#define CTL_OP_WRITEVAR 3
#define CTL_OP_READCLOCK 4
#define CTL_OP_WRITECLOCK 5
#define CTL_OP_SETTRAP 6
#define CTL_OP_ASYNCMSG 7
#define CTL_OP_CONFIGURE 8
#define CTL_OP_SAVECONFIG 9
#define CTL_OP_READ_MRU 10
#define CTL_OP_READ_ORDLIST_A 11
#define CTL_OP_REQ_NONCE 12
#define CTL_OP_UNSETTRAP 31
#define CTL_SST_TS_UNSPEC 0
#define CTL_SST_TS_ATOM 1
#define CTL_SST_TS_LF 2
#define CTL_SST_TS_HF 3
#define CTL_SST_TS_UHF 4
#define CTL_SST_TS_LOCAL 5
#define CTL_SST_TS_NTP 6
#define CTL_SST_TS_UDPTIME 7
#define CTL_SST_TS_WRSTWTCH 8
#define CTL_SST_TS_TELEPHONE 9
#define CTL_SYS_MAXEVENTS 15
#define CTL_SYS_STATUS(li, source, nevnt, evnt) \
(((((unsigned short)(li))<< 14)&0xc000) | \
(((source)<<8)&0x3f00) | \
(((nevnt)<<4)&0x00f0) | \
((evnt)&0x000f))
#define CTL_SYS_LI(status) (((status)>>14) & 0x3)
#define CTL_SYS_SOURCE(status) (((status)>>8) & 0x3f)
#define CTL_SYS_NEVNT(status) (((status)>>4) & 0xf)
#define CTL_SYS_EVENT(status) ((status) & 0xf)
#define CTL_PST_CONFIG 0x80
#define CTL_PST_AUTHENABLE 0x40
#define CTL_PST_AUTHENTIC 0x20
#define CTL_PST_REACH 0x10
#define CTL_PST_BCAST 0x08
#define CTL_PST_SEL_REJECT 0
#define CTL_PST_SEL_SANE 1
#define CTL_PST_SEL_CORRECT 2
#define CTL_PST_SEL_SELCAND 3
#define CTL_PST_SEL_SYNCCAND 4
#define CTL_PST_SEL_EXCESS 5
#define CTL_PST_SEL_SYSPEER 6
#define CTL_PST_SEL_PPS 7
#define CTL_PEER_MAXEVENTS 15
#define CTL_PEER_STATUS(status, nevnt, evnt) \
((((status)<<8) & 0xff00) | \
(((nevnt)<<4) & 0x00f0) | \
((evnt) & 0x000f))
#define CTL_PEER_STATVAL(status)(((status)>>8) & 0xff)
#define CTL_PEER_NEVNT(status) (((status)>>4) & 0xf)
#define CTL_PEER_EVENT(status) ((status) & 0xf)
#define CTL_CLK_OKAY 0
#define CTL_CLK_NOREPLY 1
#define CTL_CLK_BADFORMAT 2
#define CTL_CLK_FAULT 3
#define CTL_CLK_PROPAGATION 4
#define CTL_CLK_BADDATE 5
#define CTL_CLK_BADTIME 6
#define CTL_CLK_STATUS(status, event) \
((((status)<<8) & 0xff00) | \
((event) & 0x00ff))
#define CERR_UNSPEC 0
#define CERR_PERMISSION 1
#define CERR_BADFMT 2
#define CERR_BADOP 3
#define CERR_BADASSOC 4
#define CERR_UNKNOWNVAR 5
#define CERR_BADVALUE 6
#define CERR_RESTRICT 7
#define CERR_NORESOURCE CERR_PERMISSION
struct ctl_trap {
sockaddr_u tr_addr;
struct interface *tr_localaddr;
u_long tr_settime;
u_long tr_count;
u_long tr_origtime;
u_long tr_resets;
u_short tr_sequence;
u_char tr_flags;
u_char tr_version;
};
extern struct ctl_trap ctl_traps[CTL_MAXTRAPS];
#define TRAP_INUSE 0x1
#define TRAP_NONPRIO 0x2
#define TRAP_CONFIGURED 0x4
#define TYPE_SYS 1
#define TYPE_PEER 2
#define TYPE_CLOCK 3
#define IFSTATS_FIELDS 12
#define RESLIST_FIELDS 4