summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Galka <michal.galka@harman.com>2017-12-01 10:22:57 +0100
committerMichal Galka <michal.galka@harman.com>2017-12-01 10:22:57 +0100
commit3fde53e712e70b48a5405fd286aef637df751d33 (patch)
tree122ab613431009622099b9cb86bdeeacec672413
parentfa0163d131885fab1c1f2c0954e453d0da93f93f (diff)
downloadOpen-AVB-3fde53e712e70b48a5405fd286aef637df751d33.tar.gz
Got rid of magic numbers. More self-explanatory code.
-rw-r--r--daemons/gptp/common/ptptypes.hpp1
-rw-r--r--daemons/gptp/linux/src/linux_hal_generic.cpp7
2 files changed, 4 insertions, 4 deletions
diff --git a/daemons/gptp/common/ptptypes.hpp b/daemons/gptp/common/ptptypes.hpp
index 03cd57be..f73c8f92 100644
--- a/daemons/gptp/common/ptptypes.hpp
+++ b/daemons/gptp/common/ptptypes.hpp
@@ -43,6 +43,7 @@ typedef double FrequencyRatio; /*!< Frequency Ratio */
typedef long double FrequencyRatio; /*!< Frequency Ratio */
#endif
+#define ETHER_HDR_LEN (14)
#define ETHER_ADDR_OCTETS 6 /*!< Number of octets in a link layer address*/
#define IP_ADDR_OCTETS 4 /*!< Number of octets in a ip address*/
#define PTP_ETHERTYPE 0x88F7 /*!< PTP ethertype */
diff --git a/daemons/gptp/linux/src/linux_hal_generic.cpp b/daemons/gptp/linux/src/linux_hal_generic.cpp
index 395e344f..9eeba46f 100644
--- a/daemons/gptp/linux/src/linux_hal_generic.cpp
+++ b/daemons/gptp/linux/src/linux_hal_generic.cpp
@@ -30,7 +30,6 @@
POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
-
#include <linux_hal_generic.hpp>
#include <linux_hal_generic_tsprivate.hpp>
#include <platform.hpp>
@@ -288,7 +287,7 @@ int LinuxTimestamperGeneric::HWTimestamper_txtimestamp
struct sockaddr_ll remote;
struct iovec sgentry;
PTPMessageId reflectedMessageId;
- uint8_t reflected_bytes[46];
+ uint8_t reflected_bytes[ETHER_HDR_LEN + PTP_COMMON_HDR_LENGTH];
uint8_t *gptpCommonHeader;
uint16_t sequenceId;
struct {
@@ -305,7 +304,7 @@ int LinuxTimestamperGeneric::HWTimestamper_txtimestamp
sgentry.iov_base = reflected_bytes;
sgentry.iov_len = sizeof(reflected_bytes);
- gptpCommonHeader = reflected_bytes + 14;
+ gptpCommonHeader = reflected_bytes + ETHER_HDR_LEN;
memset( &remote, 0, sizeof(remote));
msg.msg_name = (caddr_t) &remote;
@@ -326,7 +325,7 @@ int LinuxTimestamperGeneric::HWTimestamper_txtimestamp
}
sequenceId = PLAT_ntohs(*((uint16_t*)(PTP_COMMON_HDR_SEQUENCE_ID(gptpCommonHeader))));
reflectedMessageId.setSequenceId(sequenceId);
- reflectedMessageId.setMessageType((MessageType)(*gptpCommonHeader & 0xF));
+ reflectedMessageId.setMessageType((MessageType)(*PTP_COMMON_HDR_TRANSSPEC_MSGTYPE(gptpCommonHeader) & 0xF));
if (messageId != reflectedMessageId) {
GPTP_LOG_WARNING("Timestamp discarded due to wrong message id");
ret = GPTP_EC_EAGAIN;