Commit 4126868c authored by Cesar Prados's avatar Cesar Prados Committed by Alessandro Rubini

pdelay/msg: add pdelay request msg

Signed-off-by: Cesar Prados's avatarC.Prados <c.prados@gsi.de>
parent 15d9f801
......@@ -398,6 +398,8 @@ extern void msg_pack_pdelay_resp_follow_up(struct pp_instance *ppi,
Timestamp * prec_orig_tstamp);
extern void msg_pack_pdelay_resp(struct pp_instance *ppi, MsgHeader * hdr,
Timestamp * rcv_tstamp);
extern void msg_pack_pdelay_req(struct pp_instance *ppi,
Timestamp * orig_tstamp);
/* each of them returns 0 if ok, -1 in case of error in send, 1 if stamp err */
#define PP_SEND_OK 0
......@@ -409,6 +411,7 @@ extern int msg_issue_announce(struct pp_instance *ppi);
extern int msg_issue_sync_followup(struct pp_instance *ppi);
extern int msg_issue_delay_req(struct pp_instance *ppi);
extern int msg_issue_delay_resp(struct pp_instance *ppi, TimeInternal *time);
extern int msg_issue_pdelay_req(struct pp_instance *ppi);
extern int msg_issue_pdelay_resp_followup(struct pp_instance *ppi,
TimeInternal * time);
extern int msg_issue_pdelay_resp(struct pp_instance *ppi, TimeInternal * time);
......
......@@ -292,6 +292,37 @@ static void msg_pack_delay_req(struct pp_instance *ppi, Timestamp *orig_tstamp)
*(UInteger32 *) (buf + 40) = htonl(orig_tstamp->nanosecondsField);
}
/* pack DelayReq message into out buffer of ppi */
void msg_pack_pdelay_req(struct pp_instance *ppi, Timestamp * orig_tstamp)
{
void *buf;
buf = ppi->tx_ptp;
/* changes in header 11.4.3 */
*(char *)(buf + 0) = *(char *)(buf + 0) & 0xF0;
/* RAZ messageType */
*(char *)(buf + 0) = *(char *)(buf + 0) | 0x02;
*(UInteger16 *) (buf + 2) = htons(PP_PDELAY_REQ_LENGTH);
ppi->sent_seq[PPM_DELAY_REQ]++;
/* TO DO, 11.4.3 a.1) if synthed peer-to-peer TC */
/* *(char *)(buf + 4) = 0 .- not sythonized / X synt domain */
memset((buf + 8), 0, 8);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq[PPM_PDELAY_REQ]);
*(UInteger8 *) (buf + 32) = 0x05;
/* Table 23 */
*(Integer8 *) (buf + 33) = 0x7F;
/* PDelay_req message */
*(UInteger16 *) (buf + 34) = htons(orig_tstamp->secondsField.msb);
*(UInteger32 *) (buf + 36) = htonl(orig_tstamp->secondsField.lsb);
*(UInteger32 *) (buf + 40) = htonl(orig_tstamp->nanosecondsField);
}
/* pack PDelayResp message into OUT buffer of ppi */
void msg_pack_pdelay_resp(struct pp_instance *ppi,
MsgHeader * hdr, Timestamp * rcv_tstamp)
......@@ -309,6 +340,7 @@ void msg_pack_pdelay_resp(struct pp_instance *ppi,
*(UInteger8 *) (buf + 4) = hdr->domainNumber;
/* set 0 the correction field, 11.4.3 c.3) */
memset((buf + 8), 0, 8);
*(UInteger16 *) (buf + 30) = htons(hdr->sequenceId);
*(UInteger8 *) (buf + 32) = 0x05; /* controlField */
......@@ -464,6 +496,20 @@ int msg_issue_delay_req(struct pp_instance *ppi)
PP_NP_EVT);
}
/* Pack and send on event multicast ip adress a PDelayReq message */
int msg_issue_pdelay_req(struct pp_instance *ppi)
{
Timestamp orig_tstamp;
TimeInternal now;
ppi->t_ops->get(ppi, &now);
from_TimeInternal(&now, &orig_tstamp);
msg_pack_pdelay_req(ppi, &orig_tstamp);
return __send_and_log(ppi, PP_PDELAY_REQ_LENGTH, PPM_PDELAY_REQ,
PP_NP_EVT);
}
/* Pack and send on event multicast ip adress a DelayResp message */
int msg_issue_delay_resp(struct pp_instance *ppi, TimeInternal *time)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment