diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2015-02-24 22:53:07 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-02-25 00:38:23 -0500 |
commit | b7ee3abbaf7e77dccf3bc2c355e07ea519e4fe9e (patch) | |
tree | ecc669a9fd17bec5c58848a047d4a41edf577723 /ntpshm.h | |
parent | 908344d4d6e6ff314ea263f8ec227f23e4826cee (diff) | |
download | gpsd-b7ee3abbaf7e77dccf3bc2c355e07ea519e4fe9e.tar.gz |
First cut at an interface for the read side of an NTP SHM connection.
Not yet used or tested.
Diffstat (limited to 'ntpshm.h')
-rw-r--r-- | ntpshm.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/ntpshm.h b/ntpshm.h new file mode 100644 index 00000000..f27345d9 --- /dev/null +++ b/ntpshm.h @@ -0,0 +1,62 @@ +/* + * This file is Copyright (c) 2015 by the GPSD project + * BSD terms apply: see the file COPYING in the distribution root for details. + */ + +#ifndef GPSD_NTPSHM_H +#define GPSD_NTPSHM_H + +#include <sys/time.h> +#include <sys/ipc.h> +#include <sys/shm.h> + +#define NTPD_BASE 0x4e545030 /* "NTP0" */ + +/* + * How to read and write fields in an NTP shared segment. + * This definition of shmTime is from ntpd source ntpd/refclock_shm.c + */ + +struct shmTime +{ + int mode; /* 0 - if valid set + * use values, + * clear valid + * 1 - if valid set + * if count before and after read of values is equal, + * use values + * clear valid + */ + volatile int count; + time_t clockTimeStampSec; + int clockTimeStampUSec; + time_t receiveTimeStampSec; + int receiveTimeStampUSec; + int leap; + int precision; + int nsamples; + volatile int valid; + unsigned clockTimeStampNSec; /* Unsigned ns timestamps */ + unsigned receiveTimeStampNSec; /* Unsigned ns timestamps */ + int dummy[8]; +}; + +#endif + +/* + * These types are internal to GPSD + */ +enum segstat_t { + OK, NO_SEGMENT, NOT_READY, BAD_MODE, CLASH}; + +struct shm_stat_t { + struct timespec tvr, tvt; + time_t now; + int leap; +}; + +struct shmTime *shm_get(int, bool); +extern char *shm_name(const int); +enum segstat_t shm_query(struct shmTime *, struct shm_stat_t *); + +/* end */ |