Annotation of embedaddon/ntp/include/ntp_control.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * ntp_control.h - definitions related to NTP mode 6 control messages
        !             3:  */
        !             4: 
        !             5: #include "ntp_types.h"
        !             6: 
        !             7: struct ntp_control {
        !             8:        u_char li_vn_mode;              /* leap, version, mode */
        !             9:        u_char r_m_e_op;                /* response, more, error, opcode */
        !            10:        u_short sequence;               /* sequence number of request */
        !            11:        u_short status;                 /* status word for association */
        !            12:        associd_t associd;              /* association ID */
        !            13:        u_short offset;                 /* offset of this batch of data */
        !            14:        u_short count;                  /* count of data in this packet */
        !            15:        u_char data[(480 + MAX_MAC_LEN)]; /* data + auth */
        !            16: };
        !            17: 
        !            18: /*
        !            19:  * Length of the control header, in octets
        !            20:  */
        !            21: #define        CTL_HEADER_LEN          (offsetof(struct ntp_control, data))
        !            22: #define        CTL_MAX_DATA_LEN        468
        !            23: 
        !            24: 
        !            25: /*
        !            26:  * Limits and things
        !            27:  */
        !            28: #define        CTL_MAXTRAPS    3               /* maximum number of traps we allow */
        !            29: #define        CTL_TRAPTIME    (60*60)         /* time out traps in 1 hour */
        !            30: #define        CTL_MAXAUTHSIZE 64              /* maximum size of an authen'ed req */
        !            31: 
        !            32: /*
        !            33:  * Decoding for the r_m_e_op field
        !            34:  */
        !            35: #define        CTL_RESPONSE    0x80
        !            36: #define        CTL_ERROR       0x40
        !            37: #define        CTL_MORE        0x20
        !            38: #define        CTL_OP_MASK     0x1f
        !            39: 
        !            40: #define        CTL_ISRESPONSE(r_m_e_op)        (((r_m_e_op) & 0x80) != 0)
        !            41: #define        CTL_ISMORE(r_m_e_op)    (((r_m_e_op) & 0x20) != 0)
        !            42: #define        CTL_ISERROR(r_m_e_op)   (((r_m_e_op) & 0x40) != 0)
        !            43: #define        CTL_OP(r_m_e_op)        ((r_m_e_op) & CTL_OP_MASK)
        !            44: 
        !            45: /*
        !            46:  * Opcodes
        !            47:  */
        !            48: #define        CTL_OP_UNSPEC           0       /* unspeciffied */
        !            49: #define        CTL_OP_READSTAT         1       /* read status */
        !            50: #define        CTL_OP_READVAR          2       /* read variables */
        !            51: #define        CTL_OP_WRITEVAR         3       /* write variables */
        !            52: #define        CTL_OP_READCLOCK        4       /* read clock variables */
        !            53: #define        CTL_OP_WRITECLOCK       5       /* write clock variables */
        !            54: #define        CTL_OP_SETTRAP          6       /* set trap address */
        !            55: #define        CTL_OP_ASYNCMSG         7       /* asynchronous message */
        !            56: #define CTL_OP_CONFIGURE       8       /* runtime configuration */
        !            57: #define CTL_OP_SAVECONFIG      9       /* save config to file */
        !            58: #define        CTL_OP_UNSETTRAP        31      /* unset trap */
        !            59: 
        !            60: /*
        !            61:  * {En,De}coding of the system status word
        !            62:  */
        !            63: #define        CTL_SST_TS_UNSPEC       0       /* unspec */
        !            64: #define        CTL_SST_TS_ATOM         1       /* pps */
        !            65: #define        CTL_SST_TS_LF           2       /* lf radio */
        !            66: #define        CTL_SST_TS_HF           3       /* hf radio */
        !            67: #define        CTL_SST_TS_UHF          4       /* uhf radio */
        !            68: #define        CTL_SST_TS_LOCAL        5       /* local */
        !            69: #define        CTL_SST_TS_NTP          6       /* ntp */
        !            70: #define        CTL_SST_TS_UDPTIME      7       /* other */
        !            71: #define        CTL_SST_TS_WRSTWTCH     8       /* wristwatch */
        !            72: #define        CTL_SST_TS_TELEPHONE    9       /* telephone */
        !            73: 
        !            74: #define        CTL_SYS_MAXEVENTS       15
        !            75: 
        !            76: #define        CTL_SYS_STATUS(li, source, nevnt, evnt) \
        !            77:                (((((unsigned short)(li))<< 14)&0xc000) | \
        !            78:                (((source)<<8)&0x3f00) | \
        !            79:                (((nevnt)<<4)&0x00f0) | \
        !            80:                ((evnt)&0x000f))
        !            81: 
        !            82: #define        CTL_SYS_LI(status)      (((status)>>14) & 0x3)
        !            83: #define        CTL_SYS_SOURCE(status)  (((status)>>8) & 0x3f)
        !            84: #define        CTL_SYS_NEVNT(status)   (((status)>>4) & 0xf)
        !            85: #define        CTL_SYS_EVENT(status)   ((status) & 0xf)
        !            86: 
        !            87: /*
        !            88:  * {En,De}coding of the peer status word
        !            89:  */
        !            90: #define        CTL_PST_CONFIG          0x80
        !            91: #define        CTL_PST_AUTHENABLE      0x40
        !            92: #define        CTL_PST_AUTHENTIC       0x20
        !            93: #define        CTL_PST_REACH           0x10
        !            94: #define        CTL_PST_BCAST           0x08
        !            95: 
        !            96: #define        CTL_PST_SEL_REJECT      0       /*   reject */
        !            97: #define        CTL_PST_SEL_SANE        1       /* x falsetick */
        !            98: #define        CTL_PST_SEL_CORRECT     2       /* . excess */
        !            99: #define        CTL_PST_SEL_SELCAND     3       /* - outlyer */
        !           100: #define        CTL_PST_SEL_SYNCCAND    4       /* + candidate */
        !           101: #define        CTL_PST_SEL_EXCESS      5       /* # backup */
        !           102: #define        CTL_PST_SEL_SYSPEER     6       /* * sys.peer */
        !           103: #define        CTL_PST_SEL_PPS         7       /* o pps.peer */
        !           104: 
        !           105: #define        CTL_PEER_MAXEVENTS      15
        !           106: 
        !           107: #define        CTL_PEER_STATUS(status, nevnt, evnt) \
        !           108:                ((((status)<<8) & 0xff00) | \
        !           109:                (((nevnt)<<4) & 0x00f0) | \
        !           110:                ((evnt) & 0x000f))
        !           111: 
        !           112: #define        CTL_PEER_STATVAL(status)(((status)>>8) & 0xff)
        !           113: #define        CTL_PEER_NEVNT(status)  (((status)>>4) & 0xf)
        !           114: #define        CTL_PEER_EVENT(status)  ((status) & 0xf)
        !           115: 
        !           116: /*
        !           117:  * {En,De}coding of the clock status word
        !           118:  */
        !           119: #define        CTL_CLK_OKAY            0
        !           120: #define        CTL_CLK_NOREPLY         1
        !           121: #define        CTL_CLK_BADFORMAT       2
        !           122: #define        CTL_CLK_FAULT           3
        !           123: #define        CTL_CLK_PROPAGATION     4
        !           124: #define        CTL_CLK_BADDATE         5
        !           125: #define        CTL_CLK_BADTIME         6
        !           126: 
        !           127: #define        CTL_CLK_STATUS(status, event) \
        !           128:                ((((status)<<8) & 0xff00) | \
        !           129:                ((event) & 0x00ff))
        !           130: 
        !           131: /*
        !           132:  * Error code responses returned when the E bit is set.
        !           133:  */
        !           134: #define        CERR_UNSPEC     0
        !           135: #define        CERR_PERMISSION 1
        !           136: #define        CERR_BADFMT     2
        !           137: #define        CERR_BADOP      3
        !           138: #define        CERR_BADASSOC   4
        !           139: #define        CERR_UNKNOWNVAR 5
        !           140: #define        CERR_BADVALUE   6
        !           141: #define        CERR_RESTRICT   7
        !           142: 
        !           143: #define        CERR_NORESOURCE CERR_PERMISSION /* wish there was a different code */
        !           144: 
        !           145: 
        !           146: /*
        !           147:  * System variables we understand
        !           148:  */
        !           149: #define        CS_LEAP         1
        !           150: #define        CS_STRATUM      2
        !           151: #define        CS_PRECISION    3
        !           152: #define        CS_ROOTDELAY    4
        !           153: #define        CS_ROOTDISPERSION       5
        !           154: #define        CS_REFID        6
        !           155: #define        CS_REFTIME      7
        !           156: #define        CS_POLL         8
        !           157: #define        CS_PEERID       9
        !           158: #define        CS_OFFSET       10
        !           159: #define        CS_DRIFT        11
        !           160: #define CS_JITTER      12
        !           161: #define CS_ERROR       13
        !           162: #define        CS_CLOCK        14
        !           163: #define        CS_PROCESSOR    15
        !           164: #define        CS_SYSTEM       16
        !           165: #define CS_VERSION     17
        !           166: #define        CS_STABIL       18
        !           167: #define CS_VARLIST     19
        !           168: #define CS_TAI          20
        !           169: #define CS_LEAPTAB      21
        !           170: #define CS_LEAPEND      22
        !           171: #define        CS_RATE         23
        !           172: #ifdef OPENSSL
        !           173: #define CS_FLAGS       24
        !           174: #define CS_HOST                25
        !           175: #define CS_PUBLIC      26
        !           176: #define        CS_CERTIF       27
        !           177: #define        CS_SIGNATURE    28
        !           178: #define        CS_REVTIME      29
        !           179: #define        CS_GROUP        30
        !           180: #define CS_DIGEST      31
        !           181: #define        CS_MAXCODE      CS_DIGEST
        !           182: #else
        !           183: #define        CS_MAXCODE      CS_RATE
        !           184: #endif /* OPENSSL */
        !           185: 
        !           186: /*
        !           187:  * Peer variables we understand
        !           188:  */
        !           189: #define        CP_CONFIG       1
        !           190: #define        CP_AUTHENABLE   2
        !           191: #define        CP_AUTHENTIC    3
        !           192: #define        CP_SRCADR       4
        !           193: #define        CP_SRCPORT      5
        !           194: #define        CP_DSTADR       6
        !           195: #define        CP_DSTPORT      7
        !           196: #define        CP_LEAP         8
        !           197: #define        CP_HMODE        9
        !           198: #define        CP_STRATUM      10
        !           199: #define        CP_PPOLL        11
        !           200: #define        CP_HPOLL        12
        !           201: #define        CP_PRECISION    13
        !           202: #define        CP_ROOTDELAY    14
        !           203: #define        CP_ROOTDISPERSION       15
        !           204: #define        CP_REFID        16
        !           205: #define        CP_REFTIME      17
        !           206: #define        CP_ORG          18
        !           207: #define        CP_REC          19
        !           208: #define        CP_XMT          20
        !           209: #define        CP_REACH        21
        !           210: #define        CP_UNREACH      22
        !           211: #define        CP_TIMER        23
        !           212: #define        CP_DELAY        24
        !           213: #define        CP_OFFSET       25
        !           214: #define CP_JITTER      26
        !           215: #define        CP_DISPERSION   27
        !           216: #define        CP_KEYID        28
        !           217: #define        CP_FILTDELAY    29
        !           218: #define        CP_FILTOFFSET   30
        !           219: #define        CP_PMODE        31
        !           220: #define        CP_RECEIVED     32
        !           221: #define        CP_SENT         33
        !           222: #define        CP_FILTERROR    34
        !           223: #define        CP_FLASH        35
        !           224: #define CP_TTL         36
        !           225: #define CP_VARLIST     37
        !           226: #define        CP_IN           38
        !           227: #define        CP_OUT          39
        !           228: #define        CP_RATE         40
        !           229: #define        CP_BIAS         41
        !           230: #ifdef OPENSSL
        !           231: #define CP_FLAGS       42
        !           232: #define CP_HOST                43
        !           233: #define CP_VALID       44
        !           234: #define        CP_INITSEQ      45
        !           235: #define        CP_INITKEY      46
        !           236: #define        CP_INITTSP      47
        !           237: #define        CP_SIGNATURE    48
        !           238: #define        CP_MAXCODE      CP_SIGNATURE
        !           239: #else
        !           240: #define        CP_MAXCODE      CP_BIAS
        !           241: #endif /* OPENSSL */
        !           242: 
        !           243: /*
        !           244:  * Clock variables we understand
        !           245:  */
        !           246: #define        CC_TYPE         1
        !           247: #define        CC_TIMECODE     2
        !           248: #define        CC_POLL         3
        !           249: #define        CC_NOREPLY      4
        !           250: #define        CC_BADFORMAT    5
        !           251: #define        CC_BADDATA      6
        !           252: #define        CC_FUDGETIME1   7
        !           253: #define        CC_FUDGETIME2   8
        !           254: #define        CC_FUDGEVAL1    9
        !           255: #define        CC_FUDGEVAL2    10
        !           256: #define        CC_FLAGS        11
        !           257: #define        CC_DEVICE       12
        !           258: #define CC_VARLIST     13
        !           259: #define        CC_MAXCODE      CC_VARLIST
        !           260: 
        !           261: /*
        !           262:  * Definition of the structure used internally to hold trap information.
        !           263:  * ntp_request.c wants to see this.
        !           264:  */
        !           265: struct ctl_trap {
        !           266:        sockaddr_u tr_addr;             /* address of trap recipient */
        !           267:        struct interface *tr_localaddr; /* interface to send this through */
        !           268:        u_long tr_settime;              /* time trap was set */
        !           269:        u_long tr_count;                /* async messages sent to this guy */
        !           270:        u_long tr_origtime;             /* time trap was originally set */
        !           271:        u_long tr_resets;               /* count of resets for this trap */
        !           272:        u_short tr_sequence;            /* trap sequence id */
        !           273:        u_char tr_flags;                /* trap flags */
        !           274:        u_char tr_version;              /* version number of trapper */
        !           275: };
        !           276: extern struct ctl_trap ctl_trap[];
        !           277: 
        !           278: /*
        !           279:  * Flag bits
        !           280:  */
        !           281: #define        TRAP_INUSE      0x1             /* this trap is active */
        !           282: #define        TRAP_NONPRIO    0x2             /* this trap is non-priority */
        !           283: #define        TRAP_CONFIGURED 0x4             /* this trap was configured */
        !           284: 
        !           285: /*
        !           286:  * Types of things we may deal with
        !           287:  * shared between ntpq and library
        !           288:  */
        !           289: #define        TYPE_SYS        1
        !           290: #define        TYPE_PEER       2
        !           291: #define        TYPE_CLOCK      3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>