mbgtools-lx  4.2.8
ptp_util.h File Reference
#include <stdio.h>
#include <lan_util.h>
#include <gpsdefs.h>

Go to the source code of this file.

Macros

#define _ext   extern
 

Functions

static __mbg_inline uint32_t get_supp_ptp_role_mask (uint32_t flags)
 Derive a "supported PTP roles" bit mask from PTP_CFG_INFO::supp_flags. More...
 
void mac_from_ptp_clock_id (MBG_MAC_ADDR *p_mac_addr, const PTP_CLOCK_ID *p_clock_id)
 Get the MAC addr from a PTP clock ID. More...
 
void ptp_clock_id_from_mac (PTP_CLOCK_ID *p_clock_id, const MBG_MAC_ADDR *p_mac_addr)
 Get the PTP clock ID from the MAC addr. More...
 
void ptp_clock_id_from_str (PTP_CLOCK_ID *p_clock_id, const char *p_str)
 Get the PTP clock ID from a string. More...
 

Macro Definition Documentation

◆ _ext

#define _ext   extern

Definition at line 44 of file ptp_util.h.

Function Documentation

◆ get_supp_ptp_role_mask()

static __mbg_inline uint32_t get_supp_ptp_role_mask ( uint32_t  flags)
static

Derive a "supported PTP roles" bit mask from PTP_CFG_INFO::supp_flags.

The relevant bits used with PTP_CFG_INFO::supp_flags have not been defined sequentially, so we need to test them individually to put a supported roles bit mask together.

Note
Originally, all devices supported the multicast slave role, so there was no extra flag to indicate this. However, some newer devices may not support the multicast slave role, so two new flags have been introduced to cope with this:
If PTP_CFG_SUPP_MCAST_SLAVE_FLAG is set then a different flag PTP_CFG_CAN_BE_MULTICAST_SLAVE needs to be checked to tell if the multicast slave role is supported, or not.
If PTP_CFG_SUPP_MCAST_SLAVE_FLAG is not set then the device definitely supports the multicast slave role.
Parameters
flagsbit mask from PTP_CFG_INFO::supp_flags, see PTP_CFG_FLAG_MASKS
Returns
bit mask of supported PTP roles, see PTP_ROLE_MASKS

Definition at line 82 of file ptp_util.h.

References mac_from_ptp_clock_id(), PTP_CFG_MSK_CAN_BE_BOTH_MASTER, PTP_CFG_MSK_CAN_BE_MULTICAST_AUTO, PTP_CFG_MSK_CAN_BE_MULTICAST_MASTER, PTP_CFG_MSK_CAN_BE_MULTICAST_SLAVE, PTP_CFG_MSK_CAN_BE_TIME_MONITOR, PTP_CFG_MSK_CAN_BE_UNICAST_MASTER, PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE, PTP_CFG_MSK_CAN_BE_V1_MASTER, PTP_CFG_MSK_CAN_BE_V1_SLAVE, PTP_CFG_MSK_NTP_HW_TS_MASTER, PTP_CFG_MSK_NTP_HW_TS_SLAVE, PTP_CFG_MSK_SUPP_MCAST_SLAVE_FLAG, ptp_clock_id_from_mac(), ptp_clock_id_from_str(), PTP_ROLE_MSK_BOTH_MASTER, PTP_ROLE_MSK_MULTICAST_AUTO, PTP_ROLE_MSK_MULTICAST_MASTER, PTP_ROLE_MSK_MULTICAST_SLAVE, PTP_ROLE_MSK_NTP_CLIENT, PTP_ROLE_MSK_NTP_SERVER, PTP_ROLE_MSK_TIME_MONITOR, PTP_ROLE_MSK_UNICAST_MASTER, PTP_ROLE_MSK_UNICAST_SLAVE, PTP_ROLE_MSK_V1_MASTER, and PTP_ROLE_MSK_V1_SLAVE.

Referenced by set_ptp_cfg().

◆ mac_from_ptp_clock_id()

void mac_from_ptp_clock_id ( MBG_MAC_ADDR p_mac_addr,
const PTP_CLOCK_ID p_clock_id 
)

Get the MAC addr from a PTP clock ID.

The clock ID is usually the MAC ID with 2 octets 0xFF and 0xFE inserted in the middle.

Parameters
p_mac_addrThe MAC ID to be filled up
p_clock_idThe PTP clock ID

Referenced by get_supp_ptp_role_mask().

◆ ptp_clock_id_from_mac()

void ptp_clock_id_from_mac ( PTP_CLOCK_ID p_clock_id,
const MBG_MAC_ADDR p_mac_addr 
)

Get the PTP clock ID from the MAC addr.

The clock ID is usually the MAC ID with 2 octets 0xFF and 0xFE inserted in the middle.

Parameters
p_clock_idThe PTP clock ID
p_mac_addrThe MAC ID to be filled up

Referenced by get_supp_ptp_role_mask().

◆ ptp_clock_id_from_str()

void ptp_clock_id_from_str ( PTP_CLOCK_ID p_clock_id,
const char *  p_str 
)

Get the PTP clock ID from a string.

The clock ID is usually the MAC ID with 2 octets 0xFF and 0xFE inserted in the middle.

Parameters
p_clock_idThe PTP clock ID
p_strThe UUID as string with format e.g. 0050C2FFFED287DE

Referenced by get_supp_ptp_role_mask().