Commit c105365a authored by Sven Meier's avatar Sven Meier Committed by Adam Wujek

audit porting: ported the patches of the audit chapter 2.4.4

Only the patches ragrding the flag from the current master was
taken over, the other falgs are still needed and used.
parent 17c4f21f
......@@ -192,7 +192,6 @@ struct pp_instance {
unsigned long ptp_rx_count;
};
/* The following things used to be bit fields. Other flags are now enums */
#define PPI_FLAG_FROM_CURRENT_PARENT 0x01
#define PPI_FLAG_WAITING_FOR_F_UP 0x02
#define PPI_FLAG_WAITING_FOR_RF_UP 0x04
#define PPI_FLAGS_WAITING 0x06 /* both of the above */
......
......@@ -385,6 +385,7 @@ extern void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf,
int len);
/* msg.c */
extern void msg_init_header(struct pp_instance *ppi, void *buf);
extern int msg_from_current_master(struct pp_instance *ppi);
extern int __attribute__((warn_unused_result))
msg_unpack_header(struct pp_instance *ppi, void *buf, int plen);
extern void msg_unpack_sync(void *buf, MsgSync *sync);
......
......@@ -694,17 +694,15 @@ void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf,
* there is a special handling described for boundary clocks
* which is done in the BMC
*/
if (!memcmp(&hdr->sourcePortIdentity,
&DSPOR(ppi)->portIdentity,
sizeof(PortIdentity))) {
if (!bmc_pidcmp(&hdr->sourcePortIdentity,
&DSPOR(ppi)->portIdentity)) {
pp_diag(ppi, bmc, 2, "Announce frame from this port\n");
return;
}
} else {
/* Check if announce from a port from this clock 9.3.2.5 a) */
if (!memcmp(&hdr->sourcePortIdentity.clockIdentity,
&DSDEF(ppi)->clockIdentity,
sizeof(ClockIdentity))) {
if (!bmc_idcmp(&hdr->sourcePortIdentity.clockIdentity,
&DSDEF(ppi)->clockIdentity)) {
pp_diag(ppi, bmc, 2, "Announce frame from this clock\n");
return;
}
......@@ -720,9 +718,8 @@ void bmc_add_frgn_master(struct pp_instance *ppi, unsigned char *buf,
/* Check if foreign master is already known */
for (i = 0; i < ppi->frgn_rec_num; i++) {
if (!memcmp(&hdr->sourcePortIdentity,
&ppi->frgn_master[i].sourcePortIdentity,
sizeof(PortIdentity))) {
if (!bmc_pidcmp(&hdr->sourcePortIdentity,
&ppi->frgn_master[i].sourcePortIdentity)) {
pp_diag(ppi, bmc, 2, "Foreign Master %i updated\n", i);
......
......@@ -140,7 +140,7 @@ int st_com_peer_handle_pres(struct pp_instance *ppi, unsigned char *buf,
hdr->sequenceId) &&
(DSPOR(ppi)->portIdentity.portNumber ==
resp.requestingPortIdentity.portNumber) &&
(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT)) {
(msg_from_current_master(ppi))) {
ppi->t4 = resp.requestReceiptTimestamp;
pp_time_add(&ppi->t4, &hdr->cField);
......@@ -186,7 +186,7 @@ int st_com_peer_handle_pres_followup(struct pp_instance *ppi,
hdr->sequenceId) &&
(DSPOR(ppi)->portIdentity.portNumber ==
respFllw.requestingPortIdentity.portNumber) &&
(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT)) {
(msg_from_current_master(ppi))) {
ppi->t5 = respFllw.responseOriginTimestamp;
pp_time_add(&ppi->t5, &hdr->cField);
......
......@@ -9,6 +9,18 @@
#include <ppsi/ppsi.h>
#include "common-fun.h"
/* return 1 if the frame is from the current master, else 0 */
int msg_from_current_master(struct pp_instance *ppi)
{
MsgHeader *hdr = &ppi->received_ptp_header;
if (!bmc_pidcmp(&DSPAR(ppi)->parentPortIdentity,
&hdr->sourcePortIdentity))
return 1;
else
return 0;
}
/* Unpack header from in buffer to receieved_ptp_header field */
int msg_unpack_header(struct pp_instance *ppi, void *buf, int plen)
{
......@@ -35,20 +47,6 @@ int msg_unpack_header(struct pp_instance *ppi, void *buf, int plen)
hdr->sequenceId = htons(*(UInteger16 *) (buf + 30));
hdr->logMessageInterval = (*(Integer8 *) (buf + 33));
/*
* This FLAG_FROM_CURRENT_PARENT must be killed. Meanwhile, say it's
* from current parent if we have no current parent, so the rest works
*/
if (!DSPAR(ppi)->parentPortIdentity.portNumber ||
(!memcmp(&DSPAR(ppi)->parentPortIdentity.clockIdentity,
&hdr->sourcePortIdentity.clockIdentity,
PP_CLOCK_IDENTITY_LENGTH) &&
(DSPAR(ppi)->parentPortIdentity.portNumber ==
hdr->sourcePortIdentity.portNumber)))
ppi->flags |= PPI_FLAG_FROM_CURRENT_PARENT;
else
ppi->flags &= ~PPI_FLAG_FROM_CURRENT_PARENT;
return 0;
}
......
......@@ -38,7 +38,7 @@ static int slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
MsgHeader *hdr = &ppi->received_ptp_header;
MsgSync sync;
if (!(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT))
if (!msg_from_current_master(ppi))
return 0;
/* t2 may be overriden by follow-up, save it immediately */
......@@ -72,7 +72,7 @@ static int slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
MsgHeader *hdr = &ppi->received_ptp_header;
if (!(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT)) {
if (!msg_from_current_master(ppi)) {
pp_error("%s: Follow up message is not from current parent\n",
__func__);
return 0;
......@@ -130,7 +130,7 @@ static int slave_handle_response(struct pp_instance *ppi, unsigned char *buf,
hdr->sequenceId) ||
(DSPOR(ppi)->portIdentity.portNumber !=
resp.requestingPortIdentity.portNumber) ||
!(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT)) {
(!msg_from_current_master(ppi))) {
pp_diag(ppi, frames, 1, "pp_slave : "
"Delay Resp doesn't match Delay Req (f %x)\n",
ppi->flags);
......@@ -168,13 +168,14 @@ static int slave_handle_announce(struct pp_instance *ppi, unsigned char *buf, in
if (ret)
return ret;
if (ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT) {
if (!msg_from_current_master(ppi))
return 0;
/* 9.2.6.11 a) reset timeout */
pp_timeout_set(ppi, PP_TO_ANN_RECEIPT);
/* 9.5.3 Figure 29 update data set if announce from current master */
bmc_store_frgn_master(ppi, &frgn_master, buf, len);
bmc_s1(ppi, &frgn_master);
}
return 0;
}
......
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