libptpmgmt  1.3
libptpmgmt library that provides the functionality of linuxptp pmc
Classes | Typedefs | Functions
json.h File Reference

Convert a management or a signalling message to JSON. More...

#include "c/msg.h"
Include dependency graph for json.h:

Go to the source code of this file.

Classes

struct  ptpmgmt_json_t
 

Typedefs

typedef struct ptpmgmt_json_tptpmgmt_json
 
typedef const struct ptpmgmt_json_tconst_ptpmgmt_json
 

Functions

char * ptpmgmt_json_msg2json (const_ptpmgmt_msg message, int indent)
 
char * ptpmgmt_json_tlv2json (enum ptpmgmt_mng_vals_e managementId, const void *tlv, int indent)
 
bool ptpmgmt_json_selectLib (const char *libName)
 
const char * ptpmgmt_json_loadLibrary ()
 
bool ptpmgmt_json_isLibShared ()
 
ptpmgmt_json ptpmgmt_json_alloc ()
 

Detailed Description

Convert a management or a signalling message to JSON.

Author
Erez Geva <ErezGeva2@gmail.com>

Typedef Documentation

◆ const_ptpmgmt_json

typedef const struct ptpmgmt_json_t* const_ptpmgmt_json

pointer to constant ptpmgmt json structure

◆ ptpmgmt_json

typedef struct ptpmgmt_json_t* ptpmgmt_json

pointer to ptpmgmt json structure

Function Documentation

◆ ptpmgmt_json_alloc()

ptpmgmt_json ptpmgmt_json_alloc ( )

Alocate new json structure

Returns
new json structure or null in case of error

◆ ptpmgmt_json_isLibShared()

bool ptpmgmt_json_isLibShared ( )

Determine if library is shared or static

Returns
true if library is shared library

◆ ptpmgmt_json_loadLibrary()

const char* ptpmgmt_json_loadLibrary ( )

Return shared library name

Returns
shared library name or nullptr in not
Note
When using static link, function return the shared library name of the same code!

◆ ptpmgmt_json_msg2json()

char* ptpmgmt_json_msg2json ( const_ptpmgmt_msg  message,
int  indent 
)

Convert Message to JSON string

Parameters
[in]messagereceived from PTP entity
[in]indentbase indent for the JSON string
Returns
JSON string
Note
The caller MUST free the string after use!

◆ ptpmgmt_json_selectLib()

bool ptpmgmt_json_selectLib ( const char *  libName)

Try to load the a specific library

Parameters
[in]libNamepartial library name
Returns
true if library found and load
Note
This function always return false when called from static library
The libName can be partial and is case insensitive. Library will load only if found exactly one match.
If this function fails, fromJson() and fromJsonObj(), will try to load any available library.
if Library is already load, return true if it matchs

◆ ptpmgmt_json_tlv2json()

char* ptpmgmt_json_tlv2json ( enum ptpmgmt_mng_vals_e  managementId,
const void *  tlv,
int  indent 
)

Convert PTP managment TLV to JSON string

Parameters
[in]managementIdPTP managment TLV id
[in]tlvPTP managment TLV
[in]indentbase indent for the JSON string
Returns
JSON string
Note
The caller MUST free the string after use!