Add option to recalculate cksums during pcap import
Recalculate cksum is now the default. This behaviour change has been done to facilitate rewriting packet fields post PCAP import using the new Find & Replace feature. Without this any change in fields may cause incorrect checksums. The earlier rationale for retaining the checksums in the PCAP file during import was to ensure replayed packet was same as the one in the PCAP file. User now has a choice with this option.
This commit is contained in:
parent
366022552f
commit
dbdeee2a6f
@ -56,7 +56,7 @@ void PdmlIcmpProtocol::preProtocolHandler(QString name,
|
|||||||
else if (name == "icmpv6")
|
else if (name == "icmpv6")
|
||||||
icmp->set_icmp_version(OstProto::Icmp::kIcmp6);
|
icmp->set_icmp_version(OstProto::Icmp::kIcmp6);
|
||||||
|
|
||||||
icmp->set_is_override_checksum(true);
|
icmp->set_is_override_checksum(overrideCksum_);
|
||||||
|
|
||||||
icmp->set_type(kIcmpInvalidType);
|
icmp->set_type(kIcmpInvalidType);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ void PdmlIgmpProtocol::preProtocolHandler(QString /*name*/,
|
|||||||
OstProto::Gmp *igmp = pbProto->MutableExtension(OstProto::igmp);
|
OstProto::Gmp *igmp = pbProto->MutableExtension(OstProto::igmp);
|
||||||
|
|
||||||
igmp->set_is_override_rsvd_code(true);
|
igmp->set_is_override_rsvd_code(true);
|
||||||
igmp->set_is_override_checksum(true);
|
igmp->set_is_override_checksum(overrideCksum_);
|
||||||
igmp->set_is_override_source_count(true);
|
igmp->set_is_override_source_count(true);
|
||||||
igmp->set_is_override_group_record_count(true);
|
igmp->set_is_override_group_record_count(true);
|
||||||
|
|
||||||
|
@ -88,6 +88,6 @@ void PdmlIp4Protocol::postProtocolHandler(OstProto::Protocol *pbProto,
|
|||||||
ip4->set_is_override_hdrlen(true);
|
ip4->set_is_override_hdrlen(true);
|
||||||
ip4->set_is_override_totlen(true);
|
ip4->set_is_override_totlen(true);
|
||||||
ip4->set_is_override_proto(true);
|
ip4->set_is_override_proto(true);
|
||||||
ip4->set_is_override_cksum(true);
|
ip4->set_is_override_cksum(overrideCksum_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ void PdmlMldProtocol::preProtocolHandler(QString /*name*/,
|
|||||||
OstProto::Gmp *mld = pbProto->MutableExtension(OstProto::mld);
|
OstProto::Gmp *mld = pbProto->MutableExtension(OstProto::mld);
|
||||||
|
|
||||||
mld->set_is_override_rsvd_code(true);
|
mld->set_is_override_rsvd_code(true);
|
||||||
mld->set_is_override_checksum(true);
|
mld->set_is_override_checksum(overrideCksum_);
|
||||||
mld->set_is_override_source_count(true);
|
mld->set_is_override_source_count(true);
|
||||||
mld->set_is_override_group_record_count(true);
|
mld->set_is_override_group_record_count(true);
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ PcapImportOptionsDialog::PcapImportOptionsDialog(QVariantMap *options)
|
|||||||
options_ = options;
|
options_ = options;
|
||||||
|
|
||||||
viaPdml->setChecked(options_->value("ViaPdml").toBool());
|
viaPdml->setChecked(options_->value("ViaPdml").toBool());
|
||||||
|
recalculateCksums->setChecked(
|
||||||
|
options_->value("RecalculateCksums").toBool());
|
||||||
doDiff->setChecked(options_->value("DoDiff").toBool());
|
doDiff->setChecked(options_->value("DoDiff").toBool());
|
||||||
|
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
@ -59,6 +61,7 @@ PcapImportOptionsDialog::~PcapImportOptionsDialog()
|
|||||||
void PcapImportOptionsDialog::accept()
|
void PcapImportOptionsDialog::accept()
|
||||||
{
|
{
|
||||||
options_->insert("ViaPdml", viaPdml->isChecked());
|
options_->insert("ViaPdml", viaPdml->isChecked());
|
||||||
|
options_->insert("RecalculateCksums", recalculateCksums->isChecked());
|
||||||
options_->insert("DoDiff", doDiff->isChecked());
|
options_->insert("DoDiff", doDiff->isChecked());
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
@ -67,6 +70,7 @@ void PcapImportOptionsDialog::accept()
|
|||||||
PcapFileFormat::PcapFileFormat()
|
PcapFileFormat::PcapFileFormat()
|
||||||
{
|
{
|
||||||
importOptions_.insert("ViaPdml", true);
|
importOptions_.insert("ViaPdml", true);
|
||||||
|
importOptions_.insert("RecalculateCksums", true);
|
||||||
importOptions_.insert("DoDiff", true);
|
importOptions_.insert("DoDiff", true);
|
||||||
|
|
||||||
importDialog_ = NULL;
|
importDialog_ = NULL;
|
||||||
@ -224,7 +228,7 @@ _retry:
|
|||||||
{
|
{
|
||||||
QProcess tshark;
|
QProcess tshark;
|
||||||
QTemporaryFile pdmlFile;
|
QTemporaryFile pdmlFile;
|
||||||
PdmlReader reader(&streams);
|
PdmlReader reader(&streams, importOptions_);
|
||||||
|
|
||||||
if (!pdmlFile.open())
|
if (!pdmlFile.open())
|
||||||
{
|
{
|
||||||
|
@ -7,51 +7,57 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>326</width>
|
<width>326</width>
|
||||||
<height>93</height>
|
<height>112</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>PCAP import options</string>
|
<string>PCAP import options</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="viaPdml">
|
<widget class="QCheckBox" name="viaPdml">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Intelligent Import (via PDML)</string>
|
<string>Intelligent Import (via PDML)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="0" rowspan="2">
|
||||||
<layout class="QHBoxLayout">
|
<widget class="QWidget" name="indentSpacing" native="true">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QWidget" name="widget" native="true">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<property name="sizePolicy">
|
<horstretch>0</horstretch>
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<verstretch>0</verstretch>
|
||||||
<horstretch>0</horstretch>
|
</sizepolicy>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
<property name="minimumSize">
|
||||||
</property>
|
<size>
|
||||||
<property name="minimumSize">
|
<width>16</width>
|
||||||
<size>
|
<height>16</height>
|
||||||
<width>16</width>
|
</size>
|
||||||
<height>16</height>
|
</property>
|
||||||
</size>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="doDiff">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Do a diff after import</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="recalculateCksums">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Recalculate Checksums</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="doDiff">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do a diff after import</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -108,8 +114,8 @@
|
|||||||
<y>16</y>
|
<y>16</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>37</x>
|
<x>68</x>
|
||||||
<y>42</y>
|
<y>71</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@ -124,8 +130,40 @@
|
|||||||
<y>14</y>
|
<y>14</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>150</x>
|
<x>181</x>
|
||||||
<y>34</y>
|
<y>71</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>viaPdml</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>recalculateCksums</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>29</x>
|
||||||
|
<y>17</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>38</x>
|
||||||
|
<y>39</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>viaPdml</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>recalculateCksums</receiver>
|
||||||
|
<slot>setChecked(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>67</x>
|
||||||
|
<y>18</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>66</x>
|
||||||
|
<y>33</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -102,6 +102,11 @@ int PdmlProtocol::fieldId(QString name) const
|
|||||||
return fieldMap_.value(name);
|
return fieldMap_.value(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PdmlProtocol::setRecalculateCksum(bool recalculate)
|
||||||
|
{
|
||||||
|
overrideCksum_ = !recalculate;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
This method is called by PdmlReader before any fields within the protocol
|
This method is called by PdmlReader before any fields within the protocol
|
||||||
are processed. All attributes associated with the 'proto' tag in the PDML
|
are processed. All attributes associated with the 'proto' tag in the PDML
|
||||||
|
@ -40,6 +40,8 @@ public:
|
|||||||
bool hasField(QString name) const;
|
bool hasField(QString name) const;
|
||||||
int fieldId(QString name) const;
|
int fieldId(QString name) const;
|
||||||
|
|
||||||
|
void setRecalculateCksum(bool recalculate);
|
||||||
|
|
||||||
virtual void preProtocolHandler(QString name,
|
virtual void preProtocolHandler(QString name,
|
||||||
const QXmlStreamAttributes &attributes, int expectedPos,
|
const QXmlStreamAttributes &attributes, int expectedPos,
|
||||||
OstProto::Protocol *pbProto, OstProto::Stream *stream);
|
OstProto::Protocol *pbProto, OstProto::Stream *stream);
|
||||||
@ -63,6 +65,8 @@ protected:
|
|||||||
int ostProtoId_;
|
int ostProtoId_;
|
||||||
//!< Map of PDML field names to protobuf field numbers for 'known' fields
|
//!< Map of PDML field names to protobuf field numbers for 'known' fields
|
||||||
QMap<QString, int> fieldMap_;
|
QMap<QString, int> fieldMap_;
|
||||||
|
|
||||||
|
bool overrideCksum_{true};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,12 +42,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "udppdml.h"
|
#include "udppdml.h"
|
||||||
#include "vlanpdml.h"
|
#include "vlanpdml.h"
|
||||||
|
|
||||||
PdmlReader::PdmlReader(OstProto::StreamConfigList *streams)
|
PdmlReader::PdmlReader(OstProto::StreamConfigList *streams,
|
||||||
|
const QVariantMap &options)
|
||||||
{
|
{
|
||||||
//gPdmlReader = this;
|
//gPdmlReader = this;
|
||||||
pcap_ = NULL;
|
pcap_ = NULL;
|
||||||
streams_ = streams;
|
streams_ = streams;
|
||||||
|
|
||||||
|
recalculateCksums_ = options.value("RecalculateCksums").toBool();
|
||||||
|
|
||||||
currentStream_ = NULL;
|
currentStream_ = NULL;
|
||||||
prevStream_ = NULL;
|
prevStream_ = NULL;
|
||||||
|
|
||||||
@ -353,6 +356,8 @@ void PdmlReader::readProto()
|
|||||||
|
|
||||||
pdmlProto = appendPdmlProto(protoName, &pbProto);
|
pdmlProto = appendPdmlProto(protoName, &pbProto);
|
||||||
|
|
||||||
|
pdmlProto->setRecalculateCksum(recalculateCksums_);
|
||||||
|
|
||||||
qDebug("%s: preProtocolHandler(expPos = %d)",
|
qDebug("%s: preProtocolHandler(expPos = %d)",
|
||||||
qPrintable(protoName), expPos_);
|
qPrintable(protoName), expPos_);
|
||||||
pdmlProto->preProtocolHandler(protoName, attributes(), expPos_, pbProto,
|
pdmlProto->preProtocolHandler(protoName, attributes(), expPos_, pbProto,
|
||||||
|
@ -24,13 +24,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
#include <QVariantMap>
|
||||||
|
|
||||||
class PcapFileFormat;
|
class PcapFileFormat;
|
||||||
class PdmlReader : public QObject, public QXmlStreamReader
|
class PdmlReader : public QObject, public QXmlStreamReader
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PdmlReader(OstProto::StreamConfigList *streams);
|
PdmlReader(OstProto::StreamConfigList *streams,
|
||||||
|
const QVariantMap &options = QVariantMap());
|
||||||
~PdmlReader();
|
~PdmlReader();
|
||||||
|
|
||||||
bool read(QIODevice *device, PcapFileFormat *pcap = NULL,
|
bool read(QIODevice *device, PcapFileFormat *pcap = NULL,
|
||||||
@ -64,6 +66,8 @@ private:
|
|||||||
PcapFileFormat *pcap_;
|
PcapFileFormat *pcap_;
|
||||||
QByteArray pktBuf_;
|
QByteArray pktBuf_;
|
||||||
|
|
||||||
|
bool recalculateCksums_{false};
|
||||||
|
|
||||||
bool isMldSupport_;
|
bool isMldSupport_;
|
||||||
int packetCount_;
|
int packetCount_;
|
||||||
int expPos_;
|
int expPos_;
|
||||||
|
@ -87,7 +87,9 @@ void PdmlSampleProtocol::prematureEndHandler(int /*pos*/,
|
|||||||
fields such as length, checksum etc. may be correct or incorrect in the
|
fields such as length, checksum etc. may be correct or incorrect in the
|
||||||
PCAP/PDML - to retain the same value as in the PCAP/PDML and not let
|
PCAP/PDML - to retain the same value as in the PCAP/PDML and not let
|
||||||
Ostinato recalculate these, you can set the is_override_length,
|
Ostinato recalculate these, you can set the is_override_length,
|
||||||
is_override_cksum meta-fields to true here
|
is_override_cksum meta-fields to true here; for cksum, use the base
|
||||||
|
class attribute overrideCksum_ to decide - this is set based on user
|
||||||
|
input
|
||||||
*/
|
*/
|
||||||
void PdmlSampleProtocol::postProtocolHandler(OstProto::Protocol* /*pbProto*/,
|
void PdmlSampleProtocol::postProtocolHandler(OstProto::Protocol* /*pbProto*/,
|
||||||
OstProto::Stream* /*stream*/)
|
OstProto::Stream* /*stream*/)
|
||||||
|
@ -78,7 +78,7 @@ void PdmlTcpProtocol::postProtocolHandler(OstProto::Protocol *pbProto,
|
|||||||
tcp->set_is_override_src_port(true);
|
tcp->set_is_override_src_port(true);
|
||||||
tcp->set_is_override_dst_port(true);
|
tcp->set_is_override_dst_port(true);
|
||||||
tcp->set_is_override_hdrlen(true);
|
tcp->set_is_override_hdrlen(true);
|
||||||
tcp->set_is_override_cksum(true);
|
tcp->set_is_override_cksum(overrideCksum_);
|
||||||
|
|
||||||
if (options_.size())
|
if (options_.size())
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,6 @@ void PdmlUdpProtocol::postProtocolHandler(OstProto::Protocol *pbProto,
|
|||||||
udp->set_is_override_src_port(true);
|
udp->set_is_override_src_port(true);
|
||||||
udp->set_is_override_dst_port(true);
|
udp->set_is_override_dst_port(true);
|
||||||
udp->set_is_override_totlen(true);
|
udp->set_is_override_totlen(true);
|
||||||
udp->set_is_override_cksum(true);
|
udp->set_is_override_cksum(overrideCksum_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user