1*8724a494Sdholland /* $NetBSD: timed.h,v 1.13 2016/01/22 23:13:20 dholland Exp $ */ 24d2cbfceScgd 361f28255Scgd /* 4a141abe4Sperry * Copyright (c) 1983, 1993 5a141abe4Sperry * The Regents of the University of California. All rights reserved. 661f28255Scgd * 761f28255Scgd * Redistribution and use in source and binary forms, with or without 861f28255Scgd * modification, are permitted provided that the following conditions 961f28255Scgd * are met: 1061f28255Scgd * 1. Redistributions of source code must retain the above copyright 1161f28255Scgd * notice, this list of conditions and the following disclaimer. 1261f28255Scgd * 2. Redistributions in binary form must reproduce the above copyright 1361f28255Scgd * notice, this list of conditions and the following disclaimer in the 1461f28255Scgd * documentation and/or other materials provided with the distribution. 15039cc956Sagc * 3. Neither the name of the University nor the names of its contributors 1661f28255Scgd * may be used to endorse or promote products derived from this software 1761f28255Scgd * without specific prior written permission. 1861f28255Scgd * 1961f28255Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2061f28255Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2161f28255Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2261f28255Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2361f28255Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2461f28255Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2561f28255Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2661f28255Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2761f28255Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2861f28255Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2961f28255Scgd * SUCH DAMAGE. 3061f28255Scgd * 31a141abe4Sperry * @(#)timed.h 8.1 (Berkeley) 6/2/93 3261f28255Scgd */ 3361f28255Scgd 343b3774fcSperry #ifndef _PROTOCOLS_TIMED_H_ 353b3774fcSperry #define _PROTOCOLS_TIMED_H_ 3661f28255Scgd 37a8c9c98eSdholland #include <stdint.h> 38a8c9c98eSdholland #include <limits.h> 39a8c9c98eSdholland 4061f28255Scgd /* 4161f28255Scgd * Time Synchronization Protocol 4261f28255Scgd */ 4361f28255Scgd 4461f28255Scgd #define TSPVERSION 1 4561f28255Scgd #define ANYADDR NULL 4661f28255Scgd 4761f28255Scgd struct tsp { 485f65228bSperry uint8_t tsp_type; 495f65228bSperry uint8_t tsp_vers; 505f65228bSperry uint16_t tsp_seq; 5161f28255Scgd union { 52e9e09ebaScgd struct { 538b65ecffScgd int32_t tv_sec; 548b65ecffScgd int32_t tv_usec; 55e9e09ebaScgd } tspu_time; 5661f28255Scgd char tspu_hopcnt; 5761f28255Scgd } tsp_u; 58*8724a494Sdholland char tsp_name[_POSIX_HOST_NAME_MAX+1]; 5961f28255Scgd }; 6061f28255Scgd 6161f28255Scgd #define tsp_time tsp_u.tspu_time 6261f28255Scgd #define tsp_hopcnt tsp_u.tspu_hopcnt 6361f28255Scgd 6461f28255Scgd /* 6561f28255Scgd * Command types. 6661f28255Scgd */ 6761f28255Scgd #define TSP_ANY 0 /* match any types */ 6861f28255Scgd #define TSP_ADJTIME 1 /* send adjtime */ 6961f28255Scgd #define TSP_ACK 2 /* generic acknowledgement */ 7061f28255Scgd #define TSP_MASTERREQ 3 /* ask for master's name */ 7161f28255Scgd #define TSP_MASTERACK 4 /* acknowledge master request */ 7261f28255Scgd #define TSP_SETTIME 5 /* send network time */ 7361f28255Scgd #define TSP_MASTERUP 6 /* inform slaves that master is up */ 7461f28255Scgd #define TSP_SLAVEUP 7 /* slave is up but not polled */ 7561f28255Scgd #define TSP_ELECTION 8 /* advance candidature for master */ 7661f28255Scgd #define TSP_ACCEPT 9 /* support candidature of master */ 7761f28255Scgd #define TSP_REFUSE 10 /* reject candidature of master */ 7861f28255Scgd #define TSP_CONFLICT 11 /* two or more masters present */ 7961f28255Scgd #define TSP_RESOLVE 12 /* masters' conflict resolution */ 8061f28255Scgd #define TSP_QUIT 13 /* reject candidature if master is up */ 8161f28255Scgd #define TSP_DATE 14 /* reset the time (date command) */ 8261f28255Scgd #define TSP_DATEREQ 15 /* remote request to reset the time */ 8361f28255Scgd #define TSP_DATEACK 16 /* acknowledge time setting */ 8461f28255Scgd #define TSP_TRACEON 17 /* turn tracing on */ 8561f28255Scgd #define TSP_TRACEOFF 18 /* turn tracing off */ 8661f28255Scgd #define TSP_MSITE 19 /* find out master's site */ 8761f28255Scgd #define TSP_MSITEREQ 20 /* remote master's site request */ 8861f28255Scgd #define TSP_TEST 21 /* for testing election algo */ 8961f28255Scgd #define TSP_SETDATE 22 /* New from date command */ 9061f28255Scgd #define TSP_SETDATEREQ 23 /* New remote for above */ 9161f28255Scgd #define TSP_LOOP 24 /* loop detection packet */ 9261f28255Scgd 9361f28255Scgd #define TSPTYPENUMBER 25 9461f28255Scgd 9561f28255Scgd #ifdef TSPTYPES 9680d082b8Smatt const char * const tsptype[TSPTYPENUMBER] = 9761f28255Scgd { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", 9861f28255Scgd "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", 9961f28255Scgd "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", 10061f28255Scgd "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; 10161f28255Scgd #endif 10261f28255Scgd 1033b3774fcSperry #endif /* !_PROTOCOLS_TIMED_H_ */ 104