~ubuntu-branches/ubuntu/lucid/ntp/lucid

« back to all changes in this revision

Viewing changes to ntpd/refclock_oncore.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-04-29 06:08:19 UTC
  • mfrom: (4.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090429060819-ejgcea6z6hy6xv1f
Tags: 1:4.2.4p6+dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/ntp.conf, debian/ntpdate.default: Change default server to
    ntp.ubuntu.com.
  - debian/ntpdate.ifup: Stop ntp before running ntpdate when an interface 
    comes up, then start again afterwards
  - debian/ntp.init, debian/rules: Only stop when entering single user mode.
  - debian/man/ntpdate.8 - fix debian shipped manpage; patch by
    Josh Holland <jrh@joshh.co.uk>
* Dropped changes, merged in Debian:
  - Build against libcap2 instead of libcap1, fixing a kernel warning
    about using an old interface.
* Dropped changes, superseded upstream/in Debian:
  - debian/patches/CVE-2009-0021.patch: update ntpd/ntp_crypto.c to properly
    check the return code of EVP_VerifyFinal()
  - debian/patches/ipv6-gnu-source.patch: Define _GNU_SOURCE to make IPv6
    work.
* Fixes LP: #217699

Show diffs side-by-side

added added

removed removed

Lines of Context:
535
535
        char device1[STRING_LEN], device2[STRING_LEN], Msg[160];
536
536
        const char *cp;
537
537
        struct stat stat1, stat2;
538
 
#ifdef PPS_HAVE_FINDSOURCE
539
 
        int ret;
540
 
        char id[STRING_LEN];
541
 
#endif
542
538
 
543
539
        /* create instance structure for this unit */
544
540
 
589
585
        (void)sprintf(device1, DEVICE1, unit);
590
586
        (void)sprintf(device2, DEVICE2, unit);
591
587
 
592
 
#ifdef PPS_HAVE_FINDSOURCE
593
 
        /* Try to find the PPS source (by using "index = -1"
594
 
         * we ask just for a generic source)
595
 
         */
596
 
 
597
 
        num = fd2 = -1;
598
 
        if ((num=time_pps_findsource(num, device2, STRING_LEN, id, STRING_LEN)) < 0) {
599
 
                sprintf(Msg, "No available PPS source in the system");
600
 
                record_clock_stats(&(instance->peer->srcadr), Msg);
601
 
                exit(1);
602
 
        }
603
 
 
604
 
        sprintf(Msg, "Found PPS source #%d \"%s\" on \"%s\"", num, id, device2);
605
 
        record_clock_stats(&(instance->peer->srcadr), Msg);
606
 
 
607
 
        /* there are two cases here:
608
 
         *     either there is a device name in device2 and we must open it,
609
 
         *  or there is not, and and it is not a device, and there is nothing
610
 
         *     to open.
611
 
         *  in either case we must use refclock_open to get fd1 opened raw.
612
 
         */
613
 
 
614
 
        if (strlen(device2)) {
615
 
                if (stat(device1, &stat1)) {
616
 
                        sprintf(Msg, "Can't stat fd1 (%s)\n", device1);
617
 
                        record_clock_stats(&(instance->peer->srcadr), Msg);
618
 
                        exit(1);
619
 
                }
620
 
 
621
 
                if (stat(device2, &stat2)) {
622
 
                        sprintf(Msg, "Can't stat fd2 (%s)\n", device2);
623
 
                        record_clock_stats(&(instance->peer->srcadr), Msg);
624
 
                        exit(1);
625
 
                }
626
 
 
627
 
                if ((stat1.st_dev != stat2.st_dev) || (stat1.st_ino != stat2.st_ino)) {
628
 
                        if ((ret=open(device2, O_RDWR)) < 0) {  /* different devices here */
629
 
                                sprintf(Msg, "Can't open fd2 (%s)\n", device2);
630
 
                                record_clock_stats(&(instance->peer->srcadr), Msg);
631
 
                                exit(1);
632
 
                        }
633
 
                }
634
 
        }
635
 
 
636
 
        if ((fd1=refclock_open(device1, SPEED, LDISC_RAW)) < 0) {
637
 
                sprintf(Msg, "Can't open fd1 (%s)\n", device1);
638
 
                record_clock_stats(&(instance->peer->srcadr), Msg);
639
 
                exit(1);
640
 
        }
641
 
 
642
 
#else
643
588
        /* OPEN DEVICES */
644
589
        /* opening different devices for fd1 and fd2 presents no problems */
645
590
        /* opening the SAME device twice, seems to be OS dependent.
679
624
                }
680
625
        }
681
626
        num = fd2;
682
 
#endif
 
627
 
683
628
        /* open ppsapi soure */
684
629
 
685
630
        if (time_pps_create(num, &instance->pps_h) < 0) {
2422
2367
                        return;
2423
2368
 
2424
2369
                dt1 = instance->saw_tooth + instance->offset;    /* dt this time step */
2425
 
                instance->saw_tooth = (s_char) instance->BEHn[10]; /* update for next time Hn[10] */
 
2370
                instance->saw_tooth = (s_char) instance->BEHn[14]; /* update for next time Hn[14] */
2426
2371
                dt2 = instance->saw_tooth + instance->offset;    /* dt next time step */
2427
2372
        } else {
2428
2373
                if (instance->BEHn[21]) /* bad TRAIM */
2429
2374
                        return;
2430
2375
 
2431
2376
                dt1 = instance->saw_tooth + instance->offset;    /* dt this time step */
2432
 
                instance->saw_tooth = (s_char) instance->BEHn[25]; /* update for next time */
 
2377
                instance->saw_tooth = (s_char) instance->BEHn[25]; /* update for next time Bn[25], En[25] */
2433
2378
                dt2 = instance->saw_tooth + instance->offset;    /* dt next time step */
2434
2379
        }
2435
2380
 
2971
2916
        if (dt) {
2972
2917
                sprintf(Msg, "ONCORE[%d]: Leap second (%d) scheduled for %d%s%d at %d:%d:%d",
2973
2918
                        instance->unit,
2974
 
                        dt, buf[9], Month[buf[8]], 256*buf[6]+buf[7],
 
2919
                        dt, buf[9], Month[buf[8]-1], 256*buf[6]+buf[7],
2975
2920
                        buf[15], buf[16], buf[17]);
2976
2921
                record_clock_stats(&(instance->peer->srcadr), Msg);
2977
2922
        }