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_zyfer.c
/* * refclock_zyfer - clock driver for the Zyfer GPSTarplus Clock * * Harlan Stenn, Jan 2002 */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #if defined(REFCLOCK) && defined(CLOCK_ZYFER) #include "ntpd.h" #include "ntp_io.h" #include "ntp_refclock.h" #include "ntp_stdlib.h" #include "ntp_unixtime.h" #include "ntp_calgps.h" #include <stdio.h> #include <ctype.h> #if defined(HAVE_TERMIOS_H) # include <termios.h> #elif defined(HAVE_SYS_TERMIOS_H) # include <sys/termios.h> #endif #ifdef HAVE_SYS_PPSCLOCK_H # include <sys/ppsclock.h> #endif /* * This driver provides support for the TOD serial port of a Zyfer GPStarplus. * This clock also provides PPS as well as IRIG outputs. * Precision is limited by the serial driver, etc. * * If I was really brave I'd hack/generalize the serial driver to deal * with arbitrary on-time characters. This clock *begins* the stream with * `!`, the on-time character, and the string is *not* EOL-terminated. * * Configure the beast for 9600, 8N1. While I see leap-second stuff * in the documentation, the published specs on the TOD format only show * the seconds going to '59'. I see no leap warning in the TOD format. * * The clock sends the following message once per second: * * !TIME,2002,017,07,59,32,2,4,1 * YYYY DDD HH MM SS m T O * * ! On-time character * YYYY Year * DDD 001-366 Day of Year * HH 00-23 Hour * MM 00-59 Minute * SS 00-59 Second (probably 00-60) * m 1-5 Time Mode: * 1 = GPS time * 2 = UTC time * 3 = LGPS time (Local GPS) * 4 = LUTC time (Local UTC) * 5 = Manual time * T 4-9 Time Figure Of Merit: * 4 x <= 1us * 5 1us < x <= 10 us * 6 10us < x <= 100us * 7 100us < x <= 1ms * 8 1ms < x <= 10ms * 9 10ms < x * O 0-4 Operation Mode: * 0 Warm-up * 1 Time Locked * 2 Coasting * 3 Recovering * 4 Manual * */ /* * Interface definitions */ #define DEVICE "/dev/zyfer%d" /* device name and unit */ #define SPEED232 B9600 /* uart speed (9600 baud) */ #define PRECISION (-20) /* precision assumed (about 1 us) */ #define REFID "GPS\0" /* reference ID */ #define DESCRIPTION "Zyfer GPStarplus" /* WRU */ #define LENZYFER 29 /* timecode length */ /* * Unit control structure */ struct zyferunit { u_char Rcvbuf[LENZYFER + 1]; u_char polled; /* poll message flag */ int pollcnt; l_fp tstamp; /* timestamp of last poll */ int Rcvptr; }; /* * Function prototypes */ static int zyfer_start (int, struct peer *); static void zyfer_shutdown (int, struct peer *); static void zyfer_receive (struct recvbuf *); static void zyfer_poll (int, struct peer *); /* * Transfer vector */ struct refclock refclock_zyfer = { zyfer_start, /* start up driver */ zyfer_shutdown, /* shut down driver */ zyfer_poll, /* transmit poll message */ noentry, /* not used (old zyfer_control) */ noentry, /* initialize driver (not used) */ noentry, /* not used (old zyfer_buginfo) */ NOFLAGS /* not used */ }; /* * zyfer_start - open the devices and initialize data for processing */ static int zyfer_start( int unit, struct peer *peer ) { register struct zyferunit *up; struct refclockproc *pp; int fd; char device[20]; /* * Open serial port. * Something like LDISC_ACTS that looked for ! would be nice... */ snprintf(device, sizeof(device), DEVICE, unit); fd = refclock_open(device, SPEED232, LDISC_RAW); if (fd <= 0) return (0); msyslog(LOG_NOTICE, "zyfer(%d) fd: %d dev <%s>", unit, fd, device); /* * Allocate and initialize unit structure */ up = emalloc(sizeof(struct zyferunit)); memset(up, 0, sizeof(struct zyferunit)); pp = peer->procptr; pp->io.clock_recv = zyfer_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, REFID, 4); up->pollcnt = 2; up->polled = 0; /* May not be needed... */ return (1); } /* * zyfer_shutdown - shut down the clock */ static void zyfer_shutdown( int unit, struct peer *peer ) { register struct zyferunit *up; struct refclockproc *pp; pp = peer->procptr; up = pp->unitptr; if (pp->io.fd != -1) io_closeclock(&pp->io); if (up != NULL) free(up); } /* * zyfer_receive - receive data from the serial interface */ static void zyfer_receive( struct recvbuf *rbufp ) { register struct zyferunit *up; struct refclockproc *pp; struct peer *peer; int tmode; /* Time mode */ int tfom; /* Time Figure Of Merit */ int omode; /* Operation mode */ u_char *p; TCivilDate tsdoy; TNtpDatum tsntp; l_fp tfrac; peer = rbufp->recv_peer; pp = peer->procptr; up = pp->unitptr; p = (u_char *) &rbufp->recv_space; /* * If lencode is 0: * - if *rbufp->recv_space is ! * - - call refclock_gtlin to get things going * - else flush * else stuff it on the end of lastcode * If we don't have LENZYFER bytes * - wait for more data * Crack the beast, and if it's OK, process it. * * We use refclock_gtlin() because we might use LDISC_CLK. * * Under FreeBSD, we get the ! followed by two 14-byte packets. */ if (pp->lencode >= LENZYFER) pp->lencode = 0; if (!pp->lencode) { if (*p == '!') pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &pp->lastrec); else return; } else { memcpy(pp->a_lastcode + pp->lencode, p, rbufp->recv_length); pp->lencode += rbufp->recv_length; pp->a_lastcode[pp->lencode] = '\0'; } if (pp->lencode < LENZYFER) return; record_clock_stats(&peer->srcadr, pp->a_lastcode); /* * 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 != LENZYFER) { refclock_report(peer, CEVNT_BADTIME); return; } /* * Timecode sample: "!TIME,2002,017,07,59,32,2,4,1" */ if (sscanf(pp->a_lastcode, "!TIME,%4d,%3d,%2d,%2d,%2d,%d,%d,%d", &pp->year, &pp->day, &pp->hour, &pp->minute, &pp->second, &tmode, &tfom, &omode) != 8) { refclock_report(peer, CEVNT_BADREPLY); return; } if (tmode != 2) { refclock_report(peer, CEVNT_BADTIME); return; } /* Should we make sure tfom is 4? */ if (omode != 1) { pp->leap = LEAP_NOTINSYNC; return; } /* treat GPS input as subject to era warps */ ZERO(tsdoy); ZERO(tfrac); tsdoy.year = pp->year; tsdoy.yearday = pp->day; tsdoy.hour = pp->hour; tsdoy.minute = pp->minute; tsdoy.second = pp->second; /* note: We kept 'month' and 'monthday' zero above. That forces * day-of-year based calculation now: */ tsntp = gpsntp_from_calendar(&tsdoy, tfrac); tfrac = ntpfp_from_ntpdatum(&tsntp); refclock_process_offset(pp, tfrac, pp->lastrec, pp->fudgetime1); /* * Good place for record_clock_stats() */ up->pollcnt = 2; if (up->polled) { up->polled = 0; refclock_receive(peer); } } /* * zyfer_poll - called by the transmit procedure */ static void zyfer_poll( int unit, struct peer *peer ) { register struct zyferunit *up; struct refclockproc *pp; /* * We don't really do anything here, except arm the receiving * side to capture a sample and check for timeouts. */ pp = peer->procptr; up = pp->unitptr; if (!up->pollcnt) refclock_report(peer, CEVNT_TIMEOUT); else up->pollcnt--; pp->polls++; up->polled = 1; } #else int refclock_zyfer_bs; #endif /* REFCLOCK */
Upload File
Create Folder