1*eabc0478Schristos /* $NetBSD: refclock_conf.c,v 1.6 2024/08/18 20:47:18 christos Exp $ */ 2abb0f93cSkardel 3abb0f93cSkardel /* 4abb0f93cSkardel * refclock_conf.c - reference clock configuration 5abb0f93cSkardel */ 6abb0f93cSkardel #ifdef HAVE_CONFIG_H 7abb0f93cSkardel #include <config.h> 8abb0f93cSkardel #endif 9abb0f93cSkardel 10abb0f93cSkardel #include <stdio.h> 11abb0f93cSkardel #include <sys/types.h> 12abb0f93cSkardel 13abb0f93cSkardel #include "ntpd.h" 14abb0f93cSkardel #include "ntp_refclock.h" 15abb0f93cSkardel #include "ntp_stdlib.h" 16abb0f93cSkardel 17abb0f93cSkardel #ifdef REFCLOCK 18abb0f93cSkardel 19abb0f93cSkardel static struct refclock refclock_none = { 20abb0f93cSkardel noentry, noentry, noentry, noentry, noentry, noentry, NOFLAGS 21abb0f93cSkardel }; 22abb0f93cSkardel 23abb0f93cSkardel #ifdef CLOCK_LOCAL 24abb0f93cSkardel extern struct refclock refclock_local; 25abb0f93cSkardel #else 26abb0f93cSkardel #define refclock_local refclock_none 27abb0f93cSkardel #endif 28abb0f93cSkardel 29abb0f93cSkardel #ifdef CLOCK_PST 30abb0f93cSkardel extern struct refclock refclock_pst; 31abb0f93cSkardel #else 32abb0f93cSkardel #define refclock_pst refclock_none 33abb0f93cSkardel #endif 34abb0f93cSkardel 35abb0f93cSkardel #ifdef CLOCK_CHU 36abb0f93cSkardel extern struct refclock refclock_chu; 37abb0f93cSkardel #else 38abb0f93cSkardel #define refclock_chu refclock_none 39abb0f93cSkardel #endif 40abb0f93cSkardel 41abb0f93cSkardel #ifdef CLOCK_WWV 42abb0f93cSkardel extern struct refclock refclock_wwv; 43abb0f93cSkardel #else 44abb0f93cSkardel #define refclock_wwv refclock_none 45abb0f93cSkardel #endif 46abb0f93cSkardel 47abb0f93cSkardel #ifdef CLOCK_SPECTRACOM 48abb0f93cSkardel extern struct refclock refclock_wwvb; 49abb0f93cSkardel #else 50abb0f93cSkardel #define refclock_wwvb refclock_none 51abb0f93cSkardel #endif 52abb0f93cSkardel 53abb0f93cSkardel #ifdef CLOCK_PARSE 54abb0f93cSkardel extern struct refclock refclock_parse; 55abb0f93cSkardel #else 56abb0f93cSkardel #define refclock_parse refclock_none 57abb0f93cSkardel #endif 58abb0f93cSkardel 59abb0f93cSkardel #if defined(CLOCK_MX4200) && defined(HAVE_PPSAPI) 60abb0f93cSkardel extern struct refclock refclock_mx4200; 61abb0f93cSkardel #else 62abb0f93cSkardel #define refclock_mx4200 refclock_none 63abb0f93cSkardel #endif 64abb0f93cSkardel 65abb0f93cSkardel #ifdef CLOCK_AS2201 66abb0f93cSkardel extern struct refclock refclock_as2201; 67abb0f93cSkardel #else 68abb0f93cSkardel #define refclock_as2201 refclock_none 69abb0f93cSkardel #endif 70abb0f93cSkardel 71abb0f93cSkardel #ifdef CLOCK_ARBITER 72abb0f93cSkardel extern struct refclock refclock_arbiter; 73abb0f93cSkardel #else 74abb0f93cSkardel #define refclock_arbiter refclock_none 75abb0f93cSkardel #endif 76abb0f93cSkardel 77abb0f93cSkardel #ifdef CLOCK_TPRO 78abb0f93cSkardel extern struct refclock refclock_tpro; 79abb0f93cSkardel #else 80abb0f93cSkardel #define refclock_tpro refclock_none 81abb0f93cSkardel #endif 82abb0f93cSkardel 83abb0f93cSkardel #ifdef CLOCK_LEITCH 84abb0f93cSkardel extern struct refclock refclock_leitch; 85abb0f93cSkardel #else 86abb0f93cSkardel #define refclock_leitch refclock_none 87abb0f93cSkardel #endif 88abb0f93cSkardel 89abb0f93cSkardel #ifdef CLOCK_IRIG 90abb0f93cSkardel extern struct refclock refclock_irig; 91abb0f93cSkardel #else 92abb0f93cSkardel #define refclock_irig refclock_none 93abb0f93cSkardel #endif 94abb0f93cSkardel 95abb0f93cSkardel #if 0 && defined(CLOCK_MSFEES) && defined(PPS) 96abb0f93cSkardel extern struct refclock refclock_msfees; 97abb0f93cSkardel #else 98abb0f93cSkardel #define refclock_msfees refclock_none 99abb0f93cSkardel #endif 100abb0f93cSkardel 101abb0f93cSkardel #ifdef CLOCK_BANC 102abb0f93cSkardel extern struct refclock refclock_bancomm; 103abb0f93cSkardel #else 104abb0f93cSkardel #define refclock_bancomm refclock_none 105abb0f93cSkardel #endif 106abb0f93cSkardel 107abb0f93cSkardel #ifdef CLOCK_TRUETIME 108abb0f93cSkardel extern struct refclock refclock_true; 109abb0f93cSkardel #else 110abb0f93cSkardel #define refclock_true refclock_none 111abb0f93cSkardel #endif 112abb0f93cSkardel 113abb0f93cSkardel #ifdef CLOCK_DATUM 114abb0f93cSkardel extern struct refclock refclock_datum; 115abb0f93cSkardel #else 116abb0f93cSkardel #define refclock_datum refclock_none 117abb0f93cSkardel #endif 118abb0f93cSkardel 119abb0f93cSkardel #ifdef CLOCK_ACTS 120abb0f93cSkardel extern struct refclock refclock_acts; 121abb0f93cSkardel #else 122abb0f93cSkardel #define refclock_acts refclock_none 123abb0f93cSkardel #endif 124abb0f93cSkardel 125abb0f93cSkardel #ifdef CLOCK_HEATH 126abb0f93cSkardel extern struct refclock refclock_heath; 127abb0f93cSkardel #else 128abb0f93cSkardel #define refclock_heath refclock_none 129abb0f93cSkardel #endif 130abb0f93cSkardel 131abb0f93cSkardel #ifdef CLOCK_NMEA 132abb0f93cSkardel extern struct refclock refclock_nmea; 133abb0f93cSkardel #else 134abb0f93cSkardel #define refclock_nmea refclock_none 135abb0f93cSkardel #endif 136abb0f93cSkardel 137abb0f93cSkardel #if defined (CLOCK_ATOM) && defined(HAVE_PPSAPI) 138abb0f93cSkardel extern struct refclock refclock_atom; 139abb0f93cSkardel #else 140abb0f93cSkardel #define refclock_atom refclock_none 141abb0f93cSkardel #endif 142abb0f93cSkardel 143abb0f93cSkardel #ifdef CLOCK_HPGPS 144abb0f93cSkardel extern struct refclock refclock_hpgps; 145abb0f93cSkardel #else 146abb0f93cSkardel #define refclock_hpgps refclock_none 147abb0f93cSkardel #endif 148abb0f93cSkardel 149abb0f93cSkardel #ifdef CLOCK_GPSVME 150abb0f93cSkardel extern struct refclock refclock_gpsvme; 151abb0f93cSkardel #else 152abb0f93cSkardel #define refclock_gpsvme refclock_none 153abb0f93cSkardel #endif 154abb0f93cSkardel 155abb0f93cSkardel #ifdef CLOCK_ARCRON_MSF 156abb0f93cSkardel extern struct refclock refclock_arc; 157abb0f93cSkardel #else 158abb0f93cSkardel #define refclock_arc refclock_none 159abb0f93cSkardel #endif 160abb0f93cSkardel 161abb0f93cSkardel #ifdef CLOCK_SHM 162abb0f93cSkardel extern struct refclock refclock_shm; 163abb0f93cSkardel #else 164abb0f93cSkardel #define refclock_shm refclock_none 165abb0f93cSkardel #endif 166abb0f93cSkardel 167abb0f93cSkardel #ifdef CLOCK_PALISADE 168abb0f93cSkardel extern struct refclock refclock_palisade; 169abb0f93cSkardel #else 170abb0f93cSkardel #define refclock_palisade refclock_none 171abb0f93cSkardel #endif 172abb0f93cSkardel 173abb0f93cSkardel #if defined(CLOCK_ONCORE) 174abb0f93cSkardel extern struct refclock refclock_oncore; 175abb0f93cSkardel #else 176abb0f93cSkardel #define refclock_oncore refclock_none 177abb0f93cSkardel #endif 178abb0f93cSkardel 179abb0f93cSkardel #if defined(CLOCK_JUPITER) && defined(HAVE_PPSAPI) 180abb0f93cSkardel extern struct refclock refclock_jupiter; 181abb0f93cSkardel #else 182abb0f93cSkardel #define refclock_jupiter refclock_none 183abb0f93cSkardel #endif 184abb0f93cSkardel 185abb0f93cSkardel #if defined(CLOCK_CHRONOLOG) 186abb0f93cSkardel extern struct refclock refclock_chronolog; 187abb0f93cSkardel #else 188abb0f93cSkardel #define refclock_chronolog refclock_none 189abb0f93cSkardel #endif 190abb0f93cSkardel 191abb0f93cSkardel #if defined(CLOCK_DUMBCLOCK) 192abb0f93cSkardel extern struct refclock refclock_dumbclock; 193abb0f93cSkardel #else 194abb0f93cSkardel #define refclock_dumbclock refclock_none 195abb0f93cSkardel #endif 196abb0f93cSkardel 197abb0f93cSkardel #ifdef CLOCK_ULINK 198abb0f93cSkardel extern struct refclock refclock_ulink; 199abb0f93cSkardel #else 200abb0f93cSkardel #define refclock_ulink refclock_none 201abb0f93cSkardel #endif 202abb0f93cSkardel 203abb0f93cSkardel #ifdef CLOCK_PCF 204abb0f93cSkardel extern struct refclock refclock_pcf; 205abb0f93cSkardel #else 206abb0f93cSkardel #define refclock_pcf refclock_none 207abb0f93cSkardel #endif 208abb0f93cSkardel 209abb0f93cSkardel #ifdef CLOCK_FG 210abb0f93cSkardel extern struct refclock refclock_fg; 211abb0f93cSkardel #else 212abb0f93cSkardel #define refclock_fg refclock_none 213abb0f93cSkardel #endif 214abb0f93cSkardel 215abb0f93cSkardel #ifdef CLOCK_HOPF_SERIAL 216abb0f93cSkardel extern struct refclock refclock_hopfser; 217abb0f93cSkardel #else 218abb0f93cSkardel #define refclock_hopfser refclock_none 219abb0f93cSkardel #endif 220abb0f93cSkardel 221abb0f93cSkardel #ifdef CLOCK_HOPF_PCI 222abb0f93cSkardel extern struct refclock refclock_hopfpci; 223abb0f93cSkardel #else 224abb0f93cSkardel #define refclock_hopfpci refclock_none 225abb0f93cSkardel #endif 226abb0f93cSkardel 227abb0f93cSkardel #ifdef CLOCK_JJY 228abb0f93cSkardel extern struct refclock refclock_jjy; 229abb0f93cSkardel #else 230abb0f93cSkardel #define refclock_jjy refclock_none 231abb0f93cSkardel #endif 232abb0f93cSkardel 233abb0f93cSkardel #ifdef CLOCK_TT560 234abb0f93cSkardel extern struct refclock refclock_tt560; 235abb0f93cSkardel #else 236abb0f93cSkardel #define refclock_tt560 refclock_none 237abb0f93cSkardel #endif 238abb0f93cSkardel 239abb0f93cSkardel #ifdef CLOCK_ZYFER 240abb0f93cSkardel extern struct refclock refclock_zyfer; 241abb0f93cSkardel #else 242abb0f93cSkardel #define refclock_zyfer refclock_none 243abb0f93cSkardel #endif 244abb0f93cSkardel 245abb0f93cSkardel #ifdef CLOCK_RIPENCC 246abb0f93cSkardel extern struct refclock refclock_ripencc; 247abb0f93cSkardel #else 248abb0f93cSkardel #define refclock_ripencc refclock_none 249abb0f93cSkardel #endif 250abb0f93cSkardel 251abb0f93cSkardel #ifdef CLOCK_NEOCLOCK4X 252abb0f93cSkardel extern struct refclock refclock_neoclock4x; 253abb0f93cSkardel #else 254abb0f93cSkardel #define refclock_neoclock4x refclock_none 255abb0f93cSkardel #endif 256abb0f93cSkardel 2578585484eSchristos #ifdef CLOCK_TSYNCPCI 2588585484eSchristos extern struct refclock refclock_tsyncpci; 2598585484eSchristos #else 2608585484eSchristos #define refclock_tsyncpci refclock_none 2618585484eSchristos #endif 262b8ecfcfeSchristos 263b8ecfcfeSchristos #if defined(CLOCK_GPSDJSON) && !defined(SYS_WINNT) 264b8ecfcfeSchristos extern struct refclock refclock_gpsdjson; 265b8ecfcfeSchristos #else 266b8ecfcfeSchristos #define refclock_gpsdjson refclock_none 267b8ecfcfeSchristos #endif 268abb0f93cSkardel /* 269abb0f93cSkardel * Order is clock_start(), clock_shutdown(), clock_poll(), 270abb0f93cSkardel * clock_control(), clock_init(), clock_buginfo, clock_flags; 271abb0f93cSkardel * 272abb0f93cSkardel * Types are defined in ntp.h. The index must match this. 273abb0f93cSkardel */ 274f003fb54Skardel struct refclock * const refclock_conf[] = { 275abb0f93cSkardel &refclock_none, /* 0 REFCLK_NONE */ 276abb0f93cSkardel &refclock_local, /* 1 REFCLK_LOCAL */ 277abb0f93cSkardel &refclock_none, /* 2 deprecated: REFCLK_GPS_TRAK */ 278abb0f93cSkardel &refclock_pst, /* 3 REFCLK_WWV_PST */ 279abb0f93cSkardel &refclock_wwvb, /* 4 REFCLK_SPECTRACOM */ 280abb0f93cSkardel &refclock_true, /* 5 REFCLK_TRUETIME */ 281abb0f93cSkardel &refclock_irig, /* 6 REFCLK_IRIG_AUDIO */ 282abb0f93cSkardel &refclock_chu, /* 7 REFCLK_CHU_AUDIO */ 283abb0f93cSkardel &refclock_parse, /* 8 REFCLK_PARSE */ 284abb0f93cSkardel &refclock_mx4200, /* 9 REFCLK_GPS_MX4200 */ 285abb0f93cSkardel &refclock_as2201, /* 10 REFCLK_GPS_AS2201 */ 286abb0f93cSkardel &refclock_arbiter, /* 11 REFCLK_GPS_ARBITER */ 287abb0f93cSkardel &refclock_tpro, /* 12 REFCLK_IRIG_TPRO */ 288abb0f93cSkardel &refclock_leitch, /* 13 REFCLK_ATOM_LEITCH */ 289abb0f93cSkardel &refclock_none, /* 14 deprecated: REFCLK_MSF_EES */ 290abb0f93cSkardel &refclock_none, /* 15 not used */ 291abb0f93cSkardel &refclock_bancomm, /* 16 REFCLK_IRIG_BANCOMM */ 292abb0f93cSkardel &refclock_datum, /* 17 REFCLK_GPS_DATUM */ 293abb0f93cSkardel &refclock_acts, /* 18 REFCLK_ACTS */ 294abb0f93cSkardel &refclock_heath, /* 19 REFCLK_WWV_HEATH */ 295abb0f93cSkardel &refclock_nmea, /* 20 REFCLK_GPS_NMEA */ 296abb0f93cSkardel &refclock_gpsvme, /* 21 REFCLK_GPS_VME */ 297abb0f93cSkardel &refclock_atom, /* 22 REFCLK_ATOM_PPS */ 298abb0f93cSkardel &refclock_none, /* 23 not used */ 299abb0f93cSkardel &refclock_none, /* 24 not used */ 300abb0f93cSkardel &refclock_none, /* 25 not used */ 301abb0f93cSkardel &refclock_hpgps, /* 26 REFCLK_GPS_HP */ 302abb0f93cSkardel &refclock_arc, /* 27 REFCLK_ARCRON_MSF */ 303abb0f93cSkardel &refclock_shm, /* 28 REFCLK_SHM */ 304abb0f93cSkardel &refclock_palisade, /* 29 REFCLK_PALISADE */ 305abb0f93cSkardel &refclock_oncore, /* 30 REFCLK_ONCORE */ 306abb0f93cSkardel &refclock_jupiter, /* 31 REFCLK_GPS_JUPITER */ 307abb0f93cSkardel &refclock_chronolog, /* 32 REFCLK_CHRONOLOG */ 308abb0f93cSkardel &refclock_dumbclock, /* 33 REFCLK_DUMBCLOCK */ 309abb0f93cSkardel &refclock_ulink, /* 34 REFCLOCK_ULINK */ 310abb0f93cSkardel &refclock_pcf, /* 35 REFCLOCK_PCF */ 311abb0f93cSkardel &refclock_wwv, /* 36 REFCLOCK_WWV_AUDIO */ 312abb0f93cSkardel &refclock_fg, /* 37 REFCLOCK_FG */ 313abb0f93cSkardel &refclock_hopfser, /* 38 REFCLK_HOPF_SERIAL */ 314abb0f93cSkardel &refclock_hopfpci, /* 39 REFCLK_HOPF_PCI */ 315abb0f93cSkardel &refclock_jjy, /* 40 REFCLK_JJY */ 316abb0f93cSkardel &refclock_tt560, /* 41 REFCLK_TT560 */ 317abb0f93cSkardel &refclock_zyfer, /* 42 REFCLK_ZYFER */ 318abb0f93cSkardel &refclock_ripencc, /* 43 REFCLK_RIPENCC */ 3198585484eSchristos &refclock_neoclock4x, /* 44 REFCLK_NEOCLOCK4X */ 320b8ecfcfeSchristos &refclock_tsyncpci, /* 45 REFCLK_TSYNCPCI */ 321b8ecfcfeSchristos &refclock_gpsdjson /* 46 REFCLK_GPSDJSON */ 322abb0f93cSkardel }; 323abb0f93cSkardel 324abb0f93cSkardel u_char num_refclock_conf = sizeof(refclock_conf)/sizeof(struct refclock *); 325abb0f93cSkardel 326abb0f93cSkardel #else 327*eabc0478Schristos NONEMPTY_TRANSLATION_UNIT 328abb0f93cSkardel #endif 329