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 the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)globals.h 2.6 (Berkeley) 06/18/88 18 */ 19 20 #include <sys/param.h> 21 #include <stdio.h> 22 #include <sys/time.h> 23 #include <errno.h> 24 #include <syslog.h> 25 #include <sys/socket.h> 26 #include <netinet/in.h> 27 #include <netdb.h> 28 #include <arpa/inet.h> 29 30 extern int errno; 31 extern int sock; 32 33 #define SAMPLEINTVL 240 /* synch() freq for master, sec */ 34 #define MAXADJ 20 /* max correction (sec) for adjtime */ 35 /* 36 * Parameters for network time measurement 37 * of each host using ICMP timestamp requests. 38 */ 39 #define RANGE 20 /* best expected round-trip time, ms */ 40 #define MSGS 5 /* # of timestamp replies to average */ 41 #define TRIALS 10 /* max # of timestamp echos sent */ 42 43 #define MINTOUT 360 44 #define MAXTOUT 900 45 46 #define GOOD 1 47 #define UNREACHABLE 2 48 #define NONSTDTIME 3 49 #define HOSTDOWN 0x7fffffff 50 51 #define OFF 0 52 #define ON 1 53 54 /* 55 * Global and per-network states. 56 */ 57 #define NOMASTER 0 /* no master on any network */ 58 #define SLAVE 1 59 #define MASTER 2 60 #define IGNORE 4 61 #define ALL (SLAVE|MASTER|IGNORE) 62 #define SUBMASTER (SLAVE|MASTER) 63 64 #define NHOSTS 100 /* max number of hosts controlled by timed */ 65 66 struct host { 67 char *name; 68 struct sockaddr_in addr; 69 long delta; 70 u_short seq; 71 }; 72 73 struct netinfo { 74 struct netinfo *next; 75 u_long net; 76 u_long mask; 77 struct in_addr my_addr; 78 struct sockaddr_in dest_addr; /* broadcast addr or point-point */ 79 long status; 80 }; 81 82 extern struct netinfo *nettab; 83 extern int status; 84 extern int trace; 85 extern int sock; 86 extern struct sockaddr_in from; 87 extern struct netinfo *fromnet, *slavenet; 88 extern FILE *fd; 89 extern char hostname[]; 90 extern char tracefile[]; 91 extern struct host hp[]; 92 extern int backoff; 93 extern long delay1, delay2; 94 extern int slvcount; 95 extern int nslavenets; /* Number of nets were I could be a slave */ 96 extern int nmasternets; /* Number of nets were I could be a master */ 97 extern int nignorednets; /* Number of ignored nets */ 98 extern int nnets; /* Number of nets I am connected to */ 99 100 char *strcpy(), *malloc(); 101