1 1.13 dholland /* $NetBSD: timed.h,v 1.13 2016/01/22 23:13:20 dholland Exp $ */ 2 1.3 cgd 3 1.1 cgd /* 4 1.6 perry * Copyright (c) 1983, 1993 5 1.6 perry * The Regents of the University of California. All rights reserved. 6 1.1 cgd * 7 1.1 cgd * Redistribution and use in source and binary forms, with or without 8 1.1 cgd * modification, are permitted provided that the following conditions 9 1.1 cgd * are met: 10 1.1 cgd * 1. Redistributions of source code must retain the above copyright 11 1.1 cgd * notice, this list of conditions and the following disclaimer. 12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 cgd * notice, this list of conditions and the following disclaimer in the 14 1.1 cgd * documentation and/or other materials provided with the distribution. 15 1.8 agc * 3. Neither the name of the University nor the names of its contributors 16 1.1 cgd * may be used to endorse or promote products derived from this software 17 1.1 cgd * without specific prior written permission. 18 1.1 cgd * 19 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 1.1 cgd * SUCH DAMAGE. 30 1.1 cgd * 31 1.6 perry * @(#)timed.h 8.1 (Berkeley) 6/2/93 32 1.1 cgd */ 33 1.1 cgd 34 1.7 perry #ifndef _PROTOCOLS_TIMED_H_ 35 1.7 perry #define _PROTOCOLS_TIMED_H_ 36 1.1 cgd 37 1.12 dholland #include <stdint.h> 38 1.12 dholland #include <limits.h> 39 1.12 dholland 40 1.1 cgd /* 41 1.1 cgd * Time Synchronization Protocol 42 1.1 cgd */ 43 1.1 cgd 44 1.1 cgd #define TSPVERSION 1 45 1.1 cgd #define ANYADDR NULL 46 1.1 cgd 47 1.1 cgd struct tsp { 48 1.10 perry uint8_t tsp_type; 49 1.10 perry uint8_t tsp_vers; 50 1.10 perry uint16_t tsp_seq; 51 1.1 cgd union { 52 1.4 cgd struct { 53 1.5 cgd int32_t tv_sec; 54 1.5 cgd int32_t tv_usec; 55 1.4 cgd } tspu_time; 56 1.1 cgd char tspu_hopcnt; 57 1.1 cgd } tsp_u; 58 1.13 dholland char tsp_name[_POSIX_HOST_NAME_MAX+1]; 59 1.1 cgd }; 60 1.1 cgd 61 1.1 cgd #define tsp_time tsp_u.tspu_time 62 1.1 cgd #define tsp_hopcnt tsp_u.tspu_hopcnt 63 1.1 cgd 64 1.1 cgd /* 65 1.1 cgd * Command types. 66 1.1 cgd */ 67 1.1 cgd #define TSP_ANY 0 /* match any types */ 68 1.1 cgd #define TSP_ADJTIME 1 /* send adjtime */ 69 1.1 cgd #define TSP_ACK 2 /* generic acknowledgement */ 70 1.1 cgd #define TSP_MASTERREQ 3 /* ask for master's name */ 71 1.1 cgd #define TSP_MASTERACK 4 /* acknowledge master request */ 72 1.1 cgd #define TSP_SETTIME 5 /* send network time */ 73 1.1 cgd #define TSP_MASTERUP 6 /* inform slaves that master is up */ 74 1.1 cgd #define TSP_SLAVEUP 7 /* slave is up but not polled */ 75 1.1 cgd #define TSP_ELECTION 8 /* advance candidature for master */ 76 1.1 cgd #define TSP_ACCEPT 9 /* support candidature of master */ 77 1.1 cgd #define TSP_REFUSE 10 /* reject candidature of master */ 78 1.1 cgd #define TSP_CONFLICT 11 /* two or more masters present */ 79 1.1 cgd #define TSP_RESOLVE 12 /* masters' conflict resolution */ 80 1.1 cgd #define TSP_QUIT 13 /* reject candidature if master is up */ 81 1.1 cgd #define TSP_DATE 14 /* reset the time (date command) */ 82 1.1 cgd #define TSP_DATEREQ 15 /* remote request to reset the time */ 83 1.1 cgd #define TSP_DATEACK 16 /* acknowledge time setting */ 84 1.1 cgd #define TSP_TRACEON 17 /* turn tracing on */ 85 1.1 cgd #define TSP_TRACEOFF 18 /* turn tracing off */ 86 1.1 cgd #define TSP_MSITE 19 /* find out master's site */ 87 1.1 cgd #define TSP_MSITEREQ 20 /* remote master's site request */ 88 1.1 cgd #define TSP_TEST 21 /* for testing election algo */ 89 1.1 cgd #define TSP_SETDATE 22 /* New from date command */ 90 1.1 cgd #define TSP_SETDATEREQ 23 /* New remote for above */ 91 1.1 cgd #define TSP_LOOP 24 /* loop detection packet */ 92 1.1 cgd 93 1.1 cgd #define TSPTYPENUMBER 25 94 1.1 cgd 95 1.1 cgd #ifdef TSPTYPES 96 1.11 matt const char * const tsptype[TSPTYPENUMBER] = 97 1.1 cgd { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", 98 1.1 cgd "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", 99 1.1 cgd "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", 100 1.1 cgd "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; 101 1.1 cgd #endif 102 1.1 cgd 103 1.7 perry #endif /* !_PROTOCOLS_TIMED_H_ */ 104