libptpmgmt  1.3
libptpmgmt library that provides the functionality of linuxptp pmc
msg.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 
14 #ifndef __PTPMGMT_C_MSG_H
15 #define __PTPMGMT_C_MSG_H
16 
17 #include "c/cfg.h"
18 #include "c/proc.h"
19 #include "c/sig.h"
20 
22 typedef struct ptpmgmt_msg_t *ptpmgmt_msg;
23 
25 typedef const struct ptpmgmt_msg_t *const_ptpmgmt_msg;
26 
36 typedef bool (*ptpmgmt_msg_sig_callback)(void *cookie, const_ptpmgmt_msg msg,
37  enum ptpmgmt_tlvType_e tlvType, const void *tlv);
38 
43 struct ptpmgmt_msg_t {
45  void *_this;
46  struct ptpmgmt_PortIdentity_t _peer;
47  struct ptpmgmt_PortIdentity_t _target;
48  struct ptpmgmt_MsgParams _prms;
49  ptpmgmt_safile _sa;
51  const void *dataSend;
52  void *sendTlv;
53  void *data;
54  void *dataTbl;
55  void *dataSig1;
56  void *dataSig2;
57  void *dataSig3;
64  void (*free)(ptpmgmt_msg msg);
87  const char *section);
96  bool (*useAuth)(ptpmgmt_msg msg, const_ptpmgmt_safile sa, uint8_t spp,
97  uint32_t key);
105  bool (*changeAuth)(ptpmgmt_msg msg, uint8_t spp, uint32_t key);
112  bool (*changeAuthKey)(ptpmgmt_msg msg, uint32_t key);
118  bool (*disableAuth)(ptpmgmt_msg msg);
172  bool (*useConfig)(ptpmgmt_msg msg, const_ptpmgmt_cfg cfg, const char *section);
178  const char *(*err2str)(enum ptpmgmt_MNG_PARSE_ERROR_e err);
184  const char *(*type2str)(enum ptpmgmt_msgType_e type);
190  const char *(*tlv2str)(enum ptpmgmt_tlvType_e type);
196  const char *(*act2str)(enum ptpmgmt_actionField_e action);
202  const char *(*mng2str)(enum ptpmgmt_mng_vals_e id);
210  bool (*findMngID)(const char *str, enum ptpmgmt_mng_vals_e *id, bool exact);
216  const char *(*errId2str)(enum ptpmgmt_managementErrorId_e err);
222  const char *(*clkType2str)(enum ptpmgmt_clockType_e type);
228  const char *(*netProt2str)(enum ptpmgmt_networkProtocol_e protocol);
234  const char *(*clockAcc2str)(enum ptpmgmt_clockAccuracy_e value);
240  const char *(*faultRec2str)(enum ptpmgmt_faultRecord_e code);
246  const char *(*timeSrc2str)(enum ptpmgmt_timeSource_e type);
254  bool (*findTimeSrc)(const char *str, enum ptpmgmt_timeSource_e *type,
255  bool exact);
261  const char *(*portState2str)(enum ptpmgmt_portState_e state);
269  bool (*findPortState)(const char *str, enum ptpmgmt_portState_e *state,
270  bool caseSens);
276  const char *(*delayMech2str)(enum ptpmgmt_delayMechanism_e type);
284  bool (*findDelayMech)(const char *str, enum ptpmgmt_delayMechanism_e *type,
285  bool exact);
291  const char *(*smpteLck2str)(enum ptpmgmt_SMPTEmasterLockingStatus_e state);
297  const char *(*ts2str)(enum ptpmgmt_linuxptpTimeStamp_e type);
303  const char *(*pwr2str)(enum ptpmgmt_linuxptpPowerProfileVersion_e ver);
309  const char *(*us2str)(enum ptpmgmt_linuxptpUnicastState_e state);
315  bool (*is_LI_61)(uint8_t flags);
321  bool (*is_LI_59)(uint8_t flags);
327  bool (*is_UTCV)(uint8_t flags);
333  bool (*is_PTP)(uint8_t flags);
339  bool (*is_TTRA)(uint8_t flags);
345  bool (*is_FTRA)(uint8_t flags);
351  bool (*isEmpty)(enum ptpmgmt_mng_vals_e id);
373  bool (*setAction)(ptpmgmt_msg msg, enum ptpmgmt_actionField_e actionField,
374  enum ptpmgmt_mng_vals_e tlv_id, const void *dataSend);
394  enum ptpmgmt_MNG_PARSE_ERROR_e(*build)(const_ptpmgmt_msg msg, void *buf,
395  size_t bufSize, uint16_t sequence);
407  size_t (*getMsgLen)(const_ptpmgmt_msg msg);
418  /* Parsed message functions */
426  enum ptpmgmt_MNG_PARSE_ERROR_e(*parse)(const_ptpmgmt_msg msg, const void *buf,
427  ssize_t msgSize);
453  uint16_t (*getSequence)(const_ptpmgmt_msg msg);
459  const struct ptpmgmt_PortIdentity_t *(*getPeer)(ptpmgmt_msg msg);
465  const struct ptpmgmt_PortIdentity_t *(*getTarget)(ptpmgmt_msg msg);
472  uint32_t (*getSdoId)(const_ptpmgmt_msg msg);
499  const void *(*getData)(ptpmgmt_msg msg);
510  const void *(*getSendData)(const_ptpmgmt_msg msg);
524  const char *(*getErrDisplay)(const_ptpmgmt_msg msg);
558  bool (*traversSigTlvs)(ptpmgmt_msg msg, void *cookie,
559  ptpmgmt_msg_sig_callback callback);
572  const void *(*getSigTlv)(ptpmgmt_msg msg, size_t position);
579  enum ptpmgmt_tlvType_e(*getSigTlvType)(const_ptpmgmt_msg msg, size_t position);
589  size_t position);
598  const void *(*getSigMngTlv)(ptpmgmt_msg msg, size_t position);
599 };
600 
618 const char *ptpmgmt_msg_tlv2str(enum ptpmgmt_tlvType_e type);
638 bool ptpmgmt_msg_findMngID(const char *str, enum ptpmgmt_mng_vals_e *id,
639  bool exact);
683 bool ptpmgmt_msg_findTimeSrc(const char *str, enum ptpmgmt_timeSource_e *type,
684  bool exact);
698 bool ptpmgmt_msg_findPortState(const char *str, enum ptpmgmt_portState_e *state,
699  bool caseSens);
713 bool ptpmgmt_msg_findDelayMech(const char *str,
714  enum ptpmgmt_delayMechanism_e *type, bool exact);
721  state);
745 bool ptpmgmt_msg_is_LI_61(uint8_t flags);
751 bool ptpmgmt_msg_is_LI_59(uint8_t flags);
757 bool ptpmgmt_msg_is_UTCV(uint8_t flags);
763 bool ptpmgmt_msg_is_PTP(uint8_t flags);
769 bool ptpmgmt_msg_is_TTRA(uint8_t flags);
775 bool ptpmgmt_msg_is_FTRA(uint8_t flags);
782 
788 
795 
796 #endif /* __PTPMGMT_C_MSG_H */
C interface to configuration class.
const struct ptpmgmt_safile_t * const_ptpmgmt_safile
Definition: cfg.h:36
ptpmgmt_mng_vals_e
Management TLVs ID.
Definition: mngIds.h:24
ptpmgmt_msg ptpmgmt_msg_alloc()
bool ptpmgmt_msg_is_TTRA(uint8_t flags)
const char * ptpmgmt_msg_portState2str(enum ptpmgmt_portState_e state)
const char * ptpmgmt_msg_netProt2str(enum ptpmgmt_networkProtocol_e protocol)
const char * ptpmgmt_msg_clkType2str(enum ptpmgmt_clockType_e type)
const char * ptpmgmt_msg_delayMech2str(enum ptpmgmt_delayMechanism_e type)
struct ptpmgmt_msg_t * ptpmgmt_msg
Definition: msg.h:22
const char * ptpmgmt_msg_mng2str(enum ptpmgmt_mng_vals_e id)
const char * ptpmgmt_msg_us2str(enum ptpmgmt_linuxptpUnicastState_e state)
bool ptpmgmt_msg_is_LI_61(uint8_t flags)
const char * ptpmgmt_msg_errId2str(enum ptpmgmt_managementErrorId_e err)
const char * ptpmgmt_msg_timeSrc2str(enum ptpmgmt_timeSource_e type)
bool ptpmgmt_msg_findPortState(const char *str, enum ptpmgmt_portState_e *state, bool caseSens)
bool ptpmgmt_msg_is_FTRA(uint8_t flags)
const struct ptpmgmt_msg_t * const_ptpmgmt_msg
Definition: msg.h:25
const char * ptpmgmt_msg_pwr2str(enum ptpmgmt_linuxptpPowerProfileVersion_e ver)
const char * ptpmgmt_msg_smpteLck2str(enum ptpmgmt_SMPTEmasterLockingStatus_e state)
const char * ptpmgmt_msg_clockAcc2str(enum ptpmgmt_clockAccuracy_e value)
bool ptpmgmt_msg_is_PTP(uint8_t flags)
const char * ptpmgmt_msg_err2str(enum ptpmgmt_MNG_PARSE_ERROR_e err)
bool ptpmgmt_msg_is_LI_59(uint8_t flags)
bool ptpmgmt_msg_isEmpty(enum ptpmgmt_mng_vals_e id)
bool ptpmgmt_msg_findDelayMech(const char *str, enum ptpmgmt_delayMechanism_e *type, bool exact)
const char * ptpmgmt_msg_ts2str(enum ptpmgmt_linuxptpTimeStamp_e type)
bool ptpmgmt_msg_findTimeSrc(const char *str, enum ptpmgmt_timeSource_e *type, bool exact)
ptpmgmt_msg ptpmgmt_msg_alloc_prms(ptpmgmt_cpMsgParams prms)
bool ptpmgmt_msg_findMngID(const char *str, enum ptpmgmt_mng_vals_e *id, bool exact)
bool(* ptpmgmt_msg_sig_callback)(void *cookie, const_ptpmgmt_msg msg, enum ptpmgmt_tlvType_e tlvType, const void *tlv)
Definition: msg.h:36
bool ptpmgmt_msg_is_UTCV(uint8_t flags)
const char * ptpmgmt_msg_act2str(enum ptpmgmt_actionField_e action)
const char * ptpmgmt_msg_tlv2str(enum ptpmgmt_tlvType_e type)
const char * ptpmgmt_msg_type2str(enum ptpmgmt_msgType_e type)
const char * ptpmgmt_msg_faultRec2str(enum ptpmgmt_faultRecord_e code)
PTP management TLV structures.
PTP signalling TLV structures.
ptpmgmt_linuxptpTimeStamp_e
Definition: types.h:351
ptpmgmt_linuxptpPowerProfileVersion_e
Definition: types.h:367
ptpmgmt_faultRecord_e
Definition: types.h:264
ptpmgmt_networkProtocol_e
Definition: types.h:224
ptpmgmt_MNG_PARSE_ERROR_e
Definition: types.h:75
ptpmgmt_msgType_e
Definition: types.h:118
ptpmgmt_managementErrorId_e
Definition: types.h:203
struct ptpmgmt_MsgParams * ptpmgmt_pMsgParams
Definition: types.h:490
ptpmgmt_portState_e
Definition: types.h:288
ptpmgmt_tlvType_e
Definition: types.h:146
ptpmgmt_linuxptpUnicastState_e
Definition: types.h:376
ptpmgmt_delayMechanism_e
Definition: types.h:303
ptpmgmt_SMPTEmasterLockingStatus_e
Definition: types.h:331
ptpmgmt_timeSource_e
Definition: types.h:275
ptpmgmt_clockAccuracy_e
Definition: types.h:233
ptpmgmt_clockType_e
Definition: types.h:216
ptpmgmt_actionField_e
Definition: types.h:195
Definition: types.h:502
Definition: types.h:412
Definition: cfg.h:42
Definition: msg.h:43
uint8_t(* getPTPProfileSpecific)(const_ptpmgmt_msg msg)
Definition: msg.h:447
bool(* useAuth)(ptpmgmt_msg msg, const_ptpmgmt_safile sa, uint8_t spp, uint32_t key)
Definition: msg.h:96
enum ptpmgmt_tlvType_e(* getMngType)(const_ptpmgmt_msg msg)
Definition: msg.h:549
uint32_t(* getSdoId)(const_ptpmgmt_msg msg)
Definition: msg.h:472
bool(* isLastMsgSig)(const_ptpmgmt_msg msg)
Definition: msg.h:530
bool(* is_UTCV)(uint8_t flags)
Definition: msg.h:327
bool(* is_LI_59)(uint8_t flags)
Definition: msg.h:321
bool(* useConfig)(ptpmgmt_msg msg, const_ptpmgmt_cfg cfg, const char *section)
Definition: msg.h:172
void(* clearData)(const_ptpmgmt_msg msg)
Definition: msg.h:379
bool(* is_LI_61)(uint8_t flags)
Definition: msg.h:315
bool(* isEmpty)(enum ptpmgmt_mng_vals_e id)
Definition: msg.h:351
enum ptpmgmt_mng_vals_e(* getSigMngTlvType)(const_ptpmgmt_msg msg, size_t position)
Definition: msg.h:588
bool(* isValidId)(const_ptpmgmt_msg msg, enum ptpmgmt_mng_vals_e id)
Definition: msg.h:359
bool(* updateParams)(ptpmgmt_msg msg, ptpmgmt_cpMsgParams prms)
Definition: msg.h:77
bool(* isUnicast)(const_ptpmgmt_msg msg)
Definition: msg.h:440
void(* free)(ptpmgmt_msg msg)
Definition: msg.h:64
uint8_t(* getMinorVersionPTP)(const_ptpmgmt_msg msg)
Definition: msg.h:490
enum ptpmgmt_mng_vals_e(* getTlvId)(const_ptpmgmt_msg msg)
Definition: msg.h:146
bool(* changeAuth)(ptpmgmt_msg msg, uint8_t spp, uint32_t key)
Definition: msg.h:105
bool(* findPortState)(const char *str, enum ptpmgmt_portState_e *state, bool caseSens)
Definition: msg.h:269
size_t(* getSigTlvsCount)(const_ptpmgmt_msg msg)
Definition: msg.h:565
enum ptpmgmt_MNG_PARSE_ERROR_e(* parse)(const_ptpmgmt_msg msg, const void *buf, ssize_t msgSize)
Definition: msg.h:426
bool(* findTimeSrc)(const char *str, enum ptpmgmt_timeSource_e *type, bool exact)
Definition: msg.h:254
enum ptpmgmt_tlvType_e(* getSigTlvType)(const_ptpmgmt_msg msg, size_t position)
Definition: msg.h:579
enum ptpmgmt_actionField_e(* getReplyAction)(const_ptpmgmt_msg msg)
Definition: msg.h:434
bool(* traversSigTlvs)(ptpmgmt_msg msg, void *cookie, ptpmgmt_msg_sig_callback callback)
Definition: msg.h:558
bool(* disableAuth)(ptpmgmt_msg msg)
Definition: msg.h:118
bool(* findMngID)(const char *str, enum ptpmgmt_mng_vals_e *id, bool exact)
Definition: msg.h:210
uint8_t(* getVersionPTP)(const_ptpmgmt_msg msg)
Definition: msg.h:484
bool(* isLastMsgSMPTE)(const_ptpmgmt_msg msg)
Definition: msg.h:536
bool(* isAllClocks)(const_ptpmgmt_msg msg)
Definition: msg.h:163
enum ptpmgmt_msgType_e(* getType)(const_ptpmgmt_msg msg)
Definition: msg.h:542
bool(* haveAuth)(const_ptpmgmt_msg msg)
Definition: msg.h:140
size_t(* getMsgLen)(const_ptpmgmt_msg msg)
Definition: msg.h:407
bool(* is_FTRA)(uint8_t flags)
Definition: msg.h:345
bool(* useAuth_cfg)(ptpmgmt_msg msg, const_ptpmgmt_cfg cfg, const char *section)
Definition: msg.h:86
ptpmgmt_pMsgParams(* getParams)(ptpmgmt_msg msg)
Definition: msg.h:70
bool(* is_TTRA)(uint8_t flags)
Definition: msg.h:339
enum ptpmgmt_managementErrorId_e(* getErrId)(const_ptpmgmt_msg msg)
Definition: msg.h:517
enum ptpmgmt_MNG_PARSE_ERROR_e(* build)(const_ptpmgmt_msg msg, void *buf, size_t bufSize, uint16_t sequence)
Definition: msg.h:394
const_ptpmgmt_safile(* getSa)(ptpmgmt_msg msg)
Definition: msg.h:134
enum ptpmgmt_mng_vals_e(* getBuildTlvId)(const_ptpmgmt_msg msg)
Definition: msg.h:152
ssize_t(* getMsgPlanedLen)(const_ptpmgmt_msg msg)
Definition: msg.h:417
enum ptpmgmt_actionField_e(* getSendAction)(const_ptpmgmt_msg msg)
Definition: msg.h:401
void(* setAllClocks)(const_ptpmgmt_msg msg)
Definition: msg.h:157
uint16_t(* getSequence)(const_ptpmgmt_msg msg)
Definition: msg.h:453
bool(* setAction)(ptpmgmt_msg msg, enum ptpmgmt_actionField_e actionField, enum ptpmgmt_mng_vals_e tlv_id, const void *dataSend)
Definition: msg.h:373
uint8_t(* getDomainNumber)(const_ptpmgmt_msg msg)
Definition: msg.h:478
bool(* changeAuthKey)(ptpmgmt_msg msg, uint32_t key)
Definition: msg.h:112
uint32_t(* usedAuthKeyID)(const_ptpmgmt_msg msg)
Definition: msg.h:129
bool(* findDelayMech)(const char *str, enum ptpmgmt_delayMechanism_e *type, bool exact)
Definition: msg.h:284
bool(* is_PTP)(uint8_t flags)
Definition: msg.h:333
int(* usedAuthSppID)(const_ptpmgmt_msg msg)
Definition: msg.h:123
Definition: cfg.h:293