freebsd-skq/ntpd/ntp_util.c

802 lines
17 KiB
C
Raw Normal View History

1999-12-09 13:01:21 +00:00
/*
* ntp_util.c - stuff I didn't have any other place for
*/
2001-08-29 14:35:15 +00:00
1999-12-09 13:01:21 +00:00
#ifdef HAVE_CONFIG_H
2001-08-29 14:35:15 +00:00
# include <config.h>
1999-12-09 13:01:21 +00:00
#endif
#include "ntpd.h"
#include "ntp_io.h"
#include "ntp_unixtime.h"
#include "ntp_filegen.h"
#include "ntp_if.h"
#include "ntp_stdlib.h"
2001-08-29 14:35:15 +00:00
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_IEEEFP_H
# include <ieeefp.h>
#endif
#ifdef HAVE_MATH_H
# include <math.h>
#endif
1999-12-09 13:01:21 +00:00
#ifdef DOSYNCTODR
# if !defined(VMS)
# include <sys/resource.h>
# endif /* VMS */
1999-12-09 13:01:21 +00:00
#endif
#if defined(VMS)
# include <descrip.h>
1999-12-09 13:01:21 +00:00
#endif /* VMS */
/*
* This contains odds and ends. Right now the only thing you'll find
2004-07-20 15:01:56 +00:00
* in here is the hourly stats printer and some code to support
* rereading the keys file, but I may eventually put other things in
* here such as code to do something with the leap bits.
1999-12-09 13:01:21 +00:00
*/
/*
* Name of the keys file
*/
static char *key_file_name;
/*
* The name of the drift_comp file and the temporary.
*/
static char *stats_drift_file;
static char *stats_temp_file;
int stats_write_period = 3600; /* # of seconds between writes. */
double stats_write_tolerance = 0;
static double prev_drift_comp = 99999.;
1999-12-09 13:01:21 +00:00
/*
* Statistics file stuff
*/
#ifndef NTP_VAR
# ifndef SYS_WINNT
# define NTP_VAR "/var/NTP/" /* NOTE the trailing '/' */
# else
# define NTP_VAR "c:\\var\\ntp\\" /* NOTE the trailing '\\' */
# endif /* SYS_WINNT */
1999-12-09 13:01:21 +00:00
#endif
#ifndef MAXPATHLEN
# define MAXPATHLEN 256
1999-12-09 13:01:21 +00:00
#endif
static char statsdir[MAXPATHLEN] = NTP_VAR;
static FILEGEN peerstats;
static FILEGEN loopstats;
static FILEGEN clockstats;
static FILEGEN rawstats;
2004-07-20 15:01:56 +00:00
static FILEGEN sysstats;
#ifdef DEBUG_TIMING
static FILEGEN timingstats;
#endif
2004-07-20 15:01:56 +00:00
#ifdef OPENSSL
static FILEGEN cryptostats;
#endif /* OPENSSL */
1999-12-09 13:01:21 +00:00
/*
* This controls whether stats are written to the fileset. Provided
* so that ntpdc can turn off stats when the file system fills up.
*/
int stats_control;
/*
* Initial frequency offset later passed to the loopfilter.
*/
double old_drift;
1999-12-09 13:01:21 +00:00
/*
* init_util - initialize the utilities
*/
void
init_util(void)
{
stats_drift_file = 0;
stats_temp_file = 0;
key_file_name = 0;
filegen_register(&statsdir[0], "peerstats", &peerstats);
2004-07-20 15:01:56 +00:00
filegen_register(&statsdir[0], "loopstats", &loopstats);
2004-07-20 15:01:56 +00:00
filegen_register(&statsdir[0], "clockstats", &clockstats);
filegen_register(&statsdir[0], "rawstats", &rawstats);
filegen_register(&statsdir[0], "sysstats", &sysstats);
2004-07-20 15:01:56 +00:00
#ifdef OPENSSL
filegen_register(&statsdir[0], "cryptostats", &cryptostats);
2004-07-20 15:01:56 +00:00
#endif /* OPENSSL */
#ifdef DEBUG_TIMING
filegen_register(&statsdir[0], "timingstats", &timingstats);
#endif
1999-12-09 13:01:21 +00:00
}
/*
* hourly_stats - print some interesting stats
*/
void
write_stats(void)
1999-12-09 13:01:21 +00:00
{
FILE *fp;
#ifdef DOSYNCTODR
struct timeval tv;
#if !defined(VMS)
int prio_set;
#endif
#ifdef HAVE_GETCLOCK
struct timespec ts;
#endif
int o_prio;
/*
* Sometimes having a Sun can be a drag.
*
* The kernel variable dosynctodr controls whether the system's
* soft clock is kept in sync with the battery clock. If it
* is zero, then the soft clock is not synced, and the battery
* clock is simply left to rot. That means that when the system
* reboots, the battery clock (which has probably gone wacky)
* sets the soft clock. That means ntpd starts off with a very
* confused idea of what time it is. It then takes a large
* amount of time to figure out just how wacky the battery clock
* has made things drift, etc, etc. The solution is to make the
* battery clock sync up to system time. The way to do THAT is
* to simply set the time of day to the current time of day, but
* as quickly as possible. This may, or may not be a sensible
* thing to do.
*
* CAVEAT: settimeofday() steps the sun clock by about 800 us,
* so setting DOSYNCTODR seems a bad idea in the
* case of us resolution
*/
#if !defined(VMS)
/* (prr) getpriority returns -1 on error, but -1 is also a valid
2004-07-20 15:01:56 +00:00
* return value (!), so instead we have to zero errno before the
* call and check it for non-zero afterwards.
1999-12-09 13:01:21 +00:00
*/
errno = 0;
prio_set = 0;
o_prio = getpriority(PRIO_PROCESS,0); /* Save setting */
2004-07-20 15:01:56 +00:00
/*
* (prr) if getpriority succeeded, call setpriority to raise
1999-12-09 13:01:21 +00:00
* scheduling priority as high as possible. If that succeeds
* as well, set the prio_set flag so we remember to reset
2004-07-20 15:01:56 +00:00
* priority to its previous value below. Note that on Solaris
* 2.6 (and beyond?), both getpriority and setpriority will fail
* with ESRCH, because sched_setscheduler (called from main) put
* us in the real-time scheduling class which setpriority
* doesn't know about. Being in the real-time class is better
* than anything setpriority can do, anyhow, so this error is
* silently ignored.
1999-12-09 13:01:21 +00:00
*/
if ((errno == 0) && (setpriority(PRIO_PROCESS,0,-20) == 0))
2004-07-20 15:01:56 +00:00
prio_set = 1; /* overdrive */
1999-12-09 13:01:21 +00:00
#endif /* VMS */
#ifdef HAVE_GETCLOCK
(void) getclock(TIMEOFDAY, &ts);
tv.tv_sec = ts.tv_sec;
tv.tv_usec = ts.tv_nsec / 1000;
#else /* not HAVE_GETCLOCK */
GETTIMEOFDAY(&tv,(struct timezone *)NULL);
#endif /* not HAVE_GETCLOCK */
2004-07-20 15:01:56 +00:00
if (ntp_set_tod(&tv,(struct timezone *)NULL) != 0) {
1999-12-09 13:01:21 +00:00
msyslog(LOG_ERR, "can't sync battery time: %m");
}
#if !defined(VMS)
if (prio_set)
2004-07-20 15:01:56 +00:00
setpriority(PRIO_PROCESS, 0, o_prio); /* downshift */
1999-12-09 13:01:21 +00:00
#endif /* VMS */
#endif /* DOSYNCTODR */
NLOG(NLOG_SYSSTATIST)
msyslog(LOG_INFO,
"offset %.6f sec freq %.3f ppm error %.6f poll %d",
2004-07-20 15:01:56 +00:00
last_offset, drift_comp * 1e6, sys_jitter,
sys_poll);
2001-08-29 14:35:15 +00:00
1999-12-09 13:01:21 +00:00
2004-07-20 15:01:56 +00:00
record_sys_stats();
if ((u_long)(fabs(prev_drift_comp - drift_comp) * 1e9) <=
(u_long)(fabs(stats_write_tolerance * drift_comp) * 1e9)) {
return;
}
prev_drift_comp = drift_comp;
1999-12-09 13:01:21 +00:00
if (stats_drift_file != 0) {
if ((fp = fopen(stats_temp_file, "w")) == NULL) {
msyslog(LOG_ERR, "can't open %s: %m",
stats_temp_file);
return;
}
fprintf(fp, "%.3f\n", drift_comp * 1e6);
(void)fclose(fp);
/* atomic */
#ifdef SYS_WINNT
2004-07-20 15:01:56 +00:00
(void) _unlink(stats_drift_file); /* rename semantics differ under NT */
1999-12-09 13:01:21 +00:00
#endif /* SYS_WINNT */
#ifndef NO_RENAME
(void) rename(stats_temp_file, stats_drift_file);
#else
/* we have no rename NFS of ftp in use */
1999-12-09 13:01:21 +00:00
if ((fp = fopen(stats_drift_file, "w")) == NULL) {
msyslog(LOG_ERR, "can't open %s: %m",
stats_drift_file);
return;
}
#endif
#if defined(VMS)
/* PURGE */
{
$DESCRIPTOR(oldvers,";-1");
struct dsc$descriptor driftdsc = {
strlen(stats_drift_file),0,0,stats_drift_file };
while(lib$delete_file(&oldvers,&driftdsc) & 1) ;
}
#endif
}
}
/*
* stats_config - configure the stats operation
*/
void
stats_config(
int item,
const char *invalue /* only one type so far */
1999-12-09 13:01:21 +00:00
)
{
FILE *fp;
const char *value;
1999-12-09 13:01:21 +00:00
int len;
2004-07-20 15:01:56 +00:00
/*
* Expand environment strings under Windows NT, since the
* command interpreter doesn't do this, the program must.
1999-12-09 13:01:21 +00:00
*/
#ifdef SYS_WINNT
char newvalue[MAX_PATH], parameter[MAX_PATH];
2004-07-20 15:01:56 +00:00
if (!ExpandEnvironmentStrings(invalue, newvalue, MAX_PATH)) {
1999-12-09 13:01:21 +00:00
switch(item) {
case STATS_FREQ_FILE:
strcpy(parameter,"STATS_FREQ_FILE");
break;
case STATS_STATSDIR:
strcpy(parameter,"STATS_STATSDIR");
break;
case STATS_PID_FILE:
strcpy(parameter,"STATS_PID_FILE");
break;
default:
strcpy(parameter,"UNKNOWN");
break;
}
value = invalue;
msyslog(LOG_ERR,
"ExpandEnvironmentStrings(%s) failed: %m\n", parameter);
2004-07-20 15:01:56 +00:00
} else {
1999-12-09 13:01:21 +00:00
value = newvalue;
2004-07-20 15:01:56 +00:00
}
1999-12-09 13:01:21 +00:00
#else
value = invalue;
#endif /* SYS_WINNT */
switch(item) {
case STATS_FREQ_FILE:
if (stats_drift_file != 0) {
(void) free(stats_drift_file);
(void) free(stats_temp_file);
stats_drift_file = 0;
stats_temp_file = 0;
}
if (value == 0 || (len = strlen(value)) == 0)
break;
stats_drift_file = (char*)emalloc((u_int)(len + 1));
#if !defined(VMS)
2004-07-20 15:01:56 +00:00
stats_temp_file = (char*)emalloc((u_int)(len +
sizeof(".TEMP")));
1999-12-09 13:01:21 +00:00
#else
2004-07-20 15:01:56 +00:00
stats_temp_file = (char*)emalloc((u_int)(len +
sizeof("-TEMP")));
1999-12-09 13:01:21 +00:00
#endif /* VMS */
memmove(stats_drift_file, value, (unsigned)(len+1));
memmove(stats_temp_file, value, (unsigned)len);
#if !defined(VMS)
2004-07-20 15:01:56 +00:00
memmove(stats_temp_file + len, ".TEMP",
sizeof(".TEMP"));
1999-12-09 13:01:21 +00:00
#else
2004-07-20 15:01:56 +00:00
memmove(stats_temp_file + len, "-TEMP",
sizeof("-TEMP"));
1999-12-09 13:01:21 +00:00
#endif /* VMS */
/*
2004-07-20 15:01:56 +00:00
* Open drift file and read frequency. If the file is
* missing or contains errors, tell the loop to reset.
1999-12-09 13:01:21 +00:00
*/
if ((fp = fopen(stats_drift_file, "r")) == NULL) {
old_drift = 1e9;
1999-12-09 13:01:21 +00:00
break;
}
if (fscanf(fp, "%lf", &old_drift) != 1) {
2004-07-20 15:01:56 +00:00
msyslog(LOG_ERR, "Frequency format error in %s",
1999-12-09 13:01:21 +00:00
stats_drift_file);
old_drift = 1e9;
2004-07-20 15:01:56 +00:00
fclose(fp);
1999-12-09 13:01:21 +00:00
break;
}
2004-07-20 15:01:56 +00:00
fclose(fp);
prev_drift_comp = old_drift / 1e6;
2004-07-20 15:01:56 +00:00
msyslog(LOG_INFO,
"frequency initialized %.3f PPM from %s",
old_drift, stats_drift_file);
1999-12-09 13:01:21 +00:00
break;
case STATS_STATSDIR:
if (strlen(value) >= sizeof(statsdir)) {
msyslog(LOG_ERR,
"value for statsdir too long (>%d, sigh)",
(int)sizeof(statsdir)-1);
} else {
l_fp now;
get_systime(&now);
strcpy(statsdir,value);
if(peerstats.prefix == &statsdir[0] &&
peerstats.fp != NULL) {
fclose(peerstats.fp);
peerstats.fp = NULL;
filegen_setup(&peerstats, now.l_ui);
}
if(loopstats.prefix == &statsdir[0] &&
loopstats.fp != NULL) {
fclose(loopstats.fp);
loopstats.fp = NULL;
filegen_setup(&loopstats, now.l_ui);
}
if(clockstats.prefix == &statsdir[0] &&
clockstats.fp != NULL) {
fclose(clockstats.fp);
clockstats.fp = NULL;
filegen_setup(&clockstats, now.l_ui);
}
if(rawstats.prefix == &statsdir[0] &&
rawstats.fp != NULL) {
fclose(rawstats.fp);
rawstats.fp = NULL;
filegen_setup(&rawstats, now.l_ui);
}
2004-07-20 15:01:56 +00:00
if(sysstats.prefix == &statsdir[0] &&
sysstats.fp != NULL) {
fclose(sysstats.fp);
sysstats.fp = NULL;
filegen_setup(&sysstats, now.l_ui);
}
#ifdef OPENSSL
if(cryptostats.prefix == &statsdir[0] &&
cryptostats.fp != NULL) {
fclose(cryptostats.fp);
cryptostats.fp = NULL;
filegen_setup(&cryptostats, now.l_ui);
}
#endif /* OPENSSL */
1999-12-09 13:01:21 +00:00
}
break;
case STATS_PID_FILE:
if ((fp = fopen(value, "w")) == NULL) {
msyslog(LOG_ERR, "Can't open %s: %m", value);
break;
}
fprintf(fp, "%d", (int) getpid());
fclose(fp);;
break;
default:
/* oh well */
break;
}
}
/*
* record_peer_stats - write peer statistics to file
*
* file format:
* day (mjd)
* time (s past UTC midnight)
* peer (ip address)
* peer status word (hex)
* peer offset (s)
* peer delay (s)
* peer error bound (s)
* peer error (s)
*/
void
record_peer_stats(
2004-07-20 15:01:56 +00:00
struct sockaddr_storage *addr,
int status,
double offset,
double delay,
double dispersion,
double skew
1999-12-09 13:01:21 +00:00
)
{
2004-07-20 15:01:56 +00:00
l_fp now;
u_long day;
1999-12-09 13:01:21 +00:00
if (!stats_control)
return;
2004-07-20 15:01:56 +00:00
get_systime(&now);
filegen_setup(&peerstats, now.l_ui);
day = now.l_ui / 86400 + MJD_1900;
now.l_ui %= 86400;
1999-12-09 13:01:21 +00:00
if (peerstats.fp != NULL) {
fprintf(peerstats.fp,
2004-07-20 15:01:56 +00:00
"%lu %s %s %x %.9f %.9f %.9f %.9f\n",
day, ulfptoa(&now, 3), stoa(addr), status, offset,
1999-12-09 13:01:21 +00:00
delay, dispersion, skew);
fflush(peerstats.fp);
}
}
1999-12-09 13:01:21 +00:00
/*
* record_loop_stats - write loop filter statistics to file
*
* file format:
* day (mjd)
* time (s past midnight)
* offset (s)
* frequency (approx ppm)
* time constant (log base 2)
*/
void
2001-08-29 14:35:15 +00:00
record_loop_stats(
2004-07-20 15:01:56 +00:00
double offset,
double freq,
double jitter,
double stability,
int spoll
2001-08-29 14:35:15 +00:00
)
1999-12-09 13:01:21 +00:00
{
2004-07-20 15:01:56 +00:00
l_fp now;
u_long day;
1999-12-09 13:01:21 +00:00
if (!stats_control)
return;
2004-07-20 15:01:56 +00:00
get_systime(&now);
filegen_setup(&loopstats, now.l_ui);
day = now.l_ui / 86400 + MJD_1900;
now.l_ui %= 86400;
1999-12-09 13:01:21 +00:00
if (loopstats.fp != NULL) {
fprintf(loopstats.fp, "%lu %s %.9f %.3f %.9f %.6f %d\n",
2004-07-20 15:01:56 +00:00
day, ulfptoa(&now, 3), offset, freq * 1e6, jitter,
stability * 1e6, spoll);
1999-12-09 13:01:21 +00:00
fflush(loopstats.fp);
}
}
/*
* record_clock_stats - write clock statistics to file
*
* file format:
* day (mjd)
* time (s past midnight)
* peer (ip address)
* text message
*/
void
record_clock_stats(
2004-07-20 15:01:56 +00:00
struct sockaddr_storage *addr,
1999-12-09 13:01:21 +00:00
const char *text
)
{
2004-07-20 15:01:56 +00:00
l_fp now;
u_long day;
1999-12-09 13:01:21 +00:00
if (!stats_control)
return;
2004-07-20 15:01:56 +00:00
get_systime(&now);
filegen_setup(&clockstats, now.l_ui);
day = now.l_ui / 86400 + MJD_1900;
now.l_ui %= 86400;
1999-12-09 13:01:21 +00:00
if (clockstats.fp != NULL) {
2004-07-20 15:01:56 +00:00
fprintf(clockstats.fp, "%lu %s %s %s\n",
day, ulfptoa(&now, 3), stoa(addr), text);
1999-12-09 13:01:21 +00:00
fflush(clockstats.fp);
}
}
/*
* record_raw_stats - write raw timestamps to file
*
*
* file format
* time (s past midnight)
* peer ip address
* local ip address
* t1 t2 t3 t4 timestamps
*/
void
record_raw_stats(
2004-07-20 15:01:56 +00:00
struct sockaddr_storage *srcadr,
struct sockaddr_storage *dstadr,
l_fp *t1,
l_fp *t2,
l_fp *t3,
l_fp *t4
1999-12-09 13:01:21 +00:00
)
{
2004-07-20 15:01:56 +00:00
l_fp now;
u_long day;
1999-12-09 13:01:21 +00:00
if (!stats_control)
return;
2004-07-20 15:01:56 +00:00
get_systime(&now);
filegen_setup(&rawstats, now.l_ui);
day = now.l_ui / 86400 + MJD_1900;
now.l_ui %= 86400;
1999-12-09 13:01:21 +00:00
if (rawstats.fp != NULL) {
2004-07-20 15:01:56 +00:00
fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s\n",
day, ulfptoa(&now, 3), stoa(srcadr), dstadr ? stoa(dstadr) : "-",
ulfptoa(t1, 9), ulfptoa(t2, 9), ulfptoa(t3, 9),
ulfptoa(t4, 9));
1999-12-09 13:01:21 +00:00
fflush(rawstats.fp);
}
}
2004-07-20 15:01:56 +00:00
/*
* record_sys_stats - write system statistics to file
*
* file format
* time (s past midnight)
* time since startup (hr)
* packets recieved
* packets processed
* current version
* previous version
* bad version
* access denied
* bad length or format
* bad authentication
* rate exceeded
*/
void
record_sys_stats(void)
{
l_fp now;
u_long day;
if (!stats_control)
return;
get_systime(&now);
filegen_setup(&sysstats, now.l_ui);
day = now.l_ui / 86400 + MJD_1900;
now.l_ui %= 86400;
if (sysstats.fp != NULL) {
fprintf(sysstats.fp,
"%lu %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
day, ulfptoa(&now, 3), sys_stattime / 3600,
sys_received, sys_processed, sys_newversionpkt,
sys_oldversionpkt, sys_unknownversion,
sys_restricted, sys_badlength, sys_badauth,
sys_limitrejected);
fflush(sysstats.fp);
proto_clr_stats();
}
}
#ifdef OPENSSL
/*
* record_crypto_stats - write crypto statistics to file
*
* file format:
* day (mjd)
* time (s past midnight)
* peer (ip address)
* text message
*/
void
record_crypto_stats(
struct sockaddr_storage *addr,
const char *text
)
{
l_fp now;
u_long day;
if (!stats_control)
return;
get_systime(&now);
filegen_setup(&cryptostats, now.l_ui);
day = now.l_ui / 86400 + MJD_1900;
now.l_ui %= 86400;
if (cryptostats.fp != NULL) {
if (addr == NULL)
fprintf(cryptostats.fp, "%lu %s %s\n",
day, ulfptoa(&now, 3), text);
else
fprintf(cryptostats.fp, "%lu %s %s %s\n",
day, ulfptoa(&now, 3), stoa(addr), text);
fflush(cryptostats.fp);
}
}
#endif /* OPENSSL */
#ifdef DEBUG_TIMING
/*
* record_crypto_stats - write crypto statistics to file
*
* file format:
* day (mjd)
* time (s past midnight)
* text message
*/
void
record_timing_stats(
const char *text
)
{
static unsigned int flshcnt;
l_fp now;
u_long day;
if (!stats_control)
return;
2004-07-20 15:01:56 +00:00
get_systime(&now);
filegen_setup(&timingstats, now.l_ui);
day = now.l_ui / 86400 + MJD_1900;
now.l_ui %= 86400;
if (timingstats.fp != NULL) {
fprintf(timingstats.fp, "%lu %s %s\n",
day, lfptoa(&now, 3), text);
if (++flshcnt % 100 == 0)
fflush(timingstats.fp);
}
}
#endif
1999-12-09 13:01:21 +00:00
/*
* getauthkeys - read the authentication keys from the specified file
*/
void
getauthkeys(
const char *keyfile
1999-12-09 13:01:21 +00:00
)
{
int len;
len = strlen(keyfile);
if (len == 0)
return;
if (key_file_name != 0) {
if (len > (int)strlen(key_file_name)) {
(void) free(key_file_name);
key_file_name = 0;
}
}
if (key_file_name == 0) {
#ifndef SYS_WINNT
key_file_name = (char*)emalloc((u_int) (len + 1));
#else
key_file_name = (char*)emalloc((u_int) (MAXPATHLEN));
#endif
}
#ifndef SYS_WINNT
memmove(key_file_name, keyfile, (unsigned)(len+1));
#else
if (!ExpandEnvironmentStrings(keyfile, key_file_name, MAXPATHLEN))
{
msyslog(LOG_ERR,
"ExpandEnvironmentStrings(KEY_FILE) failed: %m\n");
}
#endif /* SYS_WINNT */
authreadkeys(key_file_name);
}
/*
* rereadkeys - read the authentication key file over again.
*/
void
rereadkeys(void)
{
if (key_file_name != 0)
authreadkeys(key_file_name);
}
2004-07-20 15:01:56 +00:00
/*
* sock_hash - hash an sockaddr_storage structure
*/
int
sock_hash(
struct sockaddr_storage *addr
)
{
int hashVal;
int i;
int len;
char *ch;
hashVal = 0;
len = 0;
/*
* We can't just hash the whole thing because there are hidden
* fields in sockaddr_in6 that might be filled in by recvfrom(),
* so just use the family, port and address.
*/
ch = (char *)&addr->ss_family;
hashVal = 37 * hashVal + (int)*ch;
if (sizeof(addr->ss_family) > 1) {
ch++;
hashVal = 37 * hashVal + (int)*ch;
}
switch(addr->ss_family) {
case AF_INET:
ch = (char *)&((struct sockaddr_in *)addr)->sin_addr;
len = sizeof(struct in_addr);
break;
case AF_INET6:
ch = (char *)&((struct sockaddr_in6 *)addr)->sin6_addr;
len = sizeof(struct in6_addr);
break;
}
for (i = 0; i < len ; i++)
hashVal = 37 * hashVal + (int)*(ch + i);
hashVal = hashVal % 128; /* % MON_HASH_SIZE hardcoded */
if (hashVal < 0)
hashVal += 128;
return hashVal;
}
#if notyet
/*
* ntp_exit - document explicitly that ntpd has exited
*/
void
ntp_exit(int retval)
{
msyslog(LOG_ERR, "EXITING with return code %d", retval);
exit(retval);
}
#endif