예제 #1
0
파일: manual.c 프로젝트: vulpicastor/chrony
int
MNL_DeleteSample(int index)
{
  int i;
  struct timeval now;

  if ((index < 0) || (index >= n_samples)) {
    return 0;
  }

  /* Crunch the samples down onto the one being deleted */

  for (i=index; i<(n_samples-1); i++) {
    samples[i] = samples[i+1];
  }
  
  n_samples -= 1;

  /* Now re-estimate.  NULLs because we don't want the parameters back
     in this case. */
  LCL_ReadCookedTime(&now, NULL);
  estimate_and_set_system(&now, 0, 0.0, NULL, NULL, NULL);

  return 1;

}
예제 #2
0
파일: manual.c 프로젝트: SuperQ/chrony
int
MNL_AcceptTimestamp(struct timeval *ts, long *offset_cs, double *dfreq_ppm, double *new_afreq_ppm)
{
  struct timeval now;
  double offset, diff;
  int i;

  if (enabled) {
    LCL_ReadCookedTime(&now, NULL);

    /* Make sure the provided timestamp is sane and the sample
       is not too close to the last one */

    if (!UTI_IsTimeOffsetSane(ts, 0.0))
     return 0;

    if (n_samples) {
      UTI_DiffTimevalsToDouble(&diff, &now, &samples[n_samples - 1].when);
      if (diff < MIN_SAMPLE_SEPARATION)
        return 0;
    }

    UTI_DiffTimevalsToDouble(&offset, &now, ts);

    /* Check if buffer full up */
    if (n_samples == MAX_SAMPLES) {
      /* Shift samples down */
      for (i=1; i<n_samples; i++) {
        samples[i-1] = samples[i];
      }
      --n_samples;
    }
    
    samples[n_samples].when = now;
    samples[n_samples].offset = offset;
    samples[n_samples].orig_offset = offset;
    ++n_samples;

    estimate_and_set_system(&now, 1, offset, offset_cs, dfreq_ppm, new_afreq_ppm);

    return 1;

  } else {
  
    return 0;

  }
}
예제 #3
0
파일: manual.c 프로젝트: vulpicastor/chrony
int
MNL_AcceptTimestamp(struct timeval *ts, long *offset_cs, double *dfreq_ppm, double *new_afreq_ppm)
{
  struct timeval now;
  double offset;
  int i;

  if (enabled) {

    /* Check whether timestamp is within margin of old one */
    LCL_ReadCookedTime(&now, NULL);

    UTI_DiffTimevalsToDouble(&offset, &now, ts);

    /* Check if buffer full up */
    if (n_samples == MAX_SAMPLES) {
      /* Shift samples down */
      for (i=1; i<n_samples; i++) {
        samples[i-1] = samples[i];
      }
      --n_samples;
    }
    
    samples[n_samples].when = now;
    samples[n_samples].offset = offset;
    samples[n_samples].orig_offset = offset;
    ++n_samples;

    estimate_and_set_system(&now, 1, offset, offset_cs, dfreq_ppm, new_afreq_ppm);

    return 1;

  } else {
  
    return 0;

  }
}