mbgtools-lx  4.2.8
ntp_shm.h
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: ntp_shm.h 1.3 2017/07/05 16:52:25 martin REL_M $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Definitions and prototypes for ntp_shm.c.
10  *
11  * -----------------------------------------------------------------------
12  * $Log: ntp_shm.h $
13  * Revision 1.3 2017/07/05 16:52:25 martin
14  * Defined MAX_SHM_UNIT_OFFSET.
15  * Doxygen changes and fixes.
16  * Updated function prototypes.
17  * Revision 1.2 2013/01/02 10:23:41 daniel
18  * Added nsec support
19  * Revision 1.1 2012/05/29 09:54:15 martin
20  * Initial revision.
21  *
22  **************************************************************************/
23 
24 #ifndef _NTP_SHM_H
25 #define _NTP_SHM_H
26 
27 
28 /* Other headers to be included */
29 
30 #include <sys/ipc.h>
31 #include <sys/shm.h>
32 
33 
34 #ifdef _NTP_SHM
35  #define _ext
36  #define _DO_INIT
37 #else
38  #define _ext extern
39 #endif
40 
41 
42 /* Start of header body */
43 
44 #if 0 && defined( _USE_PACK ) // use default alignment
45  #pragma pack( 1 ) // set byte alignment
46  #define _USING_BYTE_ALIGNMENT
47 #endif
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
63 struct shmTime
64 {
65  int mode; /* 0 - if valid set
66  * use values,
67  * clear valid
68  * 1 - if valid set
69  * if count before and after read of
70  * values is equal,
71  * use values
72  * clear valid
73  */
74  int count;
75  time_t clockTimeStampSec; /* external clock */
76  int clockTimeStampUSec; /* external clock */
77  time_t receiveTimeStampSec; /* internal clock, when external value was received */
78  int receiveTimeStampUSec; /* internal clock, when external value was received */
79  int leap;
80  int precision;
81  int nsamples;
82  int valid;
83  unsigned clockTimeStampNSec; /* unsigned ns timestamps */
85  int dummy[8];
86 };
87 
95 #define LEAP_NOWARNING 0x0
96 #define LEAP_ADDSECOND 0x1
97 #define LEAP_DELSECOND 0x2
98 #define LEAP_NOTINSYNC 0x3
106 #define MAX_SHM_REFCLOCKS 4
107 
108 
112 #define MAX_SHM_UNIT_OFFSET 128
113 
114 
118 #define NTPD_BASE 0x4e545030
119 
120 
124 /* ----- function prototypes begin ----- */
125 
126 /* This section was generated automatically */
127 /* by MAKEHDR, do not remove the comments. */
128 
129  struct shmTime *getShmTime( int unit ) ;
130  int ntpshm_init( struct shmTime **shmTime, int n_units, int n_unit0 ) ;
131 
132 /* ----- function prototypes end ----- */
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 
139 #if defined( _USING_BYTE_ALIGNMENT )
140  #pragma pack() // set default alignment
141  #undef _USING_BYTE_ALIGNMENT
142 #endif
143 
144 /* End of header body */
145 
146 
147 #undef _ext
148 #undef _DO_INIT
149 
150 #endif /* _NTP_SHM_H */
151 
static int n_units
Definition: mbgsvcd.c:90
unsigned clockTimeStampNSec
Definition: ntp_shm.h:83
static int n_unit0
Definition: mbgsvcd.c:89
int precision
Definition: ntp_shm.h:80
time_t receiveTimeStampSec
Definition: ntp_shm.h:77
int receiveTimeStampUSec
Definition: ntp_shm.h:78
unsigned receiveTimeStampNSec
Definition: ntp_shm.h:84
int count
Definition: ntp_shm.h:74
int clockTimeStampUSec
Definition: ntp_shm.h:76
struct shmTime * getShmTime(int unit)
Definition: ntp_shm.c:33
int leap
see NTP Leap Bits
Definition: ntp_shm.h:79
Structure of NTP&#39;s shared memory segment.
Definition: ntp_shm.h:63
int mode
Definition: ntp_shm.h:65
time_t clockTimeStampSec
Definition: ntp_shm.h:75
int valid
Definition: ntp_shm.h:82
int ntpshm_init(struct shmTime **shmTime, int n_units, int n_unit0)
Definition: ntp_shm.c:62
int nsamples
Definition: ntp_shm.h:81
int dummy[8]
Definition: ntp_shm.h:85