libptpmgmt 2.0
libptpmgmt library that provides the functionality of linuxptp pmc
Loading...
Searching...
No Matches
json.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_JSON_H
13#define __PTPMGMT_JSON_H
14
15#ifdef __cplusplus
16#include "msg.h"
17
18__PTPMGMT_NAMESPACE_BEGIN
19
26std::string msg2json(const Message &message, int indent = 0);
27
35std::string tlv2json(mng_vals_e managementId, const BaseMngTlv *tlv,
36 int indent = 0);
37
44{
45 private:
46 std::unique_ptr<BaseMngTlv> m_tlvData;
47 /* Mandatory */
48 mng_vals_e m_managementId = NULL_PTP_MANAGEMENT;
49 actionField_e m_action = GET;
50 /* optional */
51 enum {
52 have_isUnicast,
53 have_PTPProfileSpecific,
54 have_domainNumber,
55 have_versionPTP,
56 have_minorVersionPTP,
57 have_sequenceId,
58 have_sdoId,
59 have_srcPort,
60 have_dstPort,
61 have_limit,
62 };
63 bool m_have[have_limit] = { false };
64 bool m_isUnicast = false;
65 uint8_t m_PTPProfileSpecific = 0, m_domainNumber = 0,
66 m_versionPTP = 2, m_minorVersionPTP = 1;
67 uint16_t m_sequenceId = 0;
68 uint32_t m_sdoId = 0;
69 PortIdentity_t m_srcPort = {{0}, 0}, m_dstPort = {{0}, 0};
70 public:
76 bool fromJson(const std::string &json);
87 const BaseMngTlv *dataField() const;
97 bool isUnicast() const;
102 bool haveIsUnicast() const;
107 uint8_t PTPProfileSpecific() const;
117 uint8_t domainNumber() const;
122 bool haveDomainNumber() const;
127 uint8_t versionPTP() const;
132 bool haveVersionPTP() const;
137 uint8_t minorVersionPTP() const;
147 uint16_t sequenceId() const;
152 bool haveSequenceId() const;
157 uint32_t sdoId() const;
162 bool haveSdoId() const;
167 const PortIdentity_t &srcPort() const;
172 bool haveSrcPort() const;
177 const PortIdentity_t &dstPort() const;
182 bool haveDstPort() const;
188 bool setAction(Message &message) const;
189};
190
191__PTPMGMT_NAMESPACE_END
192#else /* __cplusplus */
193#include "c/json.h"
194#endif /* __cplusplus */
195
196#endif /* __PTPMGMT_JSON_H */
Convert a management or a signalling message to JSON.
Definition json.h:44
const PortIdentity_t & dstPort() const
mng_vals_e managementId() const
bool haveVersionPTP() const
uint32_t sdoId() const
bool haveSdoId() const
actionField_e actionField() const
bool haveDomainNumber() const
const BaseMngTlv * dataField() const
uint8_t PTPProfileSpecific() const
uint8_t versionPTP() const
bool havePTPProfileSpecific() const
uint8_t domainNumber() const
bool isUnicast() const
bool haveSequenceId() const
bool fromJson(const std::string &json)
bool haveSrcPort() const
bool setAction(Message &message) const
const PortIdentity_t & srcPort() const
uint16_t sequenceId() const
bool haveMinorVersionPTP() const
bool haveDstPort() const
uint8_t minorVersionPTP() const
bool haveIsUnicast() const
Handle PTP management message.
Definition msg.h:215
__PTPMGMT_NAMESPACE_BEGIN std::string msg2json(const Message &message, int indent=0)
std::string tlv2json(mng_vals_e managementId, const BaseMngTlv *tlv, int indent=0)
mng_vals_e
Management TLVs ID.
Definition mngIds.h:29
Create and parse PTP management messages.
Definition types.h:915
Definition types.h:701
actionField_e
Definition types.h:191
@ GET
Definition types.h:192