11539Srgrimes/*
21539Srgrimes * Copyright (c) 1983, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
13203965Simp * 3. Neither the name of the University nor the names of its contributors
141539Srgrimes *    may be used to endorse or promote products derived from this software
151539Srgrimes *    without specific prior written permission.
161539Srgrimes *
171539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271539Srgrimes * SUCH DAMAGE.
281539Srgrimes *
291539Srgrimes *	@(#)timed.h	8.1 (Berkeley) 6/2/93
3086644Sjhb *
3186644Sjhb * $FreeBSD$
321539Srgrimes */
331539Srgrimes
342163Spaul#ifndef	_PROTOCOLS_TIMED_H_
352163Spaul#define	_PROTOCOLS_TIMED_H_
361539Srgrimes
371539Srgrimes/*
381539Srgrimes * Time Synchronization Protocol
391539Srgrimes */
401539Srgrimes
411539Srgrimes#define	TSPVERSION	1
421539Srgrimes#define ANYADDR 	NULL
431539Srgrimes
441539Srgrimesstruct tsp {
4586644Sjhb	u_int8_t	tsp_type;
4686644Sjhb	u_int8_t	tsp_vers;
4786644Sjhb	u_int16_t	tsp_seq;
481539Srgrimes	union {
4986644Sjhb		struct {
5086644Sjhb			int32_t	tv_sec;
5186644Sjhb			int32_t	tv_usec;
5286644Sjhb		} tspu_time;
531539Srgrimes		char tspu_hopcnt;
541539Srgrimes	} tsp_u;
551539Srgrimes	char tsp_name[MAXHOSTNAMELEN];
561539Srgrimes};
571539Srgrimes
581539Srgrimes#define	tsp_time	tsp_u.tspu_time
591539Srgrimes#define	tsp_hopcnt	tsp_u.tspu_hopcnt
608858Srgrimes
611539Srgrimes/*
621539Srgrimes * Command types.
631539Srgrimes */
641539Srgrimes#define	TSP_ANY			0	/* match any types */
651539Srgrimes#define	TSP_ADJTIME		1	/* send adjtime */
661539Srgrimes#define	TSP_ACK			2	/* generic acknowledgement */
678858Srgrimes#define	TSP_MASTERREQ		3	/* ask for master's name */
681539Srgrimes#define	TSP_MASTERACK		4	/* acknowledge master request */
691539Srgrimes#define	TSP_SETTIME		5	/* send network time */
701539Srgrimes#define	TSP_MASTERUP		6	/* inform slaves that master is up */
711539Srgrimes#define	TSP_SLAVEUP		7	/* slave is up but not polled */
721539Srgrimes#define	TSP_ELECTION		8	/* advance candidature for master */
731539Srgrimes#define	TSP_ACCEPT		9	/* support candidature of master */
741539Srgrimes#define	TSP_REFUSE		10	/* reject candidature of master */
751539Srgrimes#define	TSP_CONFLICT		11	/* two or more masters present */
761539Srgrimes#define	TSP_RESOLVE		12	/* masters' conflict resolution */
771539Srgrimes#define	TSP_QUIT		13	/* reject candidature if master is up */
781539Srgrimes#define	TSP_DATE		14	/* reset the time (date command) */
791539Srgrimes#define	TSP_DATEREQ		15	/* remote request to reset the time */
801539Srgrimes#define	TSP_DATEACK		16	/* acknowledge time setting  */
811539Srgrimes#define	TSP_TRACEON		17	/* turn tracing on */
821539Srgrimes#define	TSP_TRACEOFF		18	/* turn tracing off */
831539Srgrimes#define	TSP_MSITE		19	/* find out master's site */
841539Srgrimes#define	TSP_MSITEREQ		20	/* remote master's site request */
851539Srgrimes#define	TSP_TEST		21	/* for testing election algo */
861539Srgrimes#define	TSP_SETDATE		22	/* New from date command */
871539Srgrimes#define	TSP_SETDATEREQ		23	/* New remote for above */
881539Srgrimes#define	TSP_LOOP		24	/* loop detection packet */
891539Srgrimes
901539Srgrimes#define	TSPTYPENUMBER		25
911539Srgrimes
921539Srgrimes#ifdef TSPTYPES
93249311Sedstatic char const * const tsptype[] =
948858Srgrimes  { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
958858Srgrimes  "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
961539Srgrimes  "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ",
971539Srgrimes  "TEST", "SETDATE", "SETDATEREQ", "LOOP" };
98249311Sed_Static_assert(sizeof(tsptype) / sizeof(const char *) == TSPTYPENUMBER,
99249311Sed    "Size of tsptype does not match TSPTYPENUMBER");
1001539Srgrimes#endif
1011539Srgrimes
1021539Srgrimes#endif /* !_TIMED_H_ */
103