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