pt1588-SH7216 1
IEEE1588v2 Implementation for Renesas SH7216 Demo

C:/Users/mzimmer/IEEE1588/pt1588/branches/pt1588-SH7216/pt1588/platform/ptp-msg.c File Reference

Handle sending and receiving of PTP messages. More...

#include "../ptp-protocol.h"
#include "DP83640.h"
#include "uip.h"

Go to the source code of this file.

Defines

#define set08(x, y)   (*(x) = (y))
 Set the 8-bits at address x in big-endian to the UInteger8 or Integer8 variable y.
#define set16(x, y)   (*(x) = ((y) >> 8), *((x) + 1) = (y))
 Set the 16-bits at address x in big-endian to the UInteger16 or Integer16 variable y.
#define set32(x, y)
 Set the 32-bits at address x in big-endian to the UInteger32 or Integer32 variable y.
#define set64(x, y)   (memcpy((x), &(y), 8))
 Set the 64-bits at address x in big-endian to the UInteger64 or Integer64 variable y.
#define get4h(x, y)   ((x) = (*(y) >> 4) & 0x0F)
 Set the variable x to the upper 4-bits in the 8-bit value in big-endian at address y.
#define get4l(x, y)   ((x) = (*(y)) & 0x0F)
 Set the variable x to the lower 4-bits in the 8-bit value in big-endian at address y.
#define get08(x, y)   ((x) = *(y))
 Set the UInteger8 or Integer8 variable x to the upper 4-bits in the 8-bit value in big-endian at address y.
#define get16(x, y)   (memcpy(&(x), (y), 2))
 Set the UInteger16 or Integer16 variable x to the 16-bit value in big-endian at address y.
#define get32(x, y)   (memcpy(&(x), (y), 4))
 Set the UInteger32 or Integer32 variable x to the 32-bit value in big-endian at address y.
#define get64(x, y)   (memcpy(&(x), (y), 8))
 Set the UInteger64 or Integer64 variable x to the 64-bit value in big-endian at address y.

Functions

void sendAnnounceMsg (PTPState *ptp)
 Send Announce message over the network as a multicast PTP general message.
void sendSyncMsg (PTPState *ptp)
 Send Sync message over the network as a multicast PTP event message.
void sendFollowUpMsg (PTPState *ptp)
 Send Follow_Up message over the network as a multicast PTP general message.
void sendDelayReqMsg (PTPState *ptp)
 Send Delay_Req message over the network as a multicast PTP event message.
void sendDelayRespMsg (PTPState *ptp, DelayReqMsg *msg)
 Send Delay_Resp message over the network as a multicast PTP general message.
void sendManagementMsg (PTPState *ptp, ManagementMsg *msg)
 Send Management message being sent over the network as a multicast PTP general message.
void getSyncEventEgressTimestamp (PTPState *ptp)
 Attempt to provide an accurate timestamp for Sync message egress.
Boolean getSyncEventIngressTimestamp (PTPState *ptp, UInteger16 seqId)
 Attempt to provide an accurate timestamp for Sync message ingress.
void getDelayEventEgressTimestamp (PTPState *ptp)
 Attempt to provide an accurate timestamp for Delay_Req message egress.
Boolean getDelayEventIngressTimestamp (PTPState *ptp, UInteger16 seqId)
 Attempt to provide an accurate timestamp for Delay_Req message ingress.
void readHeader (Header *header)
 Fill the provided Header data structure with data from the message.
void readAnnounceMsg (AnnounceMsg *msg)
 Fill the provided AnnounceMsg data structure with data from an Announce message.
void readSyncMsg (SyncMsg *msg)
 Fill the provided SyncMsg data structure with data from a Sync message.
void readFollowUpMsg (FollowUpMsg *msg)
 Fill the provided FollowUpMsg data structure with data from a Follow_Up message.
void readDelayReqMsg (DelayReqMsg *msg)
 Fill the provided DelayReqMsg data structure with data from a Delay_Req message.
void readDelayRespMsg (DelayRespMsg *msg)
 Fill the provided DelayRespMsg data structure with data from a Delay_Resp message.
void readManagementMsg (ManagementMsg *msg)
 Fill the provided ManagementMsg data structure with data from a Management message.
void clearIngressTimestamp ()
 In SLAVE mode, the Delay_Req messages from other SLAVE clocks may be timestamped in hardware, even though they are ignored in software.

Variables

struct uip_udp_conn * ptp_event_conn
 uIP connection to send event messages.
struct uip_udp_conn * ptp_general_conn
 uIP connection to send general messages.

Detailed Description

Handle sending and receiving of PTP messages.

Author:
Michael Zimmer (mzimmer@eecs.berkeley.edu)
Version:
$Id$

Definition in file ptp-msg.c.


Define Documentation

#define get08 (   x,
 
)    ((x) = *(y))

Set the UInteger8 or Integer8 variable x to the upper 4-bits in the 8-bit value in big-endian at address y.

Definition at line 62 of file ptp-msg.c.

#define get16 (   x,
 
)    (memcpy(&(x), (y), 2))

Set the UInteger16 or Integer16 variable x to the 16-bit value in big-endian at address y.

Definition at line 65 of file ptp-msg.c.

#define get32 (   x,
 
)    (memcpy(&(x), (y), 4))

Set the UInteger32 or Integer32 variable x to the 32-bit value in big-endian at address y.

Definition at line 68 of file ptp-msg.c.

#define get4h (   x,
 
)    ((x) = (*(y) >> 4) & 0x0F)

Set the variable x to the upper 4-bits in the 8-bit value in big-endian at address y.

Definition at line 56 of file ptp-msg.c.

#define get4l (   x,
 
)    ((x) = (*(y)) & 0x0F)

Set the variable x to the lower 4-bits in the 8-bit value in big-endian at address y.

Definition at line 59 of file ptp-msg.c.

#define get64 (   x,
 
)    (memcpy(&(x), (y), 8))

Set the UInteger64 or Integer64 variable x to the 64-bit value in big-endian at address y.

Definition at line 71 of file ptp-msg.c.

#define set08 (   x,
 
)    (*(x) = (y))

Set the 8-bits at address x in big-endian to the UInteger8 or Integer8 variable y.

Definition at line 42 of file ptp-msg.c.

#define set16 (   x,
 
)    (*(x) = ((y) >> 8), *((x) + 1) = (y))

Set the 16-bits at address x in big-endian to the UInteger16 or Integer16 variable y.

Definition at line 45 of file ptp-msg.c.

#define set32 (   x,
 
)
Value:
(*(x) = ((y) >> 24), *((x) + 1) = ((y) >> 16), \
    *((x) + 2) = ((y) >> 8), *((x) + 3) = (y))

Set the 32-bits at address x in big-endian to the UInteger32 or Integer32 variable y.

Definition at line 48 of file ptp-msg.c.

#define set64 (   x,
 
)    (memcpy((x), &(y), 8))

Set the 64-bits at address x in big-endian to the UInteger64 or Integer64 variable y.

Definition at line 53 of file ptp-msg.c.


Function Documentation

void clearIngressTimestamp ( )

In SLAVE mode, the Delay_Req messages from other SLAVE clocks may be timestamped in hardware, even though they are ignored in software.

Clear receive timestamp.

Nothing is done because it is assumed that messages are received in the same order in software that they are timestamped in hardware, so ingressTimestamp is overwritten when the next message is processed.

Definition at line 639 of file ptp-msg.c.

void getDelayEventEgressTimestamp ( PTPState ptp)

Attempt to provide an accurate timestamp for Delay_Req message egress.

Set PTPState.delayEventEgressTimestamp to the timestamp at which the latest Delay_Req message was sent.

Definition at line 421 of file ptp-msg.c.

Boolean getDelayEventIngressTimestamp ( PTPState ptp,
UInteger16  seqId 
)

Attempt to provide an accurate timestamp for Delay_Req message ingress.

Set PTPState.delayEventIngressTimestamp to the timestamp at which the latest Delay_Req message was received.

Definition at line 452 of file ptp-msg.c.

void getSyncEventEgressTimestamp ( PTPState ptp)

Attempt to provide an accurate timestamp for Sync message egress.

Set PTPState.syncEventEgressTimestamp to the timestamp at which the latest Sync message was sent.

Definition at line 347 of file ptp-msg.c.

Boolean getSyncEventIngressTimestamp ( PTPState ptp,
UInteger16  seqId 
)

Attempt to provide an accurate timestamp for Sync message ingress.

Set PTPState.syncEventIngressTimestamp to the timestamp at which the latest Sync message was received.

Definition at line 380 of file ptp-msg.c.

void readAnnounceMsg ( AnnounceMsg msg)

Fill the provided AnnounceMsg data structure with data from an Announce message.

Parse received Announce message into provided AnnounceMsg data structure, but do not update PTP state (13.5).

Definition at line 520 of file ptp-msg.c.

void readDelayReqMsg ( DelayReqMsg msg)

Fill the provided DelayReqMsg data structure with data from a Delay_Req message.

Parse received Delay_Req message into provided DelayReqMsg data structure, but do not update PTP state (13.6).

Definition at line 577 of file ptp-msg.c.

void readDelayRespMsg ( DelayRespMsg msg)

Fill the provided DelayRespMsg data structure with data from a Delay_Resp message.

Parse received Delay_Resp message into provided DelayRespMsg data structure, but do not update PTP state (13.8).

Definition at line 593 of file ptp-msg.c.

void readFollowUpMsg ( FollowUpMsg msg)

Fill the provided FollowUpMsg data structure with data from a Follow_Up message.

Parse received Follow_Up message into provided FollowUpMsg data structure, but do not update PTP state (13.7).

Definition at line 561 of file ptp-msg.c.

void readHeader ( Header header)

Fill the provided Header data structure with data from the message.

Parse received message into provided Header data structure, but do not update PTP state (13.1).

Definition at line 495 of file ptp-msg.c.

void readManagementMsg ( ManagementMsg msg)

Fill the provided ManagementMsg data structure with data from a Management message.

Parse received Management message into provided ManagementMsg data structure, but do not update PTP state (15.1).

Definition at line 611 of file ptp-msg.c.

void readSyncMsg ( SyncMsg msg)

Fill the provided SyncMsg data structure with data from a Sync message.

Parse received Sync message into provided SyncMsg data structure, but do not update PTP state (13.6).

Definition at line 545 of file ptp-msg.c.

void sendAnnounceMsg ( PTPState ptp)

Send Announce message over the network as a multicast PTP general message.

Send an Announce message over the network, with content of message as specified in 13.5.

This implementation uses current data from the PTPState ptp and the current time to fill the buffer location uip_appdata with the Announce message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.

Definition at line 81 of file ptp-msg.c.

void sendDelayReqMsg ( PTPState ptp)

Send Delay_Req message over the network as a multicast PTP event message.

Send a Delay_Req message over the network, with content of message as specified in 13.6.

This implementation uses current data from the PTPState ptp to fill the buffer location uip_appdata with the Delay_Req message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.

Definition at line 224 of file ptp-msg.c.

void sendDelayRespMsg ( PTPState ptp,
DelayReqMsg msg 
)

Send Delay_Resp message over the network as a multicast PTP general message.

Send a Delay_Resp message over the network, with content of message as specified in 13.8.

This implementation uses current data from the PTPState ptp and the DelayReqMsg msg for which this message is a response to fill the buffer location uip_appdata with the Delay_Resp message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.

Definition at line 264 of file ptp-msg.c.

void sendFollowUpMsg ( PTPState ptp)

Send Follow_Up message over the network as a multicast PTP general message.

Send a Follow_Up message over the network, with content of message as specified in 13.7.

This implementation uses current data from the PTPState ptp to fill the buffer location uip_appdata with the Follow_Up message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.

Definition at line 188 of file ptp-msg.c.

void sendManagementMsg ( PTPState ptp,
ManagementMsg msg 
)

Send Management message being sent over the network as a multicast PTP general message.

Send a Management message over the network, with content of message as specified in 15.4.

This implementation uses current data from the PTPState ptp and the ManagementMsg msg which is being sent to fill the buffer location uip_appdata with the Management message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.

Definition at line 304 of file ptp-msg.c.

void sendSyncMsg ( PTPState ptp)

Send Sync message over the network as a multicast PTP event message.

Send a Sync message over the network, with content of message as specified in 13.6.

This implementation uses current data from the PTPState ptp and the current time to fill the buffer location uip_appdata with the Sync message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.

Definition at line 140 of file ptp-msg.c.


Variable Documentation

struct uip_udp_conn* ptp_event_conn

uIP connection to send event messages.

struct uip_udp_conn* ptp_general_conn

uIP connection to send general messages.

 All Data Structures Files Functions Variables Typedefs Enumerator Defines