003 File Manager
Current Path:
/usr/src/contrib/ntp/ntpd
usr
/
src
/
contrib
/
ntp
/
ntpd
/
📁
..
📄
Makefile.am
(13.57 KB)
📄
Makefile.in
(78.52 KB)
📄
check_y2k.c
(15.73 KB)
📄
cmd_args.c
(4.25 KB)
📄
complete.conf.in
(3.35 KB)
📄
declcond.h
(793 B)
📄
invoke-ntp.conf.menu
(56 B)
📄
invoke-ntp.conf.texi
(104.37 KB)
📄
invoke-ntp.keys.menu
(56 B)
📄
invoke-ntp.keys.texi
(3.21 KB)
📄
invoke-ntpd.menu
(49 B)
📄
invoke-ntpd.texi
(23.68 KB)
📄
jupiter.h
(9.1 KB)
📄
keyword-gen-utd
(57 B)
📄
keyword-gen.c
(21.99 KB)
📄
ntp.conf.5man
(115.01 KB)
📄
ntp.conf.5mdoc
(101.72 KB)
📄
ntp.conf.def
(100.75 KB)
📄
ntp.conf.html
(126.28 KB)
📄
ntp.conf.man.in
(115.01 KB)
📄
ntp.conf.mdoc.in
(101.71 KB)
📄
ntp.conf.texi
(1.19 KB)
📄
ntp.keys.5man
(3.99 KB)
📄
ntp.keys.5mdoc
(4.25 KB)
📄
ntp.keys.def
(3.65 KB)
📄
ntp.keys.html
(8.37 KB)
📄
ntp.keys.man.in
(3.99 KB)
📄
ntp.keys.mdoc.in
(4.24 KB)
📄
ntp.keys.texi
(1.2 KB)
📄
ntp_config.c
(117.55 KB)
📄
ntp_control.c
(123.14 KB)
📄
ntp_crypto.c
(117.09 KB)
📄
ntp_filegen.c
(13.42 KB)
📄
ntp_io.c
(112.21 KB)
📄
ntp_keyword.h
(73.49 KB)
📄
ntp_leapsec.c
(31.18 KB)
📄
ntp_leapsec.h
(10.95 KB)
📄
ntp_loopfilter.c
(40.05 KB)
📄
ntp_monitor.c
(13.43 KB)
📄
ntp_parser.c
(130.65 KB)
📄
ntp_parser.h
(11.36 KB)
📄
ntp_peer.c
(27.66 KB)
📄
ntp_prio_q.c
(4.54 KB)
📄
ntp_proto.c
(150.76 KB)
📄
ntp_refclock.c
(43.87 KB)
📄
ntp_request.c
(67.25 KB)
📄
ntp_restrict.c
(19.06 KB)
📄
ntp_scanner.c
(20.74 KB)
📄
ntp_scanner.h
(4.43 KB)
📄
ntp_signd.c
(5.24 KB)
📄
ntp_timer.c
(17.69 KB)
📄
ntp_util.c
(22.66 KB)
📄
ntpd-opts.c
(71.91 KB)
📄
ntpd-opts.def
(17.55 KB)
📄
ntpd-opts.h
(14.57 KB)
📄
ntpd.1ntpdman
(32.03 KB)
📄
ntpd.1ntpdmdoc
(29.07 KB)
📄
ntpd.c
(42.16 KB)
📄
ntpd.html
(49.68 KB)
📄
ntpd.man.in
(32.03 KB)
📄
ntpd.mdoc.in
(29.07 KB)
📄
ntpd.texi
(3.25 KB)
📄
ntpdbase-opts.def
(13.21 KB)
📄
ntpsim.c
(17.11 KB)
📄
ppsapi_timepps.h
(497 B)
📄
psl0.conf
(25 B)
📄
psl1.conf
(25 B)
📄
psl2.conf
(37 B)
📄
rc_cmdlength.c
(800 B)
📄
refclock_acts.c
(22.66 KB)
📄
refclock_arbiter.c
(12.15 KB)
📄
refclock_arc.c
(46.85 KB)
📄
refclock_as2201.c
(11.09 KB)
📄
refclock_atom.c
(6.63 KB)
📄
refclock_bancomm.c
(16.11 KB)
📄
refclock_chronolog.c
(7.61 KB)
📄
refclock_chu.c
(45.28 KB)
📄
refclock_conf.c
(7.25 KB)
📄
refclock_datum.c
(22.3 KB)
📄
refclock_dumbclock.c
(8.42 KB)
📄
refclock_fg.c
(6.89 KB)
📄
refclock_gpsdjson.c
(58 KB)
📄
refclock_gpsvme.c
(7.77 KB)
📄
refclock_heath.c
(12.97 KB)
📄
refclock_hopfpci.c
(5.69 KB)
📄
refclock_hopfser.c
(7.41 KB)
📄
refclock_hpgps.c
(16.38 KB)
📄
refclock_irig.c
(30.05 KB)
📄
refclock_jjy.c
(144.27 KB)
📄
refclock_jupiter.c
(25.66 KB)
📄
refclock_leitch.c
(13.27 KB)
📄
refclock_local.c
(5.72 KB)
📄
refclock_msfees.c
(44.66 KB)
📄
refclock_mx4200.c
(41.72 KB)
📄
refclock_neoclock4x.c
(29.08 KB)
📄
refclock_nmea.c
(50.6 KB)
📄
refclock_oncore.c
(121.54 KB)
📄
refclock_palisade.c
(35.15 KB)
📄
refclock_palisade.h
(6.52 KB)
📄
refclock_parse.c
(160.87 KB)
📄
refclock_pcf.c
(4.79 KB)
📄
refclock_pst.c
(8.09 KB)
📄
refclock_ripencc.c
(118.21 KB)
📄
refclock_shm.c
(16.96 KB)
📄
refclock_tpro.c
(4.69 KB)
📄
refclock_true.c
(25.3 KB)
📄
refclock_tsyncpci.c
(28.35 KB)
📄
refclock_tt560.c
(6.12 KB)
📄
refclock_ulink.c
(15.64 KB)
📄
refclock_wwv.c
(79.32 KB)
📄
refclock_wwvb.c
(15.71 KB)
📄
refclock_zyfer.c
(7.38 KB)
Editing: refclock_dumbclock.c
/* * refclock_dumbclock - clock driver for a unknown time distribution system * that only provides hh:mm:ss (in local time, yet!). */ /* * Must interpolate back to local time. Very annoying. */ #define GET_LOCALTIME #ifdef HAVE_CONFIG_H #include <config.h> #endif #if defined(REFCLOCK) && defined(CLOCK_DUMBCLOCK) #include "ntpd.h" #include "ntp_io.h" #include "ntp_refclock.h" #include "ntp_calendar.h" #include "ntp_stdlib.h" #include <stdio.h> #include <ctype.h> #ifdef SYS_WINNT extern int async_write(int, const void *, unsigned int); #undef write #define write(fd, data, octets) async_write(fd, data, octets) #endif /* * This driver supports a generic dumb clock that only outputs hh:mm:ss, * in local time, no less. * * Input format: * * hh:mm:ss <cr> * * hh:mm:ss -- what you'd expect, with a 24 hour clock. (Heck, that's the only * way it could get stupider.) We take time on the <cr>. * * The original source of this module was the WWVB module. */ /* * Interface definitions */ #define DEVICE "/dev/dumbclock%d" /* device name and unit */ #define SPEED232 B9600 /* uart speed (9600 baud) */ #define PRECISION (-13) /* precision assumed (about 100 us) */ #define REFID "dumbclock" /* reference ID */ #define DESCRIPTION "Dumb clock" /* WRU */ /* * Insanity check. Since the time is local, we need to make sure that during midnight * transitions, we can convert back to Unix time. If the conversion results in some number * worse than this number of seconds away, assume the next day and retry. */ #define INSANE_SECONDS 3600 /* * Dumb clock control structure */ struct dumbclock_unit { u_char tcswitch; /* timecode switch */ l_fp laststamp; /* last receive timestamp */ u_char lasthour; /* last hour (for monitor) */ u_char linect; /* count ignored lines (for monitor */ struct tm ymd; /* struct tm for y/m/d only */ }; /* * Function prototypes */ static int dumbclock_start (int, struct peer *); static void dumbclock_shutdown (int, struct peer *); static void dumbclock_receive (struct recvbuf *); #if 0 static void dumbclock_poll (int, struct peer *); #endif /* * Transfer vector */ struct refclock refclock_dumbclock = { dumbclock_start, /* start up driver */ dumbclock_shutdown, /* shut down driver */ noentry, /* poll the driver -- a nice fabrication */ noentry, /* not used */ noentry, /* not used */ noentry, /* not used */ NOFLAGS /* not used */ }; /* * dumbclock_start - open the devices and initialize data for processing */ static int dumbclock_start( int unit, struct peer *peer ) { register struct dumbclock_unit *up; struct refclockproc *pp; int fd; char device[20]; struct tm *tm_time_p; time_t now; /* * Open serial port. Don't bother with CLK line discipline, since * it's not available. */ snprintf(device, sizeof(device), DEVICE, unit); #ifdef DEBUG if (debug) printf ("starting Dumbclock with device %s\n",device); #endif fd = refclock_open(device, SPEED232, 0); if (fd <= 0) return (0); /* * Allocate and initialize unit structure */ up = emalloc_zero(sizeof(*up)); pp = peer->procptr; pp->unitptr = up; pp->io.clock_recv = dumbclock_receive; pp->io.srcclock = peer; pp->io.datalen = 0; pp->io.fd = fd; if (!io_addclock(&pp->io)) { close(fd); pp->io.fd = -1; free(up); pp->unitptr = NULL; return (0); } time(&now); #ifdef GET_LOCALTIME tm_time_p = localtime(&now); #else tm_time_p = gmtime(&now); #endif if (tm_time_p) up->ymd = *tm_time_p; else return 0; /* * Initialize miscellaneous variables */ peer->precision = PRECISION; pp->clockdesc = DESCRIPTION; memcpy((char *)&pp->refid, REFID, 4); return (1); } /* * dumbclock_shutdown - shut down the clock */ static void dumbclock_shutdown( int unit, struct peer *peer ) { register struct dumbclock_unit *up; struct refclockproc *pp; pp = peer->procptr; up = pp->unitptr; if (-1 != pp->io.fd) io_closeclock(&pp->io); if (NULL != up) free(up); } /* * dumbclock_receive - receive data from the serial interface */ static void dumbclock_receive( struct recvbuf *rbufp ) { struct dumbclock_unit *up; struct refclockproc *pp; struct peer *peer; l_fp trtmp; /* arrival timestamp */ int hours; /* hour-of-day */ int minutes; /* minutes-past-the-hour */ int seconds; /* seconds */ int temp; /* int temp */ int got_good; /* got a good time flag */ /* * Initialize pointers and read the timecode and timestamp */ peer = rbufp->recv_peer; pp = peer->procptr; up = pp->unitptr; temp = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp); if (temp == 0) { if (up->tcswitch == 0) { up->tcswitch = 1; up->laststamp = trtmp; } else up->tcswitch = 0; return; } pp->lencode = (u_short)temp; pp->lastrec = up->laststamp; up->laststamp = trtmp; up->tcswitch = 1; #ifdef DEBUG if (debug) printf("dumbclock: timecode %d %s\n", pp->lencode, pp->a_lastcode); #endif /* * We get down to business. Check the timecode format... */ got_good=0; if (sscanf(pp->a_lastcode,"%02d:%02d:%02d", &hours,&minutes,&seconds) == 3) { struct tm *gmtp; struct tm *lt_p; time_t asserted_time; /* the SPM time based on the composite time+date */ struct tm asserted_tm; /* the struct tm of the same */ int adjyear; int adjmon; time_t reality_delta; time_t now; /* * Convert to GMT for sites that distribute localtime. This * means we have to figure out what day it is. Easier said * than done... */ memset(&asserted_tm, 0, sizeof(asserted_tm)); asserted_tm.tm_year = up->ymd.tm_year; asserted_tm.tm_mon = up->ymd.tm_mon; asserted_tm.tm_mday = up->ymd.tm_mday; asserted_tm.tm_hour = hours; asserted_tm.tm_min = minutes; asserted_tm.tm_sec = seconds; asserted_tm.tm_isdst = -1; #ifdef GET_LOCALTIME asserted_time = mktime (&asserted_tm); time(&now); #else #include "GMT unsupported for dumbclock!" #endif reality_delta = asserted_time - now; /* * We assume that if the time is grossly wrong, it's because we got the * year/month/day wrong. */ if (reality_delta > INSANE_SECONDS) { asserted_time -= SECSPERDAY; /* local clock behind real time */ } else if (-reality_delta > INSANE_SECONDS) { asserted_time += SECSPERDAY; /* local clock ahead of real time */ } lt_p = localtime(&asserted_time); if (lt_p) { up->ymd = *lt_p; } else { refclock_report (peer, CEVNT_FAULT); return; } if ((gmtp = gmtime (&asserted_time)) == NULL) { refclock_report (peer, CEVNT_FAULT); return; } adjyear = gmtp->tm_year+1900; adjmon = gmtp->tm_mon+1; pp->day = ymd2yd (adjyear, adjmon, gmtp->tm_mday); pp->hour = gmtp->tm_hour; pp->minute = gmtp->tm_min; pp->second = gmtp->tm_sec; #ifdef DEBUG if (debug) printf ("time is %04d/%02d/%02d %02d:%02d:%02d UTC\n", adjyear,adjmon,gmtp->tm_mday,pp->hour,pp->minute, pp->second); #endif got_good=1; } if (!got_good) { if (up->linect > 0) up->linect--; else refclock_report(peer, CEVNT_BADREPLY); return; } /* * Process the new sample in the median filter and determine the * timecode timestamp. */ if (!refclock_process(pp)) { refclock_report(peer, CEVNT_BADTIME); return; } pp->lastref = pp->lastrec; refclock_receive(peer); record_clock_stats(&peer->srcadr, pp->a_lastcode); up->lasthour = (u_char)pp->hour; } #if 0 /* * dumbclock_poll - called by the transmit procedure */ static void dumbclock_poll( int unit, struct peer *peer ) { register struct dumbclock_unit *up; struct refclockproc *pp; char pollchar; /* * Time to poll the clock. The Chrono-log clock is supposed to * respond to a 'T' by returning a timecode in the format(s) * specified above. Ours does (can?) not, but this seems to be * an installation-specific problem. This code is dyked out, * but may be re-enabled if anyone ever finds a Chrono-log that * actually listens to this command. */ #if 0 pp = peer->procptr; up = pp->unitptr; if (peer->reach == 0) refclock_report(peer, CEVNT_TIMEOUT); if (up->linect > 0) pollchar = 'R'; else pollchar = 'T'; if (write(pp->io.fd, &pollchar, 1) != 1) refclock_report(peer, CEVNT_FAULT); else pp->polls++; #endif } #endif #else int refclock_dumbclock_bs; #endif /* defined(REFCLOCK) && defined(CLOCK_DUMBCLOCK) */
Upload File
Create Folder