libptpmgmt 2.0
libptpmgmt library that provides the functionality of linuxptp pmc
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-3.0-or-later
2 SPDX-FileCopyrightText: Copyright © 2021 Erez Geva <ErezGeva2@gmail.com> */
3
12#ifndef __PTPMGMT_TYPES_H
13#define __PTPMGMT_TYPES_H
14
15#ifdef __cplusplus
16#include <map>
17#include "bin.h"
18#include "mngIds.h"
19
20__PTPMGMT_NAMESPACE_BEGIN
21
22#ifndef INT48_MIN
24const int64_t INT48_MIN = -INT64_C(0x7fffffffffff) - 1;
25#endif
26#ifndef INT48_MAX
28const int64_t INT48_MAX = INT64_C(0x7fffffffffff);
29#endif
30#ifndef UINT48_MAX
32const uint64_t UINT48_MAX = UINT64_C(0xffffffffffff);
33#endif
34
36typedef uint8_t Nibble_t;
38typedef uint8_t UInteger8_t;
40typedef uint16_t UInteger16_t;
42typedef uint32_t UInteger32_t;
44typedef uint64_t UInteger48_t;
46const size_t sizeof_UInteger48_t = 6;
48typedef uint64_t UInteger64_t;
50typedef int8_t Integer8_t;
52typedef int16_t Integer16_t;
54typedef int32_t Integer32_t;
56typedef int64_t Integer48_t;
58const size_t sizeof_Integer48_t = 6;
60typedef int64_t Integer64_t;
62typedef uint8_t Octet_t;
64typedef double Float64_t;
66typedef long double float_seconds;
68typedef long double float_nanoseconds;
69
115 /* Event messages */
117 Sync = 0,
124 /* General messages */
132 Announce = 0xb,
137};
191enum actionField_e : uint8_t {
192 GET = 0,
193 SET = 1,
197};
199enum managementErrorId_e : uint16_t {
201 NO_SUCH_ID = 0x0002,
202 WRONG_LENGTH = 0x0003,
203 WRONG_VALUE = 0x0004,
204 NOT_SETABLE = 0x0005,
205 NOT_SUPPORTED = 0x0006,
206 GENERAL_ERROR = 0xfffe,
207};
212enum clockType_e : uint16_t {
213 ordinaryClock = 0x8000,
214 boundaryClock = 0x4000,
218};
260enum faultRecord_e : uint8_t {
261 F_Emergency = 0x00,
262 F_Alert = 0x01,
263 F_Critical = 0x02,
264 F_Error = 0x03,
265 F_Warning = 0x04,
266 F_Notice = 0x05,
268 F_Debug = 0x07,
269};
271enum timeSource_e : uint8_t {
273 GNSS = 0x20,
274 GPS = 0x20,
277 PTP = 0x40,
278 NTP = 0x50,
279 HAND_SET = 0x60,
280 OTHER = 0x90,
282};
299enum delayMechanism_e : uint8_t {
304 AUTO = 0,
306 E2E = 1,
308 P2P = 2,
318};
379enum : uint8_t {
381 F_LI_61 = (1 << 0),
383 F_LI_59 = (1 << 1),
385 F_UTCV = (1 << 2),
387 F_PTP = (1 << 3),
389 F_TTRA = (1 << 4),
392 F_FTRA = (1 << 5),
393};
401 static size_t size();
411 int64_t getIntervalInt() const;
416 bool isZero() const;
417};
428 Timestamp_t(int64_t secs, uint32_t nsecs);
433 static size_t size();
438 std::string string() const;
443 operator std::string() const { return string(); }
444
445 #ifndef SWIG /* standard C++ structures converting */
451 Timestamp_t(const timespec &ts);
456 operator timespec() const;
462 void toTimespec(timespec &ts) const;
468 Timestamp_t(const timeval &tv);
475 operator timeval() const;
483 void toTimeval(timeval &tv) const;
484 #endif /* SWIG */
499 operator float_seconds() const { return toFloat(); }
509 void fromNanoseconds(uint64_t nanoseconds);
514 uint64_t toNanoseconds() const;
520 bool operator==(const Timestamp_t &ts) const { return eq(ts); }
526 bool eq(const Timestamp_t &ts) const;
533 bool operator==(float_seconds seconds) const { return eq(seconds); }
540 bool eq(float_seconds seconds) const;
548 bool operator<(const Timestamp_t &ts) const { return less(ts); }
554 bool less(const Timestamp_t &ts) const;
560 bool operator<(float_seconds seconds) const { return less(seconds); }
566 bool less(float_seconds seconds) const;
572 Timestamp_t &operator+(const Timestamp_t &ts) { return add(ts); }
578 Timestamp_t &operator+=(const Timestamp_t &ts) { return add(ts); }
590 Timestamp_t &operator+(float_seconds seconds) { return add(seconds); }
596 Timestamp_t &operator+=(float_seconds seconds) { return add(seconds); }
608 Timestamp_t &operator-(const Timestamp_t &ts) { return subt(ts); }
614 Timestamp_t &operator-=(const Timestamp_t &ts) { return subt(ts); }
626 Timestamp_t &operator-(float_seconds seconds) { return add(-seconds); }
632 Timestamp_t &operator-=(float_seconds seconds) { return add(-seconds); }
643 bool isZero() const;
644};
652 static size_t size();
657 std::string string() const;
662 void clear(int val = 0);
668 bool operator==(const ClockIdentity_t &rhs) const { return eq(rhs); }
674 bool eq(const ClockIdentity_t &rhs) const;
680 bool operator<(const ClockIdentity_t &rhs) const { return less(rhs); }
686 bool less(const ClockIdentity_t &rhs) const;
692 bool operator==(const Binary &bin) const { return eq(bin); }
698 bool eq(const Binary &bin) const;
699};
708 static size_t size();
713 std::string string() const;
717 void clear();
723 bool operator==(const PortIdentity_t &rhs) const { return eq(rhs); }
729 bool eq(const PortIdentity_t &rhs) const;
735 bool operator<(const PortIdentity_t &rhs) const { return less(rhs); }
741 bool less(const PortIdentity_t &rhs) const;
742};
758 size_t size() const;
763 std::string string() const;
769 bool operator==(const PortAddress_t &rhs) const { return eq(rhs); }
775 bool eq(const PortAddress_t &rhs) const;
781 bool operator<(const PortAddress_t &rhs) const { return less(rhs); }
787 bool less(const PortAddress_t &rhs) const;
788};
801struct PTPText_t {
808 uint8_t lengthField;
809 std::string textField;
814 size_t size() const;
819 const char *string() const;
820};
845
847enum MsgParams_RcvAuth_e : uint8_t {
850 RCV_AUTH_MNG = (1 << 0),
857 RCV_AUTH_IGNORE = (1 << 3),
858};
859
916 virtual ~BaseMngTlv() = default;
917};
920 virtual ~BaseSigTlv() = default;
921};
938
939__PTPMGMT_NAMESPACE_END
940#else /* __cplusplus */
941#include "c/types.h"
942#endif /* __cplusplus */
943
944#endif /* __PTPMGMT_TYPES_H */
Provide Binary class.
Types, enumerators, and structers used by C interface to PTP management messages.
int64_t Integer48_t
Definition types.h:64
uint16_t UInteger16_t
Definition types.h:48
uint64_t UInteger48_t
Definition types.h:52
uint8_t Nibble_t
Definition types.h:44
uint8_t UInteger8_t
Definition types.h:46
uint64_t UInteger64_t
Definition types.h:56
long double float_nanoseconds
Definition types.h:76
uint32_t UInteger32_t
Definition types.h:50
int8_t Integer8_t
Definition types.h:58
uint8_t Octet_t
Definition types.h:70
int16_t Integer16_t
Definition types.h:60
int32_t Integer32_t
Definition types.h:62
int64_t Integer64_t
Definition types.h:68
long double float_seconds
Definition types.h:74
double Float64_t
Definition types.h:72
Definition bin.h:27
Management IDs enumerator.
Definition types.h:836
uint8_t alternatePriority1
Definition types.h:838
static size_t size()
PortIdentity_t acceptablePortIdentity
Definition types.h:837
Definition types.h:915
Definition types.h:919
Definition types.h:646
bool less(const ClockIdentity_t &rhs) const
bool operator==(const Binary &bin) const
Definition types.h:692
Octet_t v[8]
Definition types.h:647
bool eq(const Binary &bin) const
void clear(int val=0)
bool operator<(const ClockIdentity_t &rhs) const
Definition types.h:680
bool operator==(const ClockIdentity_t &rhs) const
Definition types.h:668
std::string string() const
static size_t size()
bool eq(const ClockIdentity_t &rhs) const
Definition types.h:790
UInteger8_t clockClass
Definition types.h:791
uint16_t offsetScaledLogVariance
Definition types.h:793
static size_t size()
clockAccuracy_e clockAccuracy
Definition types.h:792
Definition types.h:822
Timestamp_t faultTime
Definition types.h:824
PTPText_t faultName
Definition types.h:826
uint16_t faultRecordLength
Definition types.h:823
PTPText_t faultValue
Definition types.h:827
size_t size() const
faultRecord_e severityCode
Definition types.h:825
PTPText_t faultDescription
Definition types.h:828
Definition types.h:923
UInteger8_t priority2
Definition types.h:930
PortIdentity_t portIdentity
Definition types.h:924
ClockQuality_t clockQuality
Definition types.h:925
uint8_t selected
Definition types.h:926
linuxptpUnicastState_e portState
Definition types.h:928
UInteger8_t priority1
Definition types.h:929
PortAddress_t portAddress
Definition types.h:931
Definition types.h:861
uint8_t transportSpecific
Definition types.h:862
bool rcvSignaling
Definition types.h:872
bool isUnicast
Definition types.h:866
uint8_t domainNumber
Definition types.h:863
size_t countSigTlvs() const
bool useZeroGet
Definition types.h:871
PortIdentity_t target
Definition types.h:869
PortIdentity_t self_id
Definition types.h:870
void removeSigTlv(tlvType_e type)
bool filterSignaling
Definition types.h:873
uint8_t minorVersion
Definition types.h:865
bool isSigTlv(tlvType_e type) const
implementSpecific_e implementSpecific
Definition types.h:868
bool sendAuth
Definition types.h:879
uint8_t boundaryHops
Definition types.h:864
void allowSigTlv(tlvType_e type)
uint8_t rcvAuth
Definition types.h:885
bool rcvSMPTEOrg
Definition types.h:874
Definition types.h:801
uint8_t lengthField
Definition types.h:808
size_t size() const
const char * string() const
std::string textField
Definition types.h:809
Definition types.h:744
bool less(const PortAddress_t &rhs) const
bool operator==(const PortAddress_t &rhs) const
Definition types.h:769
size_t size() const
Binary addressField
Definition types.h:753
UInteger16_t addressLength
Definition types.h:752
std::string string() const
bool eq(const PortAddress_t &rhs) const
networkProtocol_e networkProtocol
Definition types.h:745
bool operator<(const PortAddress_t &rhs) const
Definition types.h:781
Definition types.h:701
bool operator==(const PortIdentity_t &rhs) const
Definition types.h:723
bool less(const PortIdentity_t &rhs) const
ClockIdentity_t clockIdentity
Definition types.h:702
static size_t size()
std::string string() const
bool eq(const PortIdentity_t &rhs) const
UInteger16_t portNumber
Definition types.h:703
bool operator<(const PortIdentity_t &rhs) const
Definition types.h:735
Definition types.h:395
bool isZero() const
float_nanoseconds getInterval() const
static size_t size()
int64_t getIntervalInt() const
Integer64_t scaledNanoseconds
Definition types.h:396
Definition types.h:419
Timestamp_t & add(float_seconds seconds)
Timestamp_t(const timespec &ts)
Timestamp_t & operator+=(const Timestamp_t &ts)
Definition types.h:578
uint64_t toNanoseconds() const
bool isZero() const
Timestamp_t(const timeval &tv)
bool eq(float_seconds seconds) const
Timestamp_t & add(const Timestamp_t &ts)
Timestamp_t(float_seconds seconds)
bool eq(const Timestamp_t &ts) const
bool operator==(float_seconds seconds) const
Definition types.h:533
std::string string() const
Timestamp_t(int64_t secs, uint32_t nsecs)
Timestamp_t & operator+=(float_seconds seconds)
Definition types.h:596
bool operator<(const Timestamp_t &ts) const
Definition types.h:548
void fromFloat(float_seconds seconds)
float_seconds toFloat() const
void toTimespec(timespec &ts) const
operator std::string() const
Definition types.h:443
UInteger48_t secondsField
Definition types.h:420
Timestamp_t & operator-(float_seconds seconds)
Definition types.h:626
void fromNanoseconds(uint64_t nanoseconds)
Timestamp_t & subt(float_seconds seconds)
static size_t size()
Timestamp_t & operator-=(const Timestamp_t &ts)
Definition types.h:614
bool operator==(const Timestamp_t &ts) const
Definition types.h:520
void toTimeval(timeval &tv) const
Timestamp_t & operator-(const Timestamp_t &ts)
Definition types.h:608
Timestamp_t & operator-=(float_seconds seconds)
Definition types.h:632
bool less(const Timestamp_t &ts) const
bool less(float_seconds seconds) const
Timestamp_t & operator+(const Timestamp_t &ts)
Definition types.h:572
Timestamp_t & operator+(float_seconds seconds)
Definition types.h:590
bool operator<(float_seconds seconds) const
Definition types.h:560
UInteger32_t nanosecondsField
Definition types.h:421
Timestamp_t & subt(const Timestamp_t &ts)
clockAccuracy_e
Definition types.h:229
@ Accurate_within_10ns
Definition types.h:238
@ Accurate_Unknown
Definition types.h:257
@ Accurate_more_10s
Definition types.h:256
@ Accurate_within_2_5ns
Definition types.h:237
@ Accurate_within_250ms
Definition types.h:253
@ Accurate_within_100ms
Definition types.h:252
@ Accurate_within_10s
Definition types.h:255
@ Accurate_within_10ps
Definition types.h:232
@ Accurate_within_25ns
Definition types.h:239
@ Accurate_within_2_5ps
Definition types.h:231
@ Accurate_within_25ms
Definition types.h:251
@ Accurate_within_1s
Definition types.h:254
@ Accurate_within_250ps
Definition types.h:235
@ Accurate_within_1ps
Definition types.h:230
@ Accurate_within_100us
Definition types.h:246
@ Accurate_within_2_5ms
Definition types.h:249
@ Accurate_within_1us
Definition types.h:242
@ Accurate_within_10us
Definition types.h:244
@ Accurate_within_25us
Definition types.h:245
@ Accurate_within_25ps
Definition types.h:233
@ Accurate_within_250ns
Definition types.h:241
@ Accurate_within_1ns
Definition types.h:236
@ Accurate_within_250us
Definition types.h:247
@ Accurate_within_100ns
Definition types.h:240
@ Accurate_within_1ms
Definition types.h:248
@ Accurate_within_100ps
Definition types.h:234
@ Accurate_within_2_5us
Definition types.h:243
@ Accurate_within_10ms
Definition types.h:250
managementErrorId_e
Definition types.h:199
@ NO_SUCH_ID
Definition types.h:201
@ NOT_SETABLE
Definition types.h:204
@ WRONG_VALUE
Definition types.h:203
@ NOT_SUPPORTED
Definition types.h:205
@ WRONG_LENGTH
Definition types.h:202
@ GENERAL_ERROR
Definition types.h:206
@ RESPONSE_TOO_BIG
Definition types.h:200
uint16_t UInteger16_t
Definition types.h:40
@ F_TTRA
Definition types.h:389
@ F_FTRA
Definition types.h:392
@ F_UTCV
Definition types.h:385
@ F_LI_61
Definition types.h:381
@ F_PTP
Definition types.h:387
@ F_LI_59
Definition types.h:383
linuxptpTimeStamp_e
Definition types.h:347
@ TS_SOFTWARE
Definition types.h:349
@ TS_P2P1STEP
Definition types.h:358
@ TS_LEGACY_HW
Definition types.h:354
@ TS_HARDWARE
Definition types.h:352
@ TS_ONESTEP
Definition types.h:356
uint64_t UInteger48_t
Definition types.h:44
msgType_e
Definition types.h:114
@ Pdelay_Resp_Follow_Up
Definition types.h:130
@ Pdelay_Resp
Definition types.h:123
@ Pdelay_Req
Definition types.h:121
@ Delay_Req
Definition types.h:119
@ Sync
Definition types.h:117
@ Follow_Up
Definition types.h:126
@ Signaling
Definition types.h:134
@ Management
Definition types.h:136
@ Announce
Definition types.h:132
@ Delay_Resp
Definition types.h:128
implementSpecific_e
Definition types.h:322
@ noImplementSpecific
Definition types.h:323
@ linuxptp
Definition types.h:324
delayMechanism_e
Definition types.h:299
@ E2E
Definition types.h:306
@ NO_MECHANISM
Definition types.h:310
@ SPECIAL
Definition types.h:317
@ COMMON_P2P
Definition types.h:315
@ AUTO
Definition types.h:304
@ P2P
Definition types.h:308
tlvType_e
Definition types.h:142
@ ENHANCED_ACCURACY_METRICS
Definition types.h:165
@ ALTERNATE_TIME_OFFSET_INDICATOR
Definition types.h:160
@ ACKNOWLEDGE_CANCEL_UNICAST_TRANSMISSION
Definition types.h:156
@ SLAVE_RX_SYNC_TIMING_DATA
Definition types.h:175
@ CANCEL_UNICAST_TRANSMISSION
Definition types.h:154
@ MANAGEMENT
Definition types.h:144
@ SLAVE_DELAY_TIMING_DATA_NP
Definition types.h:188
@ PROTOCOL_ADDRESS
Definition types.h:173
@ MANAGEMENT_ERROR_STATUS
Definition types.h:146
@ TLV_PAD
Definition types.h:183
@ PORT_COMMUNICATION_AVAILABILITY
Definition types.h:171
@ SLAVE_TX_EVENT_TIMESTAMPS
Definition types.h:179
@ AUTHENTICATION
Definition types.h:185
@ SLAVE_RX_SYNC_COMPUTED_DATA
Definition types.h:177
@ ORGANIZATION_EXTENSION
Definition types.h:148
@ ORGANIZATION_EXTENSION_PROPAGATE
Definition types.h:163
@ L1_SYNC
Definition types.h:169
@ ORGANIZATION_EXTENSION_DO_NOT_PROPAGATE
Definition types.h:167
@ REQUEST_UNICAST_TRANSMISSION
Definition types.h:150
@ CUMULATIVE_RATE_RATIO
Definition types.h:181
@ PATH_TRACE
Definition types.h:158
@ GRANT_UNICAST_TRANSMISSION
Definition types.h:152
portState_e
Definition types.h:284
@ FAULTY
Definition types.h:286
@ LISTENING
Definition types.h:288
@ UNCALIBRATED
Definition types.h:294
@ DISABLED
Definition types.h:287
@ TIME_RECEIVER
Definition types.h:296
@ PASSIVE
Definition types.h:293
@ PRE_MASTER
Definition types.h:289
@ INITIALIZING
Definition types.h:285
@ TIME_TRANSMITTER
Definition types.h:292
@ PRE_TIME_TRANSMITTER
Definition types.h:290
@ SLAVE
Definition types.h:295
@ MASTER
Definition types.h:291
uint8_t Nibble_t
Definition types.h:36
uint8_t UInteger8_t
Definition types.h:38
__PTPMGMT_NAMESPACE_BEGIN const int64_t INT48_MIN
Definition types.h:24
const int64_t INT48_MAX
Definition types.h:28
SMPTEmasterLockingStatus_e
Definition types.h:327
@ SMPTE_WARM_LOCKING
Definition types.h:341
@ SMPTE_COLD_LOCKING
Definition types.h:335
@ SMPTE_NOT_IN_USE
Definition types.h:328
@ SMPTE_FREE_RUN
Definition types.h:329
@ SMPTE_LOCKED
Definition types.h:342
linuxptpUnicastState_e
Definition types.h:372
@ UC_WAIT
Definition types.h:373
@ UC_HAVE_ANN
Definition types.h:374
@ UC_HAVE_SYDY
Definition types.h:376
@ UC_NEED_SYDY
Definition types.h:375
MsgParams_RcvAuth_e
Definition types.h:847
@ RCV_AUTH_SIG_LAST
Definition types.h:852
@ RCV_AUTH_MNG
Definition types.h:850
@ RCV_AUTH_ALL
Definition types.h:855
@ RCV_AUTH_IGNORE
Definition types.h:857
@ RCV_AUTH_NONE
Definition types.h:848
@ RCV_AUTH_SIG_ALL
Definition types.h:854
long double float_nanoseconds
Definition types.h:68
actionField_e
Definition types.h:191
@ GET
Definition types.h:192
@ ACKNOWLEDGE
Definition types.h:196
@ SET
Definition types.h:193
@ COMMAND
Definition types.h:195
@ RESPONSE
Definition types.h:194
linuxptpPowerProfileVersion_e
Definition types.h:363
@ IEEE_C37_238_VERSION_NONE
Definition types.h:365
@ IEEE_C37_238_VERSION_2017
Definition types.h:369
@ IEEE_C37_238_VERSION_2011
Definition types.h:367
uint32_t UInteger32_t
Definition types.h:42
networkProtocol_e
Definition types.h:220
@ UDP_IPv4
Definition types.h:221
@ ControlNet
Definition types.h:225
@ UDP_IPv6
Definition types.h:222
@ PROFINET
Definition types.h:226
@ IEEE_802_3
Definition types.h:223
@ DeviceNet
Definition types.h:224
uint8_t Octet_t
Definition types.h:62
int64_t Integer64_t
Definition types.h:60
MNG_PARSE_ERROR_e
Definition types.h:71
@ MNG_PARSE_ERROR_SIG
Definition types.h:77
@ MNG_PARSE_ERROR_ACTION
Definition types.h:97
@ MNG_PARSE_ERROR_UNSUPPORT
Definition types.h:99
@ MNG_PARSE_ERROR_AUTH_WRONG
Definition types.h:107
@ MNG_PARSE_ERROR_MEM
Definition types.h:101
@ MNG_PARSE_ERROR_TOO_SMALL
Definition types.h:89
@ MNG_PARSE_ERROR_SMPTE
Definition types.h:79
@ MNG_PARSE_ERROR_OK
Definition types.h:73
@ MNG_PARSE_ERROR_AUTH
Definition types.h:103
@ MNG_PARSE_ERROR_AUTH_NOKEY
Definition types.h:109
@ MNG_PARSE_ERROR_SIZE_MISS
Definition types.h:87
@ MNG_PARSE_ERROR_INVALID_TLV
Definition types.h:83
@ MNG_PARSE_ERROR_HEADER
Definition types.h:95
@ MNG_PARSE_ERROR_AUTH_NONE
Definition types.h:105
@ MNG_PARSE_ERROR_MSG
Definition types.h:75
@ MNG_PARSE_ERROR_INVALID_ID
Definition types.h:81
@ MNG_PARSE_ERROR_SIZE
Definition types.h:91
@ MNG_PARSE_ERROR_MISMATCH_TLV
Definition types.h:85
@ MNG_PARSE_ERROR_VAL
Definition types.h:93
const uint64_t UINT48_MAX
Definition types.h:32
long double float_seconds
Definition types.h:66
faultRecord_e
Definition types.h:260
@ F_Critical
Definition types.h:263
@ F_Informational
Definition types.h:267
@ F_Alert
Definition types.h:262
@ F_Warning
Definition types.h:265
@ F_Debug
Definition types.h:268
@ F_Error
Definition types.h:264
@ F_Emergency
Definition types.h:261
@ F_Notice
Definition types.h:266
clockType_e
Definition types.h:212
@ ordinaryClock
Definition types.h:213
@ managementClock
Definition types.h:217
@ boundaryClock
Definition types.h:214
@ p2pTransparentClock
Definition types.h:215
@ e2eTransparentClock
Definition types.h:216
const size_t sizeof_UInteger48_t
Definition types.h:46
timeSource_e
Definition types.h:271
@ ATOMIC_CLOCK
Definition types.h:272
@ PTP
Definition types.h:277
@ GPS
Definition types.h:274
@ SERIAL_TIME_CODE
Definition types.h:276
@ NTP
Definition types.h:278
@ TERRESTRIAL_RADIO
Definition types.h:275
@ INTERNAL_OSCILLATOR
Definition types.h:281
@ GNSS
Definition types.h:273
@ HAND_SET
Definition types.h:279
@ OTHER
Definition types.h:280
const size_t sizeof_Integer48_t
Definition types.h:58