From 96beda42e3433a24ab67fe251769e44223513c8a Mon Sep 17 00:00:00 2001
From: Patrick Ohly <patrick.ohly@intel.com>
Date: Mon, 17 Mar 2008 16:15:38 +0100
Subject: [PATCH] optionally set PTP_ASSIST in msgPackDelayReq()

This is just a cosmetic patch, the flag is never really set.
---
 src/dep/msg.c      |   10 +++++++++-
 src/dep/ptpd_dep.h |    2 +-
 src/protocol.c     |    2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/dep/msg.c b/src/dep/msg.c
index 8003495..9266323 100644
--- a/src/dep/msg.c
+++ b/src/dep/msg.c
@@ -418,7 +418,7 @@ void msgPackSync(void *buf, Boolean burst, Boolean ptpAssist,
   *(Integer32*)(buf + 120) = shift8(ptpClock->utc_reasonable, 3);
 }
 
-void msgPackDelayReq(void *buf, Boolean burst,
+void msgPackDelayReq(void *buf, Boolean burst, Boolean ptpAssist,
   TimeRepresentation *originTimestamp, PtpClock *ptpClock)
 {
   *(UInteger8*)(buf + 20) = 1;  /* messageType */
@@ -432,6 +432,10 @@ void msgPackDelayReq(void *buf, Boolean burst,
     setFlag((buf + 34), PARENT_STATS);
   else
     clearFlag((buf + 34), PARENT_STATS);
+  if(ptpAssist)
+    setFlag((buf + 34), PTP_ASSIST);
+  else
+    clearFlag((buf + 34), PTP_ASSIST);
   
   *(Integer32*)(buf + 40) = flip32(originTimestamp->seconds);
   *(Integer32*)(buf + 44) = flip32(originTimestamp->nanoseconds);
@@ -464,6 +468,7 @@ void msgPackFollowUp(void *buf, UInteger16 associatedSequenceId,
   *(UInteger8*)(buf + 32) = PTP_FOLLOWUP_MESSAGE;  /* control */
   clearFlag((buf + 34), PTP_SYNC_BURST);
   clearFlag((buf + 34), PARENT_STATS);
+  clearFlag((buf + 34), PTP_ASSIST);
   
   *(Integer32*)(buf + 40) = shift16(flip16(associatedSequenceId), 1);
   *(Integer32*)(buf + 44) = flip32(preciseOriginTimestamp->seconds);
@@ -478,6 +483,7 @@ void msgPackDelayResp(void *buf, MsgHeader *header,
   *(UInteger8*)(buf + 32) = PTP_DELAY_RESP_MESSAGE;  /* control */
   clearFlag((buf + 34), PTP_SYNC_BURST);
   clearFlag((buf + 34), PARENT_STATS);
+  clearFlag((buf + 34), PTP_ASSIST);
   
   *(Integer32*)(buf + 40) = flip32(delayReceiptTimestamp->seconds);
   *(Integer32*)(buf + 44) = flip32(delayReceiptTimestamp->nanoseconds);
@@ -493,6 +499,7 @@ UInteger16 msgPackManagement(void *buf, MsgManagement *manage, PtpClock *ptpCloc
   *(UInteger8*)(buf + 32) = PTP_MANAGEMENT_MESSAGE;  /* control */
   clearFlag((buf + 34), PTP_SYNC_BURST);
   clearFlag((buf + 34), PARENT_STATS);
+  clearFlag((buf + 34), PTP_ASSIST);
   *(Integer32*)(buf + 40) = shift8(manage->targetCommunicationTechnology, 1);
   memcpy(buf + 42, manage->targetUuid, 6);
   *(Integer32*)(buf + 48) = shift16(flip16(manage->targetPortId), 0) | shift16(flip16(MM_STARTING_BOUNDARY_HOPS), 1);
@@ -523,6 +530,7 @@ UInteger16 msgPackManagementResponse(void *buf, MsgHeader *header, MsgManagement
   *(UInteger8*)(buf + 32) = PTP_MANAGEMENT_MESSAGE;  /* control */
   clearFlag((buf + 34), PTP_SYNC_BURST);
   clearFlag((buf + 34), PARENT_STATS);
+  clearFlag((buf + 34), PTP_ASSIST);
   *(Integer32*)(buf + 40) = shift8(header->sourceCommunicationTechnology, 1);
   memcpy(buf + 42, header->sourceUuid, 6);
   *(Integer32*)(buf + 48) = shift16(flip16(header->sourcePortId), 0) | shift16(flip16(MM_STARTING_BOUNDARY_HOPS), 1);
diff --git a/src/dep/ptpd_dep.h b/src/dep/ptpd_dep.h
index d464817..f38c18a 100644
--- a/src/dep/ptpd_dep.h
+++ b/src/dep/ptpd_dep.h
@@ -103,7 +103,7 @@ UInteger8 msgUnloadManagement(void*,MsgManagement*,PtpClock*,RunTimeOpts*);
 void msgUnpackManagementPayload(void *buf, MsgManagement *manage);
 void msgPackHeader(void*,PtpClock*);
 void msgPackSync(void*,Boolean,Boolean,TimeRepresentation*,PtpClock*);
-void msgPackDelayReq(void*,Boolean,TimeRepresentation*,PtpClock*);
+void msgPackDelayReq(void*,Boolean,Boolean,TimeRepresentation*,PtpClock*);
 void msgPackFollowUp(void*,UInteger16,TimeRepresentation*,PtpClock*);
 void msgPackDelayResp(void*,MsgHeader*,TimeRepresentation*,PtpClock*);
 UInteger16 msgPackManagement(void*,MsgManagement*,PtpClock*);
diff --git a/src/protocol.c b/src/protocol.c
index e9aaa14..652df0a 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -774,7 +774,7 @@ void issueDelayReq(RunTimeOpts *rtOpts, PtpClock *ptpClock)
   
   getTime(&internalTime, ptpClock);
   fromInternalTime(&internalTime, &originTimestamp, ptpClock->halfEpoch);
-  msgPackDelayReq(ptpClock->msgObuf, FALSE, &originTimestamp, ptpClock);
+  msgPackDelayReq(ptpClock->msgObuf, FALSE, FALSE, &originTimestamp, ptpClock);
   
   if(!netSendEvent(ptpClock->msgObuf, DELAY_REQ_PACKET_LENGTH, &ptpClock->netPath))
     toState(PTP_FAULTY, rtOpts, ptpClock);
-- 
1.5.5.3

