flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
msg_utils.c File Reference
#include "ptp_types.h"
#include "format_utils.h"
#include <string.h>
#include "msg_utils.h"
#include "ptp_defs.h"

Go to the source code of this file.

Functions

void ptp_load_flags (PtpFlags *pFlags, uint16_t bitfield)
 
uint16_t ptp_write_flags (const PtpFlags *pFlags)
 
void ptp_extract_header (PtpHeader *pHeader, const void *pPayload)
 
void ptp_construct_binary_header (void *pData, const PtpHeader *pHeader)
 
void ptp_extract_announce_message (PtpAnnounceBody *pAnnounce, void *pPayload)
 
void ptp_construct_binary_announce_message (void *pData, const PtpAnnounceBody *pAnnounce)
 
void ptp_write_binary_timestamps (void *pPayload, const TimestampI *ts, uint8_t n)
 
void ptp_extract_timestamps (TimestampI *ts, void *pPayload, uint8_t n)
 
void ptp_read_delay_resp_id_data (PtpDelay_RespIdentification *pDRData, void *pPayload)
 
void ptp_write_delay_resp_id_data (void *pPayload, const PtpDelay_RespIdentification *pDRData)
 
void ptp_clear_flags (PtpFlags *pFlags)
 

Function Documentation

◆ ptp_clear_flags()

void ptp_clear_flags ( PtpFlags pFlags)

Clear PTPFlags object.

Parameters
pFlagspointer to an existing PTPFlags object

Definition at line 232 of file msg_utils.c.

◆ ptp_construct_binary_announce_message()

void ptp_construct_binary_announce_message ( void *  pData,
const PtpAnnounceBody pAnnounce 
)

Construct PTP Announce message body from its contents.

Parameters
pAnnouncePointer to an existing, filled PtpAnnounceBody object.
pDataPointer to the binary storage area.

Definition at line 143 of file msg_utils.c.

◆ ptp_construct_binary_header()

void ptp_construct_binary_header ( void *  pData,
const PtpHeader pHeader 
)

Render PtpHeader object to binary (raw) form.

Parameters
pDatapointer to the beginning of the binary destination
pHeaderpointer to a filled-out PtpHeader object

Definition at line 90 of file msg_utils.c.

◆ ptp_extract_announce_message()

void ptp_extract_announce_message ( PtpAnnounceBody pAnnounce,
void *  pPayload 
)

Extract PTP Announce message body from the rendered payload.

Parameters
pAnnouncePointer to an existing PtpAnnounceBody object, where the contents of the Announce message of interest will be copied to.
pPayloadPointer to the beginning of the whole PTP message's payload.

Definition at line 122 of file msg_utils.c.

◆ ptp_extract_header()

void ptp_extract_header ( PtpHeader pHeader,
const void *  pPayload 
)

Extract the PTP message header from the whole messages payload.

Parameters
pHeaderPointer to an existing PtpHeader object, where the fetched header will get stored to.
pPayloadPointer to the beginning of the whole PTP message's payload.

Definition at line 55 of file msg_utils.c.

◆ ptp_extract_timestamps()

void ptp_extract_timestamps ( TimestampI ts,
void *  pPayload,
uint8_t  n 
)

Fetch n pieces of timestamps from a PTP message.

Parameters
tsPointer to an array of timestamps that can support at least n elements.
pPayloadpointer to the BEGINNING of the binary PTP packet
nnumber of timestamps to fetch.

Definition at line 189 of file msg_utils.c.

◆ ptp_load_flags()

void ptp_load_flags ( PtpFlags pFlags,
uint16_t  bitfield 
)

Extract PTP flags from the rendered bitfield found in particular PTP messages.

Parameters
pFlagsPointer to an existing PTPFlags object. It is the destination where the separated bits are getting stored to.
bitfieldThe direct copy of the PTP flags field from the PTP message of interest.

Definition at line 12 of file msg_utils.c.

◆ ptp_read_delay_resp_id_data()

void ptp_read_delay_resp_id_data ( PtpDelay_RespIdentification pDRData,
void *  pPayload 
)

Read (P)Delay_Response identification data from a raw PTP message.

Parameters
pDRDatapointer to an existing Delay_RespIdentification object
pPayloadpointer to the BEGINNING of a (P)Delay_Response PTP message

Definition at line 214 of file msg_utils.c.

◆ ptp_write_binary_timestamps()

void ptp_write_binary_timestamps ( void *  pPayload,
const TimestampI ts,
uint8_t  n 
)

Place n pieces of timestamps following the PTP header in the binary packet.

Parameters
pPayloadpointer to the BEGINNING of the binary PTP packet
tspointer to an array of timestamps
nlength of the array

Definition at line 166 of file msg_utils.c.

◆ ptp_write_delay_resp_id_data()

void ptp_write_delay_resp_id_data ( void *  pPayload,
const PtpDelay_RespIdentification pDRData 
)

Write (P)Delay_Response identification data from a raw PTP message.

Parameters
pPayloadpointer to the BEGINNING of a (P)Delay_Response PTP message
pDRDatapointer to an existing, filled-out Delay_RespIdentification object

Definition at line 224 of file msg_utils.c.

◆ ptp_write_flags()

uint16_t ptp_write_flags ( const PtpFlags pFlags)

Render PTPFlags into binary form.

Parameters
pFlagspointer to a filled-out PTPFlags object
Returns
binary, bitfield form of the PTPFlags

Definition at line 32 of file msg_utils.c.