diff options
author | wollman <wollman@FreeBSD.org> | 1994-02-03 22:09:07 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1994-02-03 22:09:07 +0000 |
commit | 394ee3bae890775188c4812249fc996cb7cc0abe (patch) | |
tree | 6264e1a9edb32ef88fffee8f460175549f1b556f /usr.sbin/xntpd/lib | |
parent | 8e51e9f1429efc498f923bce8b25b20f47d7c075 (diff) | |
download | FreeBSD-src-394ee3bae890775188c4812249fc996cb7cc0abe.zip FreeBSD-src-394ee3bae890775188c4812249fc996cb7cc0abe.tar.gz |
xntpd version 3.3z from UDel
Diffstat (limited to 'usr.sbin/xntpd/lib')
-rw-r--r-- | usr.sbin/xntpd/lib/a_md512crypt.c | 7 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/a_md5decrypt.c | 4 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/a_md5encrypt.c | 6 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/authdes.c | 46 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/authdes.c.export | 1 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/authkeys.c | 2 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/authusekey.c | 2 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/clocktypes.c | 1 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/dofptoa.c | 2 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/dolfptoa.c | 2 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/getopt.c | 89 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/machines.c | 117 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/msyslog.c | 3 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/numtohost.c | 2 | ||||
-rw-r--r-- | usr.sbin/xntpd/lib/systime.c | 48 |
15 files changed, 111 insertions, 221 deletions
diff --git a/usr.sbin/xntpd/lib/a_md512crypt.c b/usr.sbin/xntpd/lib/a_md512crypt.c index a3714a2..6033ded 100644 --- a/usr.sbin/xntpd/lib/a_md512crypt.c +++ b/usr.sbin/xntpd/lib/a_md512crypt.c @@ -80,7 +80,8 @@ MD5auth2crypt(keyno, pkt, length) MD5Update(&ctx, (char *)(pkt) + length - 8, 8); MD5Final(&ctx); - bcopy((char *)ctx.digest, (char *) &pkt[NOCRYPT_LONGS + length/sizeof(U_LONG)], - BLOCK_OCTETS); - return 4 + BLOCK_OCTETS; + memmove((char *) &pkt[NOCRYPT_LONGS + length/sizeof(U_LONG)], + (char *) ctx.digest, + BLOCK_OCTETS); + return (4 + BLOCK_OCTETS); } diff --git a/usr.sbin/xntpd/lib/a_md5decrypt.c b/usr.sbin/xntpd/lib/a_md5decrypt.c index 892e52e..dc7acf6 100644 --- a/usr.sbin/xntpd/lib/a_md5decrypt.c +++ b/usr.sbin/xntpd/lib/a_md5decrypt.c @@ -54,5 +54,7 @@ MD5authdecrypt(keyno, pkt, length) MD5Update(&ctx, (char *)pkt, length); MD5Final(&ctx); - return (0 == bcmp((char *)ctx.digest, (char *)pkt + length + 4, BLOCK_OCTETS)); + return (!memcmp((char *)ctx.digest, + (char *)pkt + length + 4, + BLOCK_OCTETS)); } diff --git a/usr.sbin/xntpd/lib/a_md5encrypt.c b/usr.sbin/xntpd/lib/a_md5encrypt.c index a26e8f0..2ae6258 100644 --- a/usr.sbin/xntpd/lib/a_md5encrypt.c +++ b/usr.sbin/xntpd/lib/a_md5encrypt.c @@ -63,6 +63,8 @@ MD5authencrypt(keyno, pkt, length) MD5Update(&ctx, (char *)pkt, length); MD5Final(&ctx); - bcopy((char *)ctx.digest, (char *) &pkt[NOCRYPT_LONGS + len], BLOCK_OCTETS); - return 4 + BLOCK_OCTETS; /* return size of key and MAC */ + memmove((char *)&pkt[NOCRYPT_LONGS + len], + (char *)ctx.digest, + BLOCK_OCTETS); + return (4 + BLOCK_OCTETS); /* return size of key and MAC */ } diff --git a/usr.sbin/xntpd/lib/authdes.c b/usr.sbin/xntpd/lib/authdes.c index 36077fc..9f64c40 100644 --- a/usr.sbin/xntpd/lib/authdes.c +++ b/usr.sbin/xntpd/lib/authdes.c @@ -3,30 +3,6 @@ */ #include "ntp_stdlib.h" -#if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN) - -#if defined(XNTP_AUTO_ENDIAN) -#include <netinet/in.h> - -#if BYTE_ORDER == BIG_ENDIAN -#define XNTP_BIG_ENDIAN -#endif -#if BYTE_ORDER == LITTLE_ENDIAN -#define XNTP_LITTLE_ENDIAN -#endif - -#else /* AUTO */ - -#ifdef WORDS_BIGENDIAN -#define XNTP_BIG_ENDIAN 1 -#else -#define XNTP_LITTLE_ENDIAN 1 -#endif - -#endif /* AUTO */ - -#endif /* !BIG && !LITTLE */ - /* * There are two entries in here. auth_subkeys() called to * compute the encryption and decryption key schedules, while @@ -34,28 +10,6 @@ */ /* - * Byte order woes. The DES code is sensitive to byte order. This - * used to be resolved by calling ntohl() and htonl() to swap things - * around, but this turned out to be quite costly on Vaxes where those - * things are actual functions. The code now straightens out byte - * order troubles on its own, with no performance penalty for little - * end first machines, but at great expense to cleanliness. - */ -#if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN) - /* - * Pick one or the other. - */ - BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION -#endif - -#if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN) - /* - * Pick one or the other. - */ - BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION -#endif - -/* * Key setup. Here we entirely permute a key, saving the results * for both the encryption and decryption. Note that while the * decryption subkeys are simply the encryption keys reordered, diff --git a/usr.sbin/xntpd/lib/authdes.c.export b/usr.sbin/xntpd/lib/authdes.c.export index b0323a0..a63c6d3 100644 --- a/usr.sbin/xntpd/lib/authdes.c.export +++ b/usr.sbin/xntpd/lib/authdes.c.export @@ -15,6 +15,7 @@ * to its exportable state, copy this file to authdes.c . */ #include <sys/types.h> +#include "ntp_stdlib.h" /* * This routine is normally called to compute the key schedule. diff --git a/usr.sbin/xntpd/lib/authkeys.c b/usr.sbin/xntpd/lib/authkeys.c index 2d46eee..743af83 100644 --- a/usr.sbin/xntpd/lib/authkeys.c +++ b/usr.sbin/xntpd/lib/authkeys.c @@ -109,7 +109,7 @@ init_auth() /* * Initialize hash table and free list */ - bzero((char *)key_hash, sizeof key_hash); + memset((char *)key_hash, 0, sizeof key_hash); cache_flags = cache_keyid = 0; authnumfreekeys = authkeynotfound = authkeylookups = 0; diff --git a/usr.sbin/xntpd/lib/authusekey.c b/usr.sbin/xntpd/lib/authusekey.c index 0452031..c268c4d 100644 --- a/usr.sbin/xntpd/lib/authusekey.c +++ b/usr.sbin/xntpd/lib/authusekey.c @@ -96,7 +96,7 @@ authusekey(keyno, keytype, str) /* * Make up key from ascii representation */ - bzero((char *) keybytes, sizeof(keybytes)); + memset((char *) keybytes, 0, sizeof(keybytes)); for (i = 0; i < 8 && i < len; i++) keybytes[i] = *cp++ << 1; key[0] = (U_LONG)keybytes[0] << 24 | (U_LONG)keybytes[1] << 16 diff --git a/usr.sbin/xntpd/lib/clocktypes.c b/usr.sbin/xntpd/lib/clocktypes.c index f6fc003..2701e3f 100644 --- a/usr.sbin/xntpd/lib/clocktypes.c +++ b/usr.sbin/xntpd/lib/clocktypes.c @@ -24,6 +24,7 @@ struct clktype clktypes[] = { { REFCLK_IRIG_TPRO, "Odetics/KSI TPRO IRIG decoder (12)", "IRIG_TPRO" }, { REFCLK_ATOM_LEITCH, "Leitch CSD 5300 controller (13)", "ATOM_LEITCH" }, { REFCLK_MSF_EES, "MSF EES M201, UK (14)", "MSF_EES" }, + { REFCLK_GPSTM_TRUETIME, "TrueTime GPS/TM-TMD clock (15)", "GPS_TRUE" }, { -1, "", "" } }; diff --git a/usr.sbin/xntpd/lib/dofptoa.c b/usr.sbin/xntpd/lib/dofptoa.c index c6e317f..a496df8 100644 --- a/usr.sbin/xntpd/lib/dofptoa.c +++ b/usr.sbin/xntpd/lib/dofptoa.c @@ -31,7 +31,7 @@ dofptoa(fpv, neg, ndec, msec) /* * Zero out the buffer */ - bzero((char *)cbuf, sizeof cbuf); + memset((char *)cbuf, 0, sizeof cbuf); /* * Set the pointers to point at the first diff --git a/usr.sbin/xntpd/lib/dolfptoa.c b/usr.sbin/xntpd/lib/dolfptoa.c index ff34153..ff37c9f 100644 --- a/usr.sbin/xntpd/lib/dolfptoa.c +++ b/usr.sbin/xntpd/lib/dolfptoa.c @@ -32,7 +32,7 @@ dolfptoa(fpi, fpv, neg, ndec, msec) /* * Zero the character buffer */ - bzero((char *) cbuf, sizeof(cbuf)); + memset((char *) cbuf, 0, sizeof(cbuf)); /* * Work on the integral part. This is biased by what I know diff --git a/usr.sbin/xntpd/lib/getopt.c b/usr.sbin/xntpd/lib/getopt.c index 0ab3c29..5519235 100644 --- a/usr.sbin/xntpd/lib/getopt.c +++ b/usr.sbin/xntpd/lib/getopt.c @@ -4,7 +4,9 @@ * This is a version of the public domain getopt() implementation by * Henry Spencer, changed for 4.3BSD compatibility (in addition to System V). * It allows rescanning of an option list by setting optind to 0 before - * calling. Thanks to Dennis Ferguson for the appropriate modifications. + * calling, which is why we use it even if the system has its own (in fact, + * this one has a unique name so as not to conflict with the system's). + * Thanks to Dennis Ferguson for the appropriate modifications. * * This file is in the Public Domain. */ @@ -20,39 +22,33 @@ #define putc fputc #endif /* lint */ -char *optarg; /* Global argument pointer. */ -#ifndef __convex__ -int optind = 0; /* Global argv index. */ -#else /* __convex__ */ -extern int optind; /* Global argv index. */ -#endif /* __convex__ */ - -/* - * N.B. use following at own risk - */ -#ifndef __convex__ -int opterr = 1; /* for compatibility, should error be printed? */ -#else /* __convex__ */ -extern int opterr; /* for compatibility, should error be printed? */ -#endif /* __convex__ */ -int optopt; /* for compatibility, option character checked */ +char *ntp_optarg; /* Global argument pointer. */ +int ntp_optind = 0; /* Global argv index. */ +int ntp_opterr = 1; /* for compatibility, should error be printed? */ +int ntp_optopt; /* for compatibility, option character checked */ static char *scan = NULL; /* Private scan pointer. */ +static char *prog = "amnesia"; /* - * Print message about a bad option. Watch this definition, it's - * not a single statement. + * Print message about a bad option. */ -#define BADOPT(mess, ch) if (opterr) { \ - fputs(argv[0], stderr); \ - fputs(mess, stderr); \ - (void) putc(ch, stderr); \ - (void) putc('\n', stderr); \ - } \ - return('?') +static int +badopt(mess, ch) + char *mess; + int ch; +{ + if (ntp_opterr) { + fputs(prog, stderr); + fputs(mess, stderr); + (void) putc(ch, stderr); + (void) putc('\n', stderr); + } + return ('?'); +} int -getopt_l(argc, argv, optstring) +ntp_getopt(argc, argv, optstring) int argc; char *argv[]; char *optstring; @@ -60,47 +56,50 @@ getopt_l(argc, argv, optstring) register char c; register char *place; - optarg = NULL; + prog = argv[0]; + ntp_optarg = NULL; - if (optind == 0) { + if (ntp_optind == 0) { scan = NULL; - optind++; + ntp_optind++; } if (scan == NULL || *scan == '\0') { - if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0') - return EOF; - if (argv[optind][1] == '-' && argv[optind][2] == '\0') { - optind++; - return EOF; + if (ntp_optind >= argc + || argv[ntp_optind][0] != '-' + || argv[ntp_optind][1] == '\0') { + return (EOF); + } + if (argv[ntp_optind][1] == '-' + && argv[ntp_optind][2] == '\0') { + ntp_optind++; + return (EOF); } - scan = argv[optind]+1; - optind++; + scan = argv[ntp_optind++]+1; } c = *scan++; - optopt = c & 0377; + ntp_optopt = c & 0377; for (place = optstring; place != NULL && *place != '\0'; ++place) if (*place == c) break; if (place == NULL || *place == '\0' || c == ':' || c == '?') { - BADOPT(": unknown option -", c); + return (badopt(": unknown option -", c)); } place++; if (*place == ':') { if (*scan != '\0') { - optarg = scan; + ntp_optarg = scan; scan = NULL; - } else if (optind >= argc) { - BADOPT(": option requires argument -", c); + } else if (ntp_optind >= argc) { + return (badopt(": option requires argument -", c)); } else { - optarg = argv[optind]; - optind++; + ntp_optarg = argv[ntp_optind++]; } } - return c&0377; + return (c & 0377); } diff --git a/usr.sbin/xntpd/lib/machines.c b/usr.sbin/xntpd/lib/machines.c index f7a400c..5e01694 100644 --- a/usr.sbin/xntpd/lib/machines.c +++ b/usr.sbin/xntpd/lib/machines.c @@ -1,118 +1,43 @@ -/* - * provide special support for peculiar architectures +/* machines.c - provide special support for peculiar architectures * * Real bummers unite ! + * + * $Id:$ */ +#include "ntp_stdlib.h" + #ifdef SYS_PTX #include <sys/types.h> #include <sys/procstats.h> -int settimeofday(tvp) + +int +settimeofday(tvp) struct timeval *tvp; { - return stime(&tvp->tv_sec); /* lie as bad as SysVR4 */ + return (stime(&tvp->tv_sec)); /* lie as bad as SysVR4 */ } -int gettimeofday(tvp) +int +gettimeofday(tvp) struct timeval *tvp; { /* * hi, this is Sequents sneak path to get to a clock * this is also the most logical syscall for such a function */ - return get_process_stats(tvp, PS_SELF, (struct procstats *) 0, - (struct procstats *) 0); + return (get_process_stats(tvp, PS_SELF, (struct procstats *) 0, + (struct procstats *) 0)); } #endif -#ifdef SYS_HPUX -/* hpux.c,v 3.1 1993/07/06 01:08:23 jbj Exp - * hpux.c -- compatibility routines for HP-UX. - * XXX many of these are not needed anymore. - */ -#include "ntp_machine.h" - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <stdio.h> - -#include "ntp_stdlib.h" - -#if (SYS_HPUX < 8) -char -*index(s, c) -register char *s; -register int c; +#if !defined(NTP_POSIX_SOURCE) || defined(NTP_NEED_BOPS) +void +ntp_memset(a, x, c) + char *a; + int x, c; { - return strchr (s, c); + while (c-- > 0) + *a++ = x; } - - -char -*rindex(s, c) -register char *s; -register int c; -{ - return strrchr (s, c); -} - - -int -bcmp(a, b, count) -register char *a, *b; -register int count; -{ - return memcmp (a, b, count); -} - - -void -bcopy(from, to, count) -register char *from; -register char *to; -register int count; -{ - if ((to == from) || (count <= 0)) - return; - - if ((to > from) && (to <= (from + count))) { - to += count; - from += count; - - do { - *--to = *--from; - } while (--count); - } - else { - do { - *to++ = *from++; - } while (--count); - } -} - - -void -bzero(area, count) -register char *area; -register int count; -{ - memset(area, 0, count); -} -#endif - - -getdtablesize() -{ - return(sysconf(_SC_OPEN_MAX)); -} - - -int -setlinebuf(a_stream) - FILE *a_stream; -{ - return setvbuf(a_stream, (char *) NULL, _IOLBF, 0); -} - -#endif +#endif /*POSIX*/ diff --git a/usr.sbin/xntpd/lib/msyslog.c b/usr.sbin/xntpd/lib/msyslog.c index a8df27d..a6186b7 100644 --- a/usr.sbin/xntpd/lib/msyslog.c +++ b/usr.sbin/xntpd/lib/msyslog.c @@ -81,7 +81,8 @@ void msyslog(va_alist) n += strlen(err); } } - *n++ = '\n'; + if (!syslogit) + *n++ = '\n'; *n = '\0'; vsprintf(buf, nfmt, ap); diff --git a/usr.sbin/xntpd/lib/numtohost.c b/usr.sbin/xntpd/lib/numtohost.c index c8b532f..e22b623 100644 --- a/usr.sbin/xntpd/lib/numtohost.c +++ b/usr.sbin/xntpd/lib/numtohost.c @@ -1,7 +1,7 @@ /* numtohost.c,v 3.1 1993/07/06 01:08:40 jbj Exp * numtohost - convert network number to host name. */ -#include <string.h> +#include "ntp_types.h" #include <netdb.h> #include "ntp_fp.h" diff --git a/usr.sbin/xntpd/lib/systime.c b/usr.sbin/xntpd/lib/systime.c index 99e715a..ea15734 100644 --- a/usr.sbin/xntpd/lib/systime.c +++ b/usr.sbin/xntpd/lib/systime.c @@ -3,7 +3,7 @@ */ #include <sys/types.h> #include <sys/time.h> -#if defined(SYS_HPUX) || defined(sgi) || defined(__bsdi__) +#if defined(SYS_HPUX) || defined(sgi) || defined(SYS_BSDI) #include <sys/param.h> #include <utmp.h> #endif @@ -238,36 +238,40 @@ adj_systime(ts) #endif } - sys_clock_offset.l_ui = offset_i; - sys_clock_offset.l_uf = offset_f; - if (adjtime(&adjtv, &oadjtv) < 0) { syslog(LOG_ERR, "Can't do time adjustment: %m"); rval = 0; - } else + } else { + sys_clock_offset.l_ui = offset_i; + sys_clock_offset.l_uf = offset_f; rval = 1; #ifdef DEBUGRS6000 - syslog(LOG_ERR, "adj_systime(%s): offset = %s%s\n", - mfptoa((adj<0?-1:0), adj, 9), isneg?"-":"", - umfptoa(offset_i, offset_f, 9)); - syslog(LOG_ERR, "%d %d %d %d\n", (int) adjtv.tv_sec, - (int) adjtv.tv_usec, (int) oadjtv.tv_sec, (int) - oadjtv.tv_usec); + syslog(LOG_ERR, "adj_systime(%s): offset = %s%s\n", + mfptoa((adj<0?-1:0), adj, 9), isneg?"-":"", + umfptoa(offset_i, offset_f, 9)); + syslog(LOG_ERR, "%d %d %d %d\n", (int) adjtv.tv_sec, + (int) adjtv.tv_usec, (int) oadjtv.tv_sec, (int) + oadjtv.tv_usec); #endif /* DEBUGRS6000 */ - if ((oadjtv.tv_sec != 0 || oadjtv.tv_usec != 0) && (max_no_complete > 0)) { - sTVTOTS(&oadjtv, &oadjts); - L_ADD(&sys_clock_offset, &oadjts); - syslog(LOG_WARNING, "Previous time adjustment didn't complete"); + if (oadjtv.tv_sec != 0 || oadjtv.tv_usec != 0) { + sTVTOTS(&oadjtv, &oadjts); + L_ADD(&sys_clock_offset, &oadjts); + if (max_no_complete > 0) { + syslog(LOG_WARNING, + "Previous time adjustment didn't complete"); #ifdef DEBUG - if (debug > 4) - syslog(LOG_DEBUG, - "Previous adjtime() incomplete, residual = %s\n", - tvtoa(&oadjtv)); + if (debug > 4) + syslog(LOG_DEBUG, + "Previous adjtime() incomplete, residual = %s\n", + tvtoa(&oadjtv)); #endif - if (--max_no_complete == 0) syslog(LOG_WARNING, - "*** No more 'Prev time adj didn't complete'"); + if (--max_no_complete == 0) + syslog(LOG_WARNING, + "*** No more 'Prev time adj didn't complete'"); + } + } } return(rval); } @@ -345,7 +349,7 @@ step_systime_real(ts) * is greater than one second. */ if (oldtime != timetv.tv_sec) { - bzero((char *)&ut, sizeof(ut)); + memset((char *)&ut, 0, sizeof(ut)); ut.ut_type = OLD_TIME; ut.ut_time = oldtime; (void)strcpy(ut.ut_line, OTIME_MSG); |