xref: /csrg-svn/usr.sbin/timed/timed/globals.h (revision 33123)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  *
12  *	@(#)globals.h	2.5 (Berkeley) 12/23/87
13  */
14 
15 #include <sys/param.h>
16 #include <stdio.h>
17 #include <sys/time.h>
18 #include <errno.h>
19 #include <syslog.h>
20 #include <sys/socket.h>
21 #include <netinet/in.h>
22 #include <netdb.h>
23 #include <arpa/inet.h>
24 
25 extern int errno;
26 extern int sock;
27 
28 #define SAMPLEINTVL	240		/* synch() freq for master, sec */
29 #define	MAXADJ		20		/* max correction (sec) for adjtime */
30 /*
31  * Parameters for network time measurement
32  * of each host using ICMP timestamp requests.
33  */
34 #define RANGE		20		/* best expected round-trip time, ms */
35 #define MSGS 		5		/* # of timestamp replies to average */
36 #define TRIALS		10		/* max # of timestamp echos sent */
37 
38 #define MINTOUT		360
39 #define MAXTOUT		900
40 
41 #define GOOD		1
42 #define UNREACHABLE	2
43 #define NONSTDTIME	3
44 #define HOSTDOWN 	0x7fffffff
45 
46 #define OFF	0
47 #define ON	1
48 
49 /*
50  * Global and per-network states.
51  */
52 #define NOMASTER 	0		/* no master on any network */
53 #define SLAVE 		1
54 #define MASTER		2
55 #define IGNORE		4
56 #define ALL		(SLAVE|MASTER|IGNORE)
57 #define SUBMASTER	(SLAVE|MASTER)
58 
59 #define NHOSTS		100	/* max number of hosts controlled by timed */
60 
61 struct host {
62 	char *name;
63 	struct sockaddr_in addr;
64 	long delta;
65 	u_short seq;
66 };
67 
68 struct netinfo {
69 	struct netinfo *next;
70 	u_long net;
71 	u_long mask;
72 	struct in_addr my_addr;
73 	struct sockaddr_in dest_addr;	/* broadcast addr or point-point */
74 	long status;
75 };
76 
77 extern struct netinfo *nettab;
78 extern int status;
79 extern int trace;
80 extern int sock;
81 extern struct sockaddr_in from;
82 extern struct netinfo *fromnet, *slavenet;
83 extern FILE *fd;
84 extern char hostname[];
85 extern char tracefile[];
86 extern struct host hp[];
87 extern int backoff;
88 extern long delay1, delay2;
89 extern int slvcount;
90 extern int nslavenets;		/* Number of nets were I could be a slave */
91 extern int nmasternets;		/* Number of nets were I could be a master */
92 extern int nignorednets;	/* Number of ignored nets */
93 extern int nnets;		/* Number of nets I am connected to */
94 
95 char *strcpy(), *malloc();
96