Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
Warn if sign proto may be followed by padding
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pstavirs committed Jun 30, 2022
1 parent 2970a29 commit 06ad127
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion common/streambase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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 &lt; 64 bytes and hence will get padded - "
"make sure special signature is at the end of the "
"frame and frame content &ge; 64 bytes");
chkShort = false;
pass = false;
}

if (chkTrunc && (pktLen < (frameProtocolLength(i) + kFcsSize)))
{
result << QObject::tr("One or more frames may be truncated - "
Expand Down
2 changes: 1 addition & 1 deletion common/streambase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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??
Expand Down

0 comments on commit 06ad127

Please sign in to comment.