Track smac/dmac resolve failures when building packet list
This commit is contained in:
parent
2726192b9c
commit
88b3c287d0
@ -596,7 +596,8 @@ int AbstractProtocol::protocolFramePayloadSize(int streamIndex) const
|
|||||||
the FrameValue of all the 'frame' fields of the protocol also taking care of
|
the FrameValue of all the 'frame' fields of the protocol also taking care of
|
||||||
fields which are not an integral number of bytes\n
|
fields which are not an integral number of bytes\n
|
||||||
*/
|
*/
|
||||||
QByteArray AbstractProtocol::protocolFrameValue(int streamIndex, bool forCksum) const
|
QByteArray AbstractProtocol::protocolFrameValue(int streamIndex, bool forCksum,
|
||||||
|
FrameValueAttrib */*attrib*/) const
|
||||||
{
|
{
|
||||||
QByteArray proto, field;
|
QByteArray proto, field;
|
||||||
uint bits, lastbitpos = 0;
|
uint bits, lastbitpos = 0;
|
||||||
|
@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#define BASE_DEC (10)
|
#define BASE_DEC (10)
|
||||||
#define BASE_HEX (16)
|
#define BASE_HEX (16)
|
||||||
|
|
||||||
|
class FrameValueAttrib;
|
||||||
class StreamBase;
|
class StreamBase;
|
||||||
class ProtocolListIterator;
|
class ProtocolListIterator;
|
||||||
|
|
||||||
@ -147,8 +148,8 @@ public:
|
|||||||
const OstProto::VariableField& variableField(int index) const;
|
const OstProto::VariableField& variableField(int index) const;
|
||||||
OstProto::VariableField* mutableVariableField(int index);
|
OstProto::VariableField* mutableVariableField(int index);
|
||||||
|
|
||||||
QByteArray protocolFrameValue(int streamIndex = 0,
|
virtual QByteArray protocolFrameValue(int streamIndex = 0,
|
||||||
bool forCksum = false) const;
|
bool forCksum = false, FrameValueAttrib *attrib = nullptr) const;
|
||||||
virtual int protocolFrameSize(int streamIndex = 0) const;
|
virtual int protocolFrameSize(int streamIndex = 0) const;
|
||||||
int protocolFrameOffset(int streamIndex = 0) const;
|
int protocolFrameOffset(int streamIndex = 0) const;
|
||||||
int protocolFramePayloadSize(int streamIndex = 0) const;
|
int protocolFramePayloadSize(int streamIndex = 0) const;
|
||||||
|
49
common/framevalueattrib.h
Normal file
49
common/framevalueattrib.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2019 Srivats P.
|
||||||
|
|
||||||
|
This file is part of "Ostinato"
|
||||||
|
|
||||||
|
This is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _FRAME_VALUE_ATTRIB_H
|
||||||
|
#define _FRAME_VALUE_ATTRIB_H
|
||||||
|
|
||||||
|
#include <QFlags>
|
||||||
|
|
||||||
|
struct FrameValueAttrib
|
||||||
|
{
|
||||||
|
enum ErrorFlag {
|
||||||
|
UnresolvedSrcMacError = 0x1,
|
||||||
|
UnresolvedDstMacError = 0x2,
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(ErrorFlags, ErrorFlag);
|
||||||
|
ErrorFlags errorFlags{0};
|
||||||
|
// TODO?: int len;
|
||||||
|
|
||||||
|
FrameValueAttrib& operator+=(const FrameValueAttrib& rhs) {
|
||||||
|
errorFlags |= rhs.errorFlags;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
FrameValueAttrib operator+(const FrameValueAttrib& rhs) {
|
||||||
|
FrameValueAttrib result = *this;
|
||||||
|
result += rhs;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(FrameValueAttrib::ErrorFlags)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "mac.h"
|
#include "mac.h"
|
||||||
|
|
||||||
|
#include "framevalueattrib.h"
|
||||||
#include "../common/streambase.h"
|
#include "../common/streambase.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
@ -371,3 +372,28 @@ int MacProtocol::protocolFrameVariableCount() const
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray MacProtocol::protocolFrameValue(int streamIndex, bool /*forCksum*/,
|
||||||
|
FrameValueAttrib *attrib) const
|
||||||
|
{
|
||||||
|
QByteArray ba;
|
||||||
|
ba.resize(12);
|
||||||
|
quint64 dstMac = fieldData(mac_dstAddr, FieldValue, streamIndex)
|
||||||
|
.toULongLong();
|
||||||
|
quint64 srcMac = fieldData(mac_srcAddr, FieldValue, streamIndex)
|
||||||
|
.toULongLong();
|
||||||
|
char *p = ba.data();
|
||||||
|
*(quint32*)(p ) = qToBigEndian(quint32(dstMac >> 16));
|
||||||
|
*(quint16*)(p + 4) = qToBigEndian(quint16(dstMac & 0xffff));
|
||||||
|
*(quint32*)(p + 6) = qToBigEndian(quint32(srcMac >> 16));
|
||||||
|
*(quint16*)(p + 10) = qToBigEndian(quint16(srcMac & 0xffff));
|
||||||
|
|
||||||
|
if (attrib) {
|
||||||
|
if (!dstMac && data.dst_mac_mode() == OstProto::Mac::e_mm_resolve)
|
||||||
|
attrib->errorFlags |= FrameValueAttrib::UnresolvedDstMacError;
|
||||||
|
if (!srcMac && data.src_mac_mode() == OstProto::Mac::e_mm_resolve)
|
||||||
|
attrib->errorFlags |= FrameValueAttrib::UnresolvedSrcMacError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ba;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,9 @@ public:
|
|||||||
|
|
||||||
virtual int protocolFrameVariableCount() const;
|
virtual int protocolFrameVariableCount() const;
|
||||||
|
|
||||||
|
virtual QByteArray protocolFrameValue(int streamIndex = 0,
|
||||||
|
bool forCksum = false, FrameValueAttrib *attrib = nullptr) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OstProto::Mac data;
|
OstProto::Mac data;
|
||||||
mutable bool forResolve_;
|
mutable bool forResolve_;
|
||||||
|
@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "streambase.h"
|
#include "streambase.h"
|
||||||
#include "abstractprotocol.h"
|
#include "abstractprotocol.h"
|
||||||
|
#include "framevalueattrib.h"
|
||||||
#include "protocollist.h"
|
#include "protocollist.h"
|
||||||
#include "protocollistiterator.h"
|
#include "protocollistiterator.h"
|
||||||
#include "protocolmanager.h"
|
#include "protocolmanager.h"
|
||||||
@ -536,7 +537,8 @@ int StreamBase::frameCount() const
|
|||||||
|
|
||||||
// Returns packet length - if bufMaxSize < frameLen(), returns truncated
|
// Returns packet length - if bufMaxSize < frameLen(), returns truncated
|
||||||
// length i.e. bufMaxSize
|
// length i.e. bufMaxSize
|
||||||
int StreamBase::frameValue(uchar *buf, int bufMaxSize, int frameIndex) const
|
int StreamBase::frameValue(uchar *buf, int bufMaxSize, int frameIndex,
|
||||||
|
FrameValueAttrib *attrib) const
|
||||||
{
|
{
|
||||||
int maxSize, size, pktLen, len = 0;
|
int maxSize, size, pktLen, len = 0;
|
||||||
|
|
||||||
@ -557,9 +559,12 @@ int StreamBase::frameValue(uchar *buf, int bufMaxSize, int frameIndex) const
|
|||||||
{
|
{
|
||||||
AbstractProtocol *proto;
|
AbstractProtocol *proto;
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
|
FrameValueAttrib protoAttrib;
|
||||||
|
|
||||||
proto = iter->next();
|
proto = iter->next();
|
||||||
ba = proto->protocolFrameValue(frameIndex);
|
ba = proto->protocolFrameValue(frameIndex, false, &protoAttrib);
|
||||||
|
if (attrib)
|
||||||
|
*attrib += protoAttrib;
|
||||||
|
|
||||||
size = qMin(ba.size(), maxSize-len);
|
size = qMin(ba.size(), maxSize-len);
|
||||||
memcpy(buf+len, ba.constData(), size);
|
memcpy(buf+len, ba.constData(), size);
|
||||||
|
@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
const int kFcsSize = 4;
|
const int kFcsSize = 4;
|
||||||
|
|
||||||
class AbstractProtocol;
|
class AbstractProtocol;
|
||||||
|
class FrameValueAttrib;
|
||||||
class ProtocolList;
|
class ProtocolList;
|
||||||
class ProtocolListIterator;
|
class ProtocolListIterator;
|
||||||
|
|
||||||
@ -136,7 +137,8 @@ public:
|
|||||||
int frameVariableCount() const;
|
int frameVariableCount() const;
|
||||||
int frameProtocolLength(int frameIndex) const;
|
int frameProtocolLength(int frameIndex) const;
|
||||||
int frameCount() const;
|
int frameCount() const;
|
||||||
int frameValue(uchar *buf, int bufMaxSize, int frameIndex) const;
|
int frameValue(uchar *buf, int bufMaxSize, int frameIndex,
|
||||||
|
FrameValueAttrib *attrib = nullptr) const;
|
||||||
|
|
||||||
quint64 deviceMacAddress(int frameIndex) const;
|
quint64 deviceMacAddress(int frameIndex) const;
|
||||||
quint64 neighborMacAddress(int frameIndex) const;
|
quint64 neighborMacAddress(int frameIndex) const;
|
||||||
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "abstractport.h"
|
#include "abstractport.h"
|
||||||
|
|
||||||
#include "../common/abstractprotocol.h"
|
#include "../common/abstractprotocol.h"
|
||||||
|
#include "../common/framevalueattrib.h"
|
||||||
#include "../common/streambase.h"
|
#include "../common/streambase.h"
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "interfaceinfo.h"
|
#include "interfaceinfo.h"
|
||||||
@ -219,6 +220,7 @@ void AbstractPort::updatePacketList()
|
|||||||
|
|
||||||
void AbstractPort::updatePacketListSequential()
|
void AbstractPort::updatePacketListSequential()
|
||||||
{
|
{
|
||||||
|
FrameValueAttrib packetListAttrib;
|
||||||
long sec = 0;
|
long sec = 0;
|
||||||
long nsec = 0;
|
long nsec = 0;
|
||||||
|
|
||||||
@ -320,8 +322,10 @@ void AbstractPort::updatePacketListSequential()
|
|||||||
|
|
||||||
if (j == 0 || frameVariableCount > 1)
|
if (j == 0 || frameVariableCount > 1)
|
||||||
{
|
{
|
||||||
|
FrameValueAttrib attrib;
|
||||||
len = streamList_[i]->frameValue(
|
len = streamList_[i]->frameValue(
|
||||||
pktBuf_, sizeof(pktBuf_), j);
|
pktBuf_, sizeof(pktBuf_), j, &attrib);
|
||||||
|
packetListAttrib += attrib;
|
||||||
}
|
}
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
continue;
|
continue;
|
||||||
@ -392,10 +396,14 @@ void AbstractPort::updatePacketListSequential()
|
|||||||
|
|
||||||
_stop_no_more_pkts:
|
_stop_no_more_pkts:
|
||||||
isSendQueueDirty_ = false;
|
isSendQueueDirty_ = false;
|
||||||
|
|
||||||
|
// FIXME: send attrib back in Ack
|
||||||
|
qDebug("PacketListAttrib = %x", (int)packetListAttrib.errorFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractPort::updatePacketListInterleaved()
|
void AbstractPort::updatePacketListInterleaved()
|
||||||
{
|
{
|
||||||
|
FrameValueAttrib packetListAttrib;
|
||||||
int numStreams = 0;
|
int numStreams = 0;
|
||||||
quint64 minGap = ULLONG_MAX;
|
quint64 minGap = ULLONG_MAX;
|
||||||
quint64 duration = quint64(1e9);
|
quint64 duration = quint64(1e9);
|
||||||
@ -540,11 +548,14 @@ void AbstractPort::updatePacketListInterleaved()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
FrameValueAttrib attrib;
|
||||||
isVariable.append(false);
|
isVariable.append(false);
|
||||||
pktBuf.append(QByteArray());
|
pktBuf.append(QByteArray());
|
||||||
pktBuf.last().resize(kMaxPktSize);
|
pktBuf.last().resize(kMaxPktSize);
|
||||||
pktLen.append(streamList_[i]->frameValue(
|
pktLen.append(streamList_[i]->frameValue(
|
||||||
(uchar*)pktBuf.last().data(), pktBuf.last().size(), 0));
|
(uchar*)pktBuf.last().data(), pktBuf.last().size(),
|
||||||
|
0, &attrib));
|
||||||
|
packetListAttrib += attrib;
|
||||||
}
|
}
|
||||||
|
|
||||||
numStreams++;
|
numStreams++;
|
||||||
@ -573,9 +584,11 @@ void AbstractPort::updatePacketListInterleaved()
|
|||||||
{
|
{
|
||||||
if (isVariable.at(i))
|
if (isVariable.at(i))
|
||||||
{
|
{
|
||||||
|
FrameValueAttrib attrib;
|
||||||
buf = pktBuf_;
|
buf = pktBuf_;
|
||||||
len = streamList_[i]->frameValue(pktBuf_, sizeof(pktBuf_),
|
len = streamList_[i]->frameValue(pktBuf_, sizeof(pktBuf_),
|
||||||
pktCount[i]);
|
pktCount[i], &attrib);
|
||||||
|
packetListAttrib += attrib;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -629,6 +642,9 @@ void AbstractPort::updatePacketListInterleaved()
|
|||||||
qDebug("loop Delay = %lld/%lld", delaySec, delayNsec);
|
qDebug("loop Delay = %lld/%lld", delaySec, delayNsec);
|
||||||
setPacketListLoopMode(true, delaySec, delayNsec);
|
setPacketListLoopMode(true, delaySec, delayNsec);
|
||||||
isSendQueueDirty_ = false;
|
isSendQueueDirty_ = false;
|
||||||
|
|
||||||
|
// FIXME: send attrib back in Ack
|
||||||
|
qDebug("PacketListAttrib = %x", (int)packetListAttrib.errorFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractPort::stats(PortStats *stats)
|
void AbstractPort::stats(PortStats *stats)
|
||||||
|
Loading…
Reference in New Issue
Block a user