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