From 06ad12777fcaabbbf59c7d1763a0a48951aa0b3a Mon Sep 17 00:00:00 2001 From: Srivats P Date: Thu, 30 Jun 2022 18:24:48 +0530 Subject: [PATCH] Warn if sign proto may be followed by padding For now, we check and tell the user. The actual fix should be for sign proto to add padding before it's content, if required Updates #313 --- common/streambase.cpp | 14 +++++++++++++- common/streambase.h | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/common/streambase.cpp b/common/streambase.cpp index 39168983..af9e640f 100644 --- a/common/streambase.cpp +++ b/common/streambase.cpp @@ -145,7 +145,7 @@ void StreamBase::setFrameProtocol(ProtocolList protocolList) } #endif -bool StreamBase::hasProtocol(quint32 protocolNumber) +bool StreamBase::hasProtocol(quint32 protocolNumber) const { foreach(const AbstractProtocol *proto, *currentFrameProtocols) if (proto->protocolNumber() == protocolNumber) @@ -681,6 +681,7 @@ quint64 StreamBase::neighborMacAddress(int frameIndex) const bool StreamBase::preflightCheck(QStringList &result) const { bool pass = true; + bool chkShort = true; bool chkTrunc = true; bool chkJumbo = true; int count = isFrameSizeVariable() ? frameSizeVariableCount() : 1; @@ -689,6 +690,17 @@ bool StreamBase::preflightCheck(QStringList &result) const { int pktLen = frameLen(i); + if (chkShort && hasProtocol(OstProto::Protocol::kSignFieldNumber) + && (pktLen > (frameProtocolLength(i) + kFcsSize))) + { + result << QObject::tr("Stream statistics may not work since " + "frame content < 64 bytes and hence will get padded - " + "make sure special signature is at the end of the " + "frame and frame content ≥ 64 bytes"); + chkShort = false; + pass = false; + } + if (chkTrunc && (pktLen < (frameProtocolLength(i) + kFcsSize))) { result << QObject::tr("One or more frames may be truncated - " diff --git a/common/streambase.h b/common/streambase.h index 83e40342..0e93a4d4 100644 --- a/common/streambase.h +++ b/common/streambase.h @@ -42,7 +42,7 @@ class StreamBase void protoDataCopyFrom(const OstProto::Stream &stream); void protoDataCopyInto(OstProto::Stream &stream) const; - bool hasProtocol(quint32 protocolNumber); + bool hasProtocol(quint32 protocolNumber) const; ProtocolListIterator* createProtocolListIterator() const; //! \todo (LOW) should we have a copy constructor??