Modified ICMP protocol such that the 'Id' and 'Seq' fields are shown and used only for those ICMP types that actually have those fields
This commit is contained in:
parent
4d83432a5d
commit
11acbf201d
@ -41,6 +41,11 @@ void PacketModel::setSelectedProtocols(ProtocolListIterator &iter)
|
||||
mSelectedProtocols = currentProtocols;
|
||||
reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
emit layoutChanged();
|
||||
}
|
||||
}
|
||||
|
||||
int PacketModel::rowCount(const QModelIndex &parent) const
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
|
||||
virtual int fieldCount() const;
|
||||
int metaFieldCount() const;
|
||||
int frameFieldCount() const;
|
||||
virtual int frameFieldCount() const;
|
||||
|
||||
virtual FieldFlags fieldFlags(int index) const;
|
||||
virtual QVariant fieldData(int index, FieldAttrib attrib,
|
||||
|
@ -17,32 +17,61 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#include <qendian.h>
|
||||
|
||||
#include "icmp.h"
|
||||
|
||||
#include <QSet>
|
||||
#include <qendian.h>
|
||||
|
||||
const int kIcmpEchoReply = 0;
|
||||
const int kIcmpDestinationUnreachable = 3;
|
||||
const int kIcmpSourceQuench = 4;
|
||||
const int kIcmpRedirect = 5;
|
||||
const int kIcmpEchoRequest = 8;
|
||||
const int kIcmpTimeExceeded = 11;
|
||||
const int kIcmpParameterProblem = 12;
|
||||
const int kIcmpTimestampRequest = 13;
|
||||
const int kIcmpTimestampReply = 14;
|
||||
const int kIcmpInformationRequest = 15;
|
||||
const int kIcmpInformationReply = 16;
|
||||
const int kIcmpAddressMaskRequest = 17;
|
||||
const int kIcmpAddressMaskReply = 18;
|
||||
|
||||
static QSet<int> idSeqSet = QSet<int>()
|
||||
<< kIcmpEchoRequest
|
||||
<< kIcmpEchoReply
|
||||
<< kIcmpInformationRequest
|
||||
<< kIcmpInformationReply;
|
||||
|
||||
IcmpConfigForm::IcmpConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
typeCombo->setValidator(new QIntValidator(0, 0xFF, this));
|
||||
typeCombo->addItem(0, "Echo Reply");
|
||||
typeCombo->addItem(3, "Destination Unreachable");
|
||||
typeCombo->addItem(4, "Source Quench");
|
||||
typeCombo->addItem(5, "Redirect");
|
||||
typeCombo->addItem(8, "Echo Request");
|
||||
typeCombo->addItem(11, "Time Exceeded");
|
||||
typeCombo->addItem(12, "Parameter Problem");
|
||||
typeCombo->addItem(13, "Timestamp Request");
|
||||
typeCombo->addItem(14, "Timestamp Reply");
|
||||
typeCombo->addItem(17, "Address Mask Request");
|
||||
typeCombo->addItem(18, "Address Mask Reply");
|
||||
typeCombo->addItem(kIcmpEchoReply, "Echo Reply");
|
||||
typeCombo->addItem(kIcmpDestinationUnreachable, "Destination Unreachable");
|
||||
typeCombo->addItem(kIcmpSourceQuench, "Source Quench");
|
||||
typeCombo->addItem(kIcmpRedirect, "Redirect");
|
||||
typeCombo->addItem(kIcmpEchoRequest, "Echo Request");
|
||||
typeCombo->addItem(kIcmpTimeExceeded, "Time Exceeded");
|
||||
typeCombo->addItem(kIcmpParameterProblem, "Parameter Problem");
|
||||
typeCombo->addItem(kIcmpTimestampRequest, "Timestamp Request");
|
||||
typeCombo->addItem(kIcmpTimestampReply, "Timestamp Reply");
|
||||
typeCombo->addItem(kIcmpInformationRequest, "Information Request");
|
||||
typeCombo->addItem(kIcmpInformationReply, "Information Reply");
|
||||
typeCombo->addItem(kIcmpAddressMaskRequest, "Address Mask Request");
|
||||
typeCombo->addItem(kIcmpAddressMaskReply, "Address Mask Reply");
|
||||
|
||||
idEdit->setValidator(new QIntValidator(0, 0xFFFF, this));
|
||||
seqEdit->setValidator(new QIntValidator(0, 0xFFFF, this));
|
||||
}
|
||||
|
||||
void IcmpConfigForm::on_typeCombo_currentIndexChanged(int /*index*/)
|
||||
{
|
||||
idSeqFrame->setVisible(idSeqSet.contains(typeCombo->currentValue()));
|
||||
}
|
||||
|
||||
IcmpProtocol::IcmpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||
: AbstractProtocol(stream, parent)
|
||||
{
|
||||
@ -104,6 +133,16 @@ int IcmpProtocol::fieldCount() const
|
||||
return icmp_fieldCount;
|
||||
}
|
||||
|
||||
int IcmpProtocol::frameFieldCount() const
|
||||
{
|
||||
int count = AbstractProtocol::frameFieldCount();
|
||||
|
||||
if (!idSeqSet.contains(fieldData(icmp_type, FieldValue).toUInt()))
|
||||
count -=2;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
AbstractProtocol::FieldFlags IcmpProtocol::fieldFlags(int index) const
|
||||
{
|
||||
AbstractProtocol::FieldFlags flags;
|
||||
@ -122,6 +161,8 @@ AbstractProtocol::FieldFlags IcmpProtocol::fieldFlags(int index) const
|
||||
|
||||
case icmp_identifier:
|
||||
case icmp_sequence:
|
||||
if (!idSeqSet.contains(fieldData(icmp_type, FieldValue).toUInt()))
|
||||
flags |= FieldIsMeta;
|
||||
break;
|
||||
|
||||
case icmp_is_override_checksum:
|
||||
@ -169,7 +210,7 @@ QVariant IcmpProtocol::fieldData(int index, FieldAttrib attrib,
|
||||
switch(attrib)
|
||||
{
|
||||
case FieldName:
|
||||
return QString("code");
|
||||
return QString("Code");
|
||||
case FieldValue:
|
||||
return code;
|
||||
case FieldTextValue:
|
||||
|
@ -27,11 +27,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
/*
|
||||
Icmp Protocol Frame Format -
|
||||
+-----+------+------+-----+-----+
|
||||
| TYP | CODE | CSUM | ID | SEQ |
|
||||
| (1) | (1) | (2) | (2) | (2) |
|
||||
+-----+------+------+-----+-----+
|
||||
Figures in brackets represent field width in bytes
|
||||
+-----+------+------+------+-------+
|
||||
| TYP | CODE | CSUM | [ID] | [SEQ] |
|
||||
| (1) | (1) | (2) | (2) | (2) |
|
||||
+-----+------+------+------+-------+
|
||||
Fields within [] are applicable only to certain TYPEs
|
||||
Figures in braces represent field width in bytes
|
||||
*/
|
||||
|
||||
class IcmpConfigForm : public QWidget, public Ui::Icmp
|
||||
@ -40,6 +41,7 @@ class IcmpConfigForm : public QWidget, public Ui::Icmp
|
||||
public:
|
||||
IcmpConfigForm(QWidget *parent = 0);
|
||||
private slots:
|
||||
void on_typeCombo_currentIndexChanged(int index);
|
||||
};
|
||||
|
||||
class IcmpProtocol : public AbstractProtocol
|
||||
@ -79,6 +81,7 @@ public:
|
||||
virtual QString shortName() const;
|
||||
|
||||
virtual int fieldCount() const;
|
||||
virtual int frameFieldCount() const;
|
||||
|
||||
virtual AbstractProtocol::FieldFlags fieldFlags(int index) const;
|
||||
virtual QVariant fieldData(int index, FieldAttrib attrib,
|
||||
|
@ -5,8 +5,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>258</width>
|
||||
<height>168</height>
|
||||
<width>291</width>
|
||||
<height>190</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -66,41 +66,53 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Identifier</string>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<widget class="QFrame" name="idSeqFrame" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>idEdit</cstring>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Identifier</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>idEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="idEdit" />
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<string>Sequence</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>seqEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="seqEdit" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QLineEdit" name="idEdit" />
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<string>Sequence</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>seqEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" >
|
||||
<widget class="QLineEdit" name="seqEdit" />
|
||||
</item>
|
||||
<item row="5" column="1" >
|
||||
<item row="4" column="0" colspan="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<width>137</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
Loading…
Reference in New Issue
Block a user