1 /* 2 * ntp_stdlib.h - Prototypes for NTP lib. 3 */ 4 #include <sys/types.h> 5 6 #include "ntp_types.h" 7 #include "ntp_string.h" 8 #include "l_stdlib.h" 9 10 /* 11 * Handle gcc __attribute__ if available. 12 */ 13 #ifndef __attribute__ 14 /* This feature is available in gcc versions 2.5 and later. */ 15 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (defined(__STRICT_ANSI__)) 16 # define __attribute__(Spec) /* empty */ 17 # endif 18 /* The __-protected variants of `format' and `printf' attributes 19 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ 20 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 21 # define __format__ format 22 # define __printf__ printf 23 # endif 24 #endif 25 26 #if defined(__STDC__) || defined(HAVE_STDARG_H) 27 # include <stdarg.h> 28 extern void msyslog P((int, const char *, ...)) 29 __attribute__((__format__(__printf__, 2, 3))); 30 #else 31 # include <varargs.h> 32 extern void msyslog P(()); 33 #endif 34 35 #if 0 /* HMS: These seem to be unused now */ 36 extern void auth_des P((u_long *, u_char *)); 37 extern void auth_delkeys P((void)); 38 extern int auth_parity P((u_long *)); 39 extern void auth_setkey P((u_long, u_long *)); 40 extern void auth_subkeys P((u_long *, u_char *, u_char *)); 41 #endif 42 43 extern void auth1crypt P((u_long, u_int32 *, int)); 44 extern int auth2crypt P((u_long, u_int32 *, int)); 45 extern void auth_delkeys P((void)); 46 extern int auth_havekey P((u_long)); 47 extern int authdecrypt P((u_long, u_int32 *, int, int)); 48 extern int authencrypt P((u_long, u_int32 *, int)); 49 extern int authhavekey P((u_long)); 50 extern int authistrusted P((u_long)); 51 extern int authreadkeys P((const char *)); 52 extern void authtrust P((u_long, int)); 53 extern int authusekey P((u_long, int, const u_char *)); 54 55 extern u_long calleapwhen P((u_long)); 56 extern u_long calyearstart P((u_long)); 57 extern const char *clockname P((int)); 58 extern int clocktime P((int, int, int, int, int, u_long, u_long *, u_int32 *)); 59 #if defined SYS_WINNT && defined DEBUG 60 # define emalloc(_c) debug_emalloc(_c, __FILE__, __LINE__) 61 extern void * debug_emalloc P((u_int, char *, int)); 62 #else 63 extern void * emalloc P((u_int)); 64 #endif 65 extern int ntp_getopt P((int, char **, const char *)); 66 extern void init_auth P((void)); 67 extern void init_lib P((void)); 68 extern void init_random P((void)); 69 extern struct savekey *auth_findkey P((u_long)); 70 extern int auth_moremem P((void)); 71 extern int ymd2yd P((int, int, int)); 72 73 #ifdef DES 74 extern int DESauthdecrypt P((u_char *, u_int32 *, int, int)); 75 extern int DESauthencrypt P((u_char *, u_int32 *, int)); 76 extern void DESauth_setkey P((u_long, const u_int32 *)); 77 extern void DESauth_subkeys P((const u_int32 *, u_char *, u_char *)); 78 extern void DESauth_des P((u_int32 *, u_char *)); 79 extern int DESauth_parity P((u_int32 *)); 80 #endif /* DES */ 81 82 #ifdef MD5 83 extern int MD5authdecrypt P((u_char *, u_int32 *, int, int)); 84 extern int MD5authencrypt P((u_char *, u_int32 *, int)); 85 extern void MD5auth_setkey P((u_long, const u_char *, const int)); 86 extern u_long session_key P((u_int32, u_int32, u_long, u_long)); 87 #endif /* MD5 */ 88 89 extern int atoint P((const char *, long *)); 90 extern int atouint P((const char *, u_long *)); 91 extern int hextoint P((const char *, u_long *)); 92 extern char * humandate P((u_long)); 93 extern char * humanlogtime P((void)); 94 extern char * inttoa P((long)); 95 extern char * mfptoa P((u_long, u_long, int)); 96 extern char * mfptoms P((u_long, u_long, int)); 97 extern const char * modetoa P((int)); 98 extern const char * eventstr P((int)); 99 extern const char * ceventstr P((int)); 100 extern char * statustoa P((int, int)); 101 extern const char * sysstatstr P((int)); 102 extern const char * peerstatstr P((int)); 103 extern const char * clockstatstr P((int)); 104 extern u_int32 netof P((u_int32)); 105 extern char * numtoa P((u_int32)); 106 extern char * numtohost P((u_int32)); 107 extern int octtoint P((const char *, u_long *)); 108 extern u_long ranp2 P((int)); 109 extern char * refnumtoa P((u_int32)); 110 extern int tsftomsu P((u_long, int)); 111 extern char * uinttoa P((u_long)); 112 113 extern int decodenetnum P((const char *, u_int32 *)); 114 115 extern const char * FindConfig P((const char *)); 116 117 extern void signal_no_reset P((int, RETSIGTYPE (*func)(int))); 118 119 extern void getauthkeys P((char *)); 120 extern void auth_agekeys P((void)); 121 extern void rereadkeys P((void)); 122 123 /* 124 * Variable declarations for libntp. 125 */ 126 127 /* 128 * Defined by any program. 129 */ 130 extern volatile int debug; /* debugging flag */ 131 132 /* authkeys.c */ 133 extern u_long authkeynotfound; /* keys not found */ 134 extern u_long authkeylookups; /* calls to lookup keys */ 135 extern u_long authnumkeys; /* number of active keys */ 136 extern u_long authkeyexpired; /* key lifetime expirations */ 137 extern u_long authkeyuncached; /* cache misses */ 138 extern u_long authencryptions; /* calls to encrypt */ 139 extern u_long authdecryptions; /* calls to decrypt */ 140 141 extern int authnumfreekeys; 142 143 /* 144 * The key cache. We cache the last key we looked at here. 145 */ 146 extern u_long cache_keyid; /* key identifier */ 147 extern u_char * cache_key; /* key pointer */ 148 extern u_int cache_keylen; /* key length */ 149 150 /* clocktypes.c */ 151 struct clktype; 152 extern struct clktype clktypes[]; 153 154 /* getopt.c */ 155 extern char * ntp_optarg; /* global argument pointer */ 156 extern int ntp_optind; /* global argv index */ 157 158 /* machines.c */ 159 extern const char *set_tod_using; 160 161 /* mexit.c */ 162 #if defined SYS_WINNT || defined SYS_CYGWIN32 163 extern HANDLE hServDoneEvent; 164 #endif 165 166 /* systime.c */ 167 extern int systime_10ms_ticks; /* adj sysclock in 10ms increments */ 168 169 extern double sys_maxfreq; /* max frequency correction */ 170 171 /* version.c */ 172 extern const char *Version; /* version declaration */ 173