Commit ec332e3f authored by Aurelio Colosimo's avatar Aurelio Colosimo

handling of is_from_self flag

parent 26ea047c
......@@ -148,6 +148,7 @@ struct pp_instance {
*/
MsgHeader msg_tmp_header;
MsgHeader pdelay_req_hdr;
int is_from_self;
};
......@@ -191,7 +192,7 @@ extern UInteger8 bmc(struct pp_frgn_master *frgn_master,
/* msg.c */
extern void msg_pack_header(void *buf, struct pp_instance *ppi);
extern void msg_unpack_header(void *buf, MsgHeader *hdr);
extern void msg_unpack_header(void *buf, struct pp_instance *ppi);
extern void msg_pack_sync(void *buf, Timestamp *orig_tstamp,
struct pp_instance *ppi);
extern void msg_unpack_sync(void *buf, MsgSync *sync);
......
......@@ -7,8 +7,10 @@
/* Unpack header from in buffer to msg_tmp_header field */
void msg_unpack_header(void *buf, MsgHeader *hdr)
void msg_unpack_header(void *buf, struct pp_instance *ppi)
{
MsgHeader *hdr = &ppi->msg_tmp_header;
hdr->transportSpecific = (*(Nibble *) (buf + 0)) >> 4;
hdr->messageType = (*(Enumeration4 *) (buf + 0)) & 0x0F;
hdr->versionPTP = (*(UInteger4 *) (buf + 1)) & 0x0F;
......@@ -31,6 +33,16 @@ void msg_unpack_header(void *buf, MsgHeader *hdr)
hdr->controlField = (*(UInteger8 *) (buf + 32));
hdr->logMessageInterval = (*(Integer8 *) (buf + 33));
if (DSPOR(ppi)->portIdentity.portNumber ==
ppi->msg_tmp_header.sourcePortIdentity.portNumber
&& !pp_memcmp(ppi->msg_tmp_header.sourcePortIdentity.clockIdentity,
DSPOR(ppi)->portIdentity.clockIdentity,
PP_CLOCK_IDENTITY_LENGTH))
ppi->is_from_self = 1;
else
ppi->is_from_self = 0;
/* FIXME: diag
#ifdef PTPD_DBG
msgHeader_display(header);
......
......@@ -16,12 +16,13 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
goto state_updated;
if (ppi->msg_tmp_header.messageType == PPM_ANNOUNCE) {
/* TODO check isFromSelf?
if (isFromSelf) {
if (ppi->is_from_self) {
/* FIXME diag
DBGV("HandleAnnounce : Ignore message from self \n");
*/
return;
}
*/
/* FIXME diag
* DBGV("Announce message from another foreign master");
......
......@@ -19,7 +19,7 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->msg_tmp_header.messageType == PPM_PDELAY_REQ) {
#ifdef _FROM_PTPD_2_1_0_
/* TODO "translate" it into ptp-wr structs*/
if (isFromSelf) {
if (ppi->is_from_self) {
/*
* Get sending timestamp from IP stack
* with So_TIMESTAMP
......
......@@ -19,7 +19,7 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
int state, err;
if (packet) {
msg_unpack_header(packet, &ppi->msg_tmp_header);
msg_unpack_header(packet, ppi);
}
state = ppi->state;
......
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