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