-
Notifications
You must be signed in to change notification settings - Fork 146
/
ddt.h
133 lines (115 loc) · 3.41 KB
/
ddt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* @file ddt.h
* @brief Derived data types
* @note Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef HAVE_DDT_H
#define HAVE_DDT_H
#include "pdt.h"
#define PACKED __attribute__((packed))
typedef Integer64 TimeInterval; /* nanoseconds << 16 */
/** On the wire time stamp format. */
struct Timestamp {
uint16_t seconds_msb; /* 16 bits + */
uint32_t seconds_lsb; /* 32 bits = 48 bits*/
UInteger32 nanoseconds;
} PACKED;
/** Internal binary time stamp format. */
struct timestamp {
uint64_t sec;
UInteger32 nsec;
};
struct ClockIdentity {
Octet id[8];
};
struct PortIdentity {
struct ClockIdentity clockIdentity;
UInteger16 portNumber;
} PACKED;
struct PortAddress {
Enumeration16 networkProtocol;
UInteger16 addressLength;
Octet address[0];
} PACKED;
struct PhysicalAddress {
UInteger16 length;
Octet address[0];
} PACKED;
struct ClockQuality {
UInteger8 clockClass;
Enumeration8 clockAccuracy;
UInteger16 offsetScaledLogVariance;
} PACKED;
struct TLV {
Enumeration16 type;
UInteger16 length; /* must be even */
Octet value[0];
} PACKED;
struct PTPText {
UInteger8 length;
Octet text[0];
} PACKED;
/* A static_ptp_text is like a PTPText but includes space to store the
* text inside the struct. The text array must always be
* null-terminated. Also tracks a maximum number of symbols. Note in
* UTF-8, # symbols != # bytes.
*/
#define MAX_PTP_OCTETS 255
struct static_ptp_text {
/* null-terminated array of UTF-8 symbols */
Octet text[MAX_PTP_OCTETS + 1];
/* number of used bytes in text, not including trailing null */
int length;
/* max number of UTF-8 symbols that can be in text */
int max_symbols;
};
struct FaultRecord {
UInteger16 faultRecordLength;
struct Timestamp faultTime;
Enumeration8 severityCode;
struct PTPText faultName;
struct PTPText faultValue;
struct PTPText faultDescription;
};
/* Four bits are dedicated to messageType field */
#define MAX_MESSAGE_TYPES 16
struct PortStats {
uint64_t rxMsgType[MAX_MESSAGE_TYPES];
uint64_t txMsgType[MAX_MESSAGE_TYPES];
};
struct PortServiceStats {
uint64_t announce_timeout;
uint64_t sync_timeout;
uint64_t delay_timeout;
uint64_t unicast_service_timeout;
uint64_t unicast_request_timeout;
uint64_t master_announce_timeout;
uint64_t master_sync_timeout;
uint64_t qualification_timeout;
uint64_t sync_mismatch;
uint64_t followup_mismatch;
};
struct unicast_master_entry {
struct PortIdentity port_identity;
struct ClockQuality clock_quality;
uint8_t selected;
Enumeration8 port_state;
UInteger8 priority1;
UInteger8 priority2;
struct PortAddress address;
} PACKED;
#endif