From 5901a6632b018a182f4bd9c6473dcbc7c1c79ee1 Mon Sep 17 00:00:00 2001 From: Alexander Bulimov Date: Fri, 17 Jan 2025 09:04:52 -0800 Subject: [PATCH] fix sync packet length (#442) Summary: Pull Request resolved: https://github.com/facebook/time/pull/442 Alternate Port TLV made sync packets non-fixed size. Reviewed By: leoleovich, vvfedorenko Differential Revision: D68329227 fbshipit-source-id: fb7726efafb43353cde6c32f497f3e6189aae08a --- cmd/ziffy/node/packets.go | 2 +- ptp/sptp/client/client_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/ziffy/node/packets.go b/cmd/ziffy/node/packets.go index 3c3697ab..c6a0e85e 100644 --- a/cmd/ziffy/node/packets.go +++ b/cmd/ziffy/node/packets.go @@ -66,7 +66,7 @@ func formSyncPacket(msgType ptp.MessageType, hop int, routeIndex int) *ptp.SyncD Header: ptp.Header{ SdoIDAndMsgType: ptp.NewSdoIDAndMsgType(msgType, 0), Version: ptp.Version, - MessageLength: uint16(binary.Size(ptp.SyncDelayReq{})), + MessageLength: uint16(binary.Size(ptp.Header{}) + binary.Size(ptp.SyncDelayReqBody{})), //#nosec G115 FlagField: ptp.FlagUnicast, SequenceID: uint16(hop), SourcePortIdentity: ptp.PortIdentity{ diff --git a/ptp/sptp/client/client_test.go b/ptp/sptp/client/client_test.go index 38cd19cc..c6cf2ee7 100644 --- a/ptp/sptp/client/client_test.go +++ b/ptp/sptp/client/client_test.go @@ -49,7 +49,7 @@ func announcePkt(seq int) *ptp.Announce { } func syncPkt(seq int) *ptp.SyncDelayReq { - l := binary.Size(ptp.SyncDelayReq{}) + l := binary.Size(ptp.Header{}) + binary.Size(ptp.SyncDelayReqBody{}) //#nosec G115 return &ptp.SyncDelayReq{ Header: ptp.Header{ SdoIDAndMsgType: ptp.NewSdoIDAndMsgType(ptp.MessageSync, 0),