libptpmgmt  1.4
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 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
26 typedef struct ptpmgmt_msg_t *ptpmgmt_msg;
27 
29 typedef const struct ptpmgmt_msg_t *const_ptpmgmt_msg;
30 
40 typedef bool (*ptpmgmt_msg_sig_callback)(void *cookie, const_ptpmgmt_msg msg,
41  enum ptpmgmt_tlvType_e tlvType, const void *tlv);
42 
47 struct ptpmgmt_msg_t {
49  void *_this;
50  struct ptpmgmt_PortIdentity_t _peer;
51  struct ptpmgmt_PortIdentity_t _target;
52  struct ptpmgmt_MsgParams _prms;
53  ptpmgmt_safile _sa;
55  const void *dataSend;
56  void *sendTlv;
57  void *data;
58  void *dataTbl;
59  void *dataSig1;
60  void *dataSig2;
61  void *dataSig3;
68  void (*free)(ptpmgmt_msg msg);
91  const char *section);
100  bool (*useAuth)(ptpmgmt_msg msg, const_ptpmgmt_safile sa, uint8_t spp,
101  uint32_t key);
109  bool (*changeAuth)(ptpmgmt_msg msg, uint8_t spp, uint32_t key);
116  bool (*changeAuthKey)(ptpmgmt_msg msg, uint32_t key);
122  bool (*disableAuth)(ptpmgmt_msg msg);
176  bool (*useConfig)(ptpmgmt_msg msg, const_ptpmgmt_cfg cfg, const char *section);
182  const char *(*err2str)(enum ptpmgmt_MNG_PARSE_ERROR_e err);
188  const char *(*type2str)(enum ptpmgmt_msgType_e type);
194  const char *(*tlv2str)(enum ptpmgmt_tlvType_e type);
200  const char *(*act2str)(enum ptpmgmt_actionField_e action);
206  const char *(*mng2str)(enum ptpmgmt_mng_vals_e id);
214  bool (*findMngID)(const char *str, enum ptpmgmt_mng_vals_e *id, bool exact);
220  const char *(*errId2str)(enum ptpmgmt_managementErrorId_e err);
226  const char *(*clkType2str)(enum ptpmgmt_clockType_e type);
232  const char *(*netProt2str)(enum ptpmgmt_networkProtocol_e protocol);
238  const char *(*clockAcc2str)(enum ptpmgmt_clockAccuracy_e value);
244  const char *(*faultRec2str)(enum ptpmgmt_faultRecord_e code);
250  const char *(*timeSrc2str)(enum ptpmgmt_timeSource_e type);
258  bool (*findTimeSrc)(const char *str, enum ptpmgmt_timeSource_e *type,
259  bool exact);
265  const char *(*portState2str)(enum ptpmgmt_portState_e state);
273  bool (*findPortState)(const char *str, enum ptpmgmt_portState_e *state,
274  bool caseSens);
280  const char *(*delayMech2str)(enum ptpmgmt_delayMechanism_e type);
288  bool (*findDelayMech)(const char *str, enum ptpmgmt_delayMechanism_e *type,
289  bool exact);
295  const char *(*smpteLck2str)(enum ptpmgmt_SMPTEmasterLockingStatus_e state);
301  const char *(*ts2str)(enum ptpmgmt_linuxptpTimeStamp_e type);
307  const char *(*pwr2str)(enum ptpmgmt_linuxptpPowerProfileVersion_e ver);
313  const char *(*us2str)(enum ptpmgmt_linuxptpUnicastState_e state);
319  bool (*is_LI_61)(uint8_t flags);
325  bool (*is_LI_59)(uint8_t flags);
331  bool (*is_UTCV)(uint8_t flags);
337  bool (*is_PTP)(uint8_t flags);
343  bool (*is_TTRA)(uint8_t flags);
349  bool (*is_FTRA)(uint8_t flags);
355  bool (*isEmpty)(enum ptpmgmt_mng_vals_e id);
377  bool (*setAction)(ptpmgmt_msg msg, enum ptpmgmt_actionField_e actionField,
378  enum ptpmgmt_mng_vals_e tlv_id, const void *dataSend);
398  enum ptpmgmt_MNG_PARSE_ERROR_e(*build)(const_ptpmgmt_msg msg, void *buf,
399  size_t bufSize, uint16_t sequence);
411  size_t (*getMsgLen)(const_ptpmgmt_msg msg);
422  /* Parsed message functions */
430  enum ptpmgmt_MNG_PARSE_ERROR_e(*parse)(const_ptpmgmt_msg msg, const void *buf,
431  ssize_t msgSize);
457  uint16_t (*getSequence)(const_ptpmgmt_msg msg);
463  const struct ptpmgmt_PortIdentity_t *(*getPeer)(ptpmgmt_msg msg);
469  const struct ptpmgmt_PortIdentity_t *(*getTarget)(ptpmgmt_msg msg);
476  uint32_t (*getSdoId)(const_ptpmgmt_msg msg);
503  const void *(*getData)(ptpmgmt_msg msg);
514  const void *(*getSendData)(const_ptpmgmt_msg msg);
528  const char *(*getErrDisplay)(const_ptpmgmt_msg msg);
562  bool (*traversSigTlvs)(ptpmgmt_msg msg, void *cookie,
563  ptpmgmt_msg_sig_callback callback);
576  const void *(*getSigTlv)(ptpmgmt_msg msg, size_t position);
583  enum ptpmgmt_tlvType_e(*getSigTlvType)(const_ptpmgmt_msg msg, size_t position);
593  size_t position);
602  const void *(*getSigMngTlv)(ptpmgmt_msg msg, size_t position);
603 };
604 
622 const char *ptpmgmt_msg_tlv2str(enum ptpmgmt_tlvType_e type);
642 bool ptpmgmt_msg_findMngID(const char *str, enum ptpmgmt_mng_vals_e *id,
643  bool exact);
687 bool ptpmgmt_msg_findTimeSrc(const char *str, enum ptpmgmt_timeSource_e *type,
688  bool exact);
702 bool ptpmgmt_msg_findPortState(const char *str, enum ptpmgmt_portState_e *state,
703  bool caseSens);
717 bool ptpmgmt_msg_findDelayMech(const char *str,
718  enum ptpmgmt_delayMechanism_e *type, bool exact);
725  state);
749 bool ptpmgmt_msg_is_LI_61(uint8_t flags);
755 bool ptpmgmt_msg_is_LI_59(uint8_t flags);
761 bool ptpmgmt_msg_is_UTCV(uint8_t flags);
767 bool ptpmgmt_msg_is_PTP(uint8_t flags);
773 bool ptpmgmt_msg_is_TTRA(uint8_t flags);
779 bool ptpmgmt_msg_is_FTRA(uint8_t flags);
786 
792 
799 
800 #ifdef __cplusplus
801 }
802 #endif
803 
804 #endif /* __PTPMGMT_C_MSG_H */
C interface to configuration class.
const struct ptpmgmt_safile_t * const_ptpmgmt_safile
Definition: cfg.h:38
ptpmgmt_mng_vals_e
Management TLVs ID.
Definition: mngIds.h:28
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:26
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:29
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:40
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:355
ptpmgmt_linuxptpPowerProfileVersion_e
Definition: types.h:371
ptpmgmt_faultRecord_e
Definition: types.h:268
ptpmgmt_networkProtocol_e
Definition: types.h:228
ptpmgmt_MNG_PARSE_ERROR_e
Definition: types.h:79
ptpmgmt_msgType_e
Definition: types.h:122
ptpmgmt_managementErrorId_e
Definition: types.h:207
struct ptpmgmt_MsgParams * ptpmgmt_pMsgParams
Definition: types.h:494
ptpmgmt_portState_e
Definition: types.h:292
ptpmgmt_tlvType_e
Definition: types.h:150
ptpmgmt_linuxptpUnicastState_e
Definition: types.h:380
ptpmgmt_delayMechanism_e
Definition: types.h:307
ptpmgmt_SMPTEmasterLockingStatus_e
Definition: types.h:335
ptpmgmt_timeSource_e
Definition: types.h:279
ptpmgmt_clockAccuracy_e
Definition: types.h:237
ptpmgmt_clockType_e
Definition: types.h:220
ptpmgmt_actionField_e
Definition: types.h:199
Definition: types.h:506
Definition: types.h:416
Definition: cfg.h:44
Definition: msg.h:47
uint8_t(* getPTPProfileSpecific)(const_ptpmgmt_msg msg)
Definition: msg.h:451
bool(* useAuth)(ptpmgmt_msg msg, const_ptpmgmt_safile sa, uint8_t spp, uint32_t key)
Definition: msg.h:100
enum ptpmgmt_tlvType_e(* getMngType)(const_ptpmgmt_msg msg)
Definition: msg.h:553
uint32_t(* getSdoId)(const_ptpmgmt_msg msg)
Definition: msg.h:476
bool(* isLastMsgSig)(const_ptpmgmt_msg msg)
Definition: msg.h:534
bool(* is_UTCV)(uint8_t flags)
Definition: msg.h:331
bool(* is_LI_59)(uint8_t flags)
Definition: msg.h:325
bool(* useConfig)(ptpmgmt_msg msg, const_ptpmgmt_cfg cfg, const char *section)
Definition: msg.h:176
void(* clearData)(const_ptpmgmt_msg msg)
Definition: msg.h:383
bool(* is_LI_61)(uint8_t flags)
Definition: msg.h:319
bool(* isEmpty)(enum ptpmgmt_mng_vals_e id)
Definition: msg.h:355
enum ptpmgmt_mng_vals_e(* getSigMngTlvType)(const_ptpmgmt_msg msg, size_t position)
Definition: msg.h:592
bool(* isValidId)(const_ptpmgmt_msg msg, enum ptpmgmt_mng_vals_e id)
Definition: msg.h:363
bool(* updateParams)(ptpmgmt_msg msg, ptpmgmt_cpMsgParams prms)
Definition: msg.h:81
bool(* isUnicast)(const_ptpmgmt_msg msg)
Definition: msg.h:444
void(* free)(ptpmgmt_msg msg)
Definition: msg.h:68
uint8_t(* getMinorVersionPTP)(const_ptpmgmt_msg msg)
Definition: msg.h:494
enum ptpmgmt_mng_vals_e(* getTlvId)(const_ptpmgmt_msg msg)
Definition: msg.h:150
bool(* changeAuth)(ptpmgmt_msg msg, uint8_t spp, uint32_t key)
Definition: msg.h:109
bool(* findPortState)(const char *str, enum ptpmgmt_portState_e *state, bool caseSens)
Definition: msg.h:273
size_t(* getSigTlvsCount)(const_ptpmgmt_msg msg)
Definition: msg.h:569
enum ptpmgmt_MNG_PARSE_ERROR_e(* parse)(const_ptpmgmt_msg msg, const void *buf, ssize_t msgSize)
Definition: msg.h:430
bool(* findTimeSrc)(const char *str, enum ptpmgmt_timeSource_e *type, bool exact)
Definition: msg.h:258
enum ptpmgmt_tlvType_e(* getSigTlvType)(const_ptpmgmt_msg msg, size_t position)
Definition: msg.h:583
enum ptpmgmt_actionField_e(* getReplyAction)(const_ptpmgmt_msg msg)
Definition: msg.h:438
bool(* traversSigTlvs)(ptpmgmt_msg msg, void *cookie, ptpmgmt_msg_sig_callback callback)
Definition: msg.h:562
bool(* disableAuth)(ptpmgmt_msg msg)
Definition: msg.h:122
bool(* findMngID)(const char *str, enum ptpmgmt_mng_vals_e *id, bool exact)
Definition: msg.h:214
uint8_t(* getVersionPTP)(const_ptpmgmt_msg msg)
Definition: msg.h:488
bool(* isLastMsgSMPTE)(const_ptpmgmt_msg msg)
Definition: msg.h:540
bool(* isAllClocks)(const_ptpmgmt_msg msg)
Definition: msg.h:167
enum ptpmgmt_msgType_e(* getType)(const_ptpmgmt_msg msg)
Definition: msg.h:546
bool(* haveAuth)(const_ptpmgmt_msg msg)
Definition: msg.h:144
size_t(* getMsgLen)(const_ptpmgmt_msg msg)
Definition: msg.h:411
bool(* is_FTRA)(uint8_t flags)
Definition: msg.h:349
bool(* useAuth_cfg)(ptpmgmt_msg msg, const_ptpmgmt_cfg cfg, const char *section)
Definition: msg.h:90
ptpmgmt_pMsgParams(* getParams)(ptpmgmt_msg msg)
Definition: msg.h:74
bool(* is_TTRA)(uint8_t flags)
Definition: msg.h:343
enum ptpmgmt_managementErrorId_e(* getErrId)(const_ptpmgmt_msg msg)
Definition: msg.h:521
enum ptpmgmt_MNG_PARSE_ERROR_e(* build)(const_ptpmgmt_msg msg, void *buf, size_t bufSize, uint16_t sequence)
Definition: msg.h:398
const_ptpmgmt_safile(* getSa)(ptpmgmt_msg msg)
Definition: msg.h:138
enum ptpmgmt_mng_vals_e(* getBuildTlvId)(const_ptpmgmt_msg msg)
Definition: msg.h:156
ssize_t(* getMsgPlanedLen)(const_ptpmgmt_msg msg)
Definition: msg.h:421
enum ptpmgmt_actionField_e(* getSendAction)(const_ptpmgmt_msg msg)
Definition: msg.h:405
void(* setAllClocks)(const_ptpmgmt_msg msg)
Definition: msg.h:161
uint16_t(* getSequence)(const_ptpmgmt_msg msg)
Definition: msg.h:457
bool(* setAction)(ptpmgmt_msg msg, enum ptpmgmt_actionField_e actionField, enum ptpmgmt_mng_vals_e tlv_id, const void *dataSend)
Definition: msg.h:377
uint8_t(* getDomainNumber)(const_ptpmgmt_msg msg)
Definition: msg.h:482
bool(* changeAuthKey)(ptpmgmt_msg msg, uint32_t key)
Definition: msg.h:116
uint32_t(* usedAuthKeyID)(const_ptpmgmt_msg msg)
Definition: msg.h:133
bool(* findDelayMech)(const char *str, enum ptpmgmt_delayMechanism_e *type, bool exact)
Definition: msg.h:288
bool(* is_PTP)(uint8_t flags)
Definition: msg.h:337
int(* usedAuthSppID)(const_ptpmgmt_msg msg)
Definition: msg.h:127
Definition: cfg.h:295