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_pst.c
/* * refclock_pst - clock driver for PSTI/Traconex WWV/WWVH receivers */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #if defined(REFCLOCK) && defined(CLOCK_PST) #include "ntpd.h" #include "ntp_io.h" #include "ntp_refclock.h" #include "ntp_stdlib.h" #include <stdio.h> #include <ctype.h> /* * This driver supports the PSTI 1010 and Traconex 1020 WWV/WWVH * Receivers. No specific claim of accuracy is made for these receiver, * but actual experience suggests that 10 ms would be a conservative * assumption. * * The DIPswitches should be set for 9600 bps line speed, 24-hour day- * of-year format and UTC time zone. Automatic correction for DST should * be disabled. It is very important that the year be set correctly in * the DIPswitches; otherwise, the day of year will be incorrect after * 28 April of a normal or leap year. The propagation delay DIPswitches * should be set according to the distance from the transmitter for both * WWV and WWVH, as described in the instructions. While the delay can * be set only to within 11 ms, the fudge time1 parameter can be used * for vernier corrections. * * Using the poll sequence QTQDQM, the response timecode is in three * sections totalling 50 ASCII printing characters, as concatenated by * the driver, in the following format: * * ahh:mm:ss.fffs<cr> yy/dd/mm/ddd<cr> frdzycchhSSFTttttuuxx<cr> * * on-time = first <cr> * hh:mm:ss.fff = hours, minutes, seconds, milliseconds * a = AM/PM indicator (' ' for 24-hour mode) * yy = year (from internal switches) * dd/mm/ddd = day of month, month, day of year * s = daylight-saving indicator (' ' for 24-hour mode) * f = frequency enable (O = all frequencies enabled) * r = baud rate (3 = 1200, 6 = 9600) * d = features indicator (@ = month/day display enabled) * z = time zone (0 = UTC) * y = year (5 = 91) * cc = WWV propagation delay (52 = 22 ms) * hh = WWVH propagation delay (81 = 33 ms) * SS = status (80 or 82 = operating correctly) * F = current receive frequency (4 = 15 MHz) * T = transmitter (C = WWV, H = WWVH) * tttt = time since last update (0000 = minutes) * uu = flush character (03 = ^c) * xx = 94 (unknown) * * The alarm condition is indicated by other than '8' at A, which occurs * during initial synchronization and when received signal is lost for * an extended period; unlock condition is indicated by other than * "0000" in the tttt subfield at Q. * * Fudge Factors * * There are no special fudge factors other than the generic. */ /* * Interface definitions */ #define DEVICE "/dev/wwv%d" /* device name and unit */ #define SPEED232 B9600 /* uart speed (9600 baud) */ #define PRECISION (-10) /* precision assumed (about 1 ms) */ #define WWVREFID "WWV\0" /* WWV reference ID */ #define WWVHREFID "WWVH" /* WWVH reference ID */ #define DESCRIPTION "PSTI/Traconex WWV/WWVH Receiver" /* WRU */ #define PST_PHI (10e-6) /* max clock oscillator offset */ #define LENPST 46 /* min timecode length */ /* * Unit control structure */ struct pstunit { int tcswitch; /* timecode switch */ char *lastptr; /* pointer to timecode data */ }; /* * Function prototypes */ static int pst_start (int, struct peer *); static void pst_shutdown (int, struct peer *); static void pst_receive (struct recvbuf *); static void pst_poll (int, struct peer *); /* * Transfer vector */ struct refclock refclock_pst = { pst_start, /* start up driver */ pst_shutdown, /* shut down driver */ pst_poll, /* transmit poll message */ noentry, /* not used (old pst_control) */ noentry, /* initialize driver */ noentry, /* not used (old pst_buginfo) */ NOFLAGS /* not used */ }; /* * pst_start - open the devices and initialize data for processing */ static int pst_start( int unit, struct peer *peer ) { register struct pstunit *up; struct refclockproc *pp; int fd; char device[20]; /* * Open serial port. Use CLK line discipline, if available. */ snprintf(device, sizeof(device), DEVICE, unit); fd = refclock_open(device, SPEED232, LDISC_CLK); if (fd <= 0) return (0); /* * Allocate and initialize unit structure */ up = emalloc_zero(sizeof(*up)); pp = peer->procptr; pp->io.clock_recv = pst_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); return (0); } pp->unitptr = up; /* * Initialize miscellaneous variables */ peer->precision = PRECISION; pp->clockdesc = DESCRIPTION; memcpy((char *)&pp->refid, WWVREFID, 4); return (1); } /* * pst_shutdown - shut down the clock */ static void pst_shutdown( int unit, struct peer *peer ) { register struct pstunit *up; struct refclockproc *pp; pp = peer->procptr; up = pp->unitptr; if (-1 != pp->io.fd) io_closeclock(&pp->io); if (NULL != up) free(up); } /* * pst_receive - receive data from the serial interface */ static void pst_receive( struct recvbuf *rbufp ) { register struct pstunit *up; struct refclockproc *pp; struct peer *peer; l_fp trtmp; u_long ltemp; char ampmchar; /* AM/PM indicator */ char daychar; /* standard/daylight indicator */ char junque[10]; /* "yy/dd/mm/" discard */ char info[14]; /* "frdzycchhSSFT" clock info */ /* * Initialize pointers and read the timecode and timestamp */ peer = rbufp->recv_peer; pp = peer->procptr; up = pp->unitptr; up->lastptr += refclock_gtlin(rbufp, up->lastptr, pp->a_lastcode + BMAX - 2 - up->lastptr, &trtmp); *up->lastptr++ = ' '; *up->lastptr = '\0'; /* * Note we get a buffer and timestamp for each <cr>, but only * the first timestamp is retained. */ if (up->tcswitch == 0) pp->lastrec = trtmp; up->tcswitch++; pp->lencode = up->lastptr - pp->a_lastcode; if (up->tcswitch < 3) return; /* * We get down to business, check the timecode format and decode * its contents. If the timecode has invalid length or is not in * proper format, we declare bad format and exit. */ if (pp->lencode < LENPST) { refclock_report(peer, CEVNT_BADREPLY); return; } /* * Timecode format: * "ahh:mm:ss.fffs yy/dd/mm/ddd frdzycchhSSFTttttuuxx" */ if (sscanf(pp->a_lastcode, "%c%2d:%2d:%2d.%3ld%c %9s%3d%13s%4ld", &mchar, &pp->hour, &pp->minute, &pp->second, &pp->nsec, &daychar, junque, &pp->day, info, <emp) != 10) { refclock_report(peer, CEVNT_BADREPLY); return; } pp->nsec *= 1000000; /* * Decode synchronization, quality and last update. If * unsynchronized, set the leap bits accordingly and exit. Once * synchronized, the dispersion depends only on when the clock * was last heard, which depends on the time since last update, * as reported by the clock. */ if (info[9] != '8') pp->leap = LEAP_NOTINSYNC; if (info[12] == 'H') memcpy((char *)&pp->refid, WWVHREFID, 4); else memcpy((char *)&pp->refid, WWVREFID, 4); if (peer->stratum <= 1) peer->refid = pp->refid; if (ltemp == 0) pp->lastref = pp->lastrec; pp->disp = PST_PHI * ltemp * 60; /* * Process the new sample in the median filter and determine the * timecode timestamp. */ if (!refclock_process(pp)) refclock_report(peer, CEVNT_BADTIME); else if (peer->disp > MAXDISTANCE) refclock_receive(peer); } /* * pst_poll - called by the transmit procedure */ static void pst_poll( int unit, struct peer *peer ) { register struct pstunit *up; struct refclockproc *pp; /* * Time to poll the clock. The PSTI/Traconex clock responds to a * "QTQDQMT" by returning a timecode in the format specified * above. Note there is no checking on state, since this may not * be the only customer reading the clock. Only one customer * need poll the clock; all others just listen in. If the clock * becomes unreachable, declare a timeout and keep going. */ pp = peer->procptr; up = pp->unitptr; up->tcswitch = 0; up->lastptr = pp->a_lastcode; if (write(pp->io.fd, "QTQDQMT", 6) != 6) refclock_report(peer, CEVNT_FAULT); if (pp->coderecv == pp->codeproc) { refclock_report(peer, CEVNT_TIMEOUT); return; } refclock_receive(peer); record_clock_stats(&peer->srcadr, pp->a_lastcode); #ifdef DEBUG if (debug) printf("pst: timecode %d %s\n", pp->lencode, pp->a_lastcode); #endif pp->polls++; } #else int refclock_pst_int; #endif /* REFCLOCK */
Upload File
Create Folder