IP4over4 implemented as a "combo" protocol; added IP 4over4 as a L3 protocol in StreamConfigDialog. Also temporarily masked a change introduced in r59ec which triggers a crash if you click "cancel" in StreamConfigDialog with the "Protocol Data" tab open

This commit is contained in:
Srivats P. 2010-05-09 10:28:58 +05:30
parent 564b30955b
commit 46cebefb19
9 changed files with 173 additions and 26 deletions

View File

@ -200,6 +200,8 @@ void StreamConfigDialog::setupUiExtra()
bgProto[ProtoL3]->addButton(rbL3Ipv4, OstProto::Protocol::kIp4FieldNumber);
bgProto[ProtoL3]->addButton(rbL3Ipv6, 0xFFFF);
bgProto[ProtoL3]->addButton(rbL3Arp, OstProto::Protocol::kArpFieldNumber);
bgProto[ProtoL3]->addButton(rbL3Ip4over4,
OstProto::Protocol::kIp4over4FieldNumber);
bgProto[ProtoL3]->addButton(rbL3Other, ButtonIdOther);
#endif
@ -952,8 +954,10 @@ void StreamConfigDialog::on_tbProtocolData_currentChanged(int /*index*/)
// Refresh protocol widgets in case there is any dependent data between
// protocols e.g. TCP/UDP port numbers are dependent on Port/Protocol
// selection in TextProtocol
#if 0 // FIXME: temp mask to avoid crash till we fix it
mpStream->storeProtocolWidgets();
mpStream->loadProtocolWidgets();
#endif
}
void StreamConfigDialog::on_pbOk_clicked()

View File

@ -8,7 +8,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>569</width>
<width>579</width>
<height>481</height>
</rect>
</property>
@ -173,7 +173,7 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff
<rect>
<x>0</x>
<y>0</y>
<width>527</width>
<width>537</width>
<height>243</height>
</rect>
</property>
@ -339,6 +339,19 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff
</widget>
</item>
<item row="1" column="1" >
<widget class="QRadioButton" name="rbL3Ip4over4" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>IP 4over4</string>
</property>
<property name="checked" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QRadioButton" name="rbL3Other" >
<property name="enabled" >
<bool>false</bool>

View File

@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
template <int protoNumber, class ProtoA, class ProtoB>
class ComboProtocol : public AbstractProtocol
{
private:
protected:
ProtoA *protoA;
ProtoB *protoB;
QWidget *configForm;
@ -82,8 +82,7 @@ public:
// NOTE: To use protoX->protoDataCopyFrom() we need to arrange
// so that it sees its own protocolNumber() - but since the
// input param 'protocol' is 'const', we make a copy first
// input param 'protocol' is 'const', we work on a copy
proto.CopyFrom(protocol);
proto.mutable_protocol_id()->set_id(protoA->protocolNumber());

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>527</width>
<height>296</height>
<width>493</width>
<height>308</height>
</rect>
</property>
<property name="windowTitle" >
@ -35,7 +35,8 @@
<item row="1" column="0" >
<widget class="QCheckBox" name="cbIpHdrLenOverride" >
<property name="text" >
<string>Override Header Length (x4)</string>
<string>Override Header
Length (x4)</string>
</property>
</widget>
</item>
@ -66,16 +67,6 @@
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QToolButton" name="toolButton" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QCheckBox" name="cbIpLengthOverride" >
<property name="text" >
@ -106,13 +97,6 @@
</item>
</layout>
</item>
<item row="0" column="1" >
<widget class="Line" name="line_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="2" >
<layout class="QGridLayout" >
<item row="0" column="0" >

101
common/ip4over4.h Normal file
View File

@ -0,0 +1,101 @@
/*
Copyright (C) 2010 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 _IP_4_OVER_4_H
#define _IP_4_OVER_4_H
#include "ip4over4.pb.h"
#include "comboprotocol.h"
#include "ip4.h"
typedef ComboProtocol<OstProto::Protocol::kIp4over4FieldNumber,
Ip4Protocol, Ip4Protocol> Ip4over4Combo;
class Ip4over4Protocol : public Ip4over4Combo
{
public:
Ip4over4Protocol(StreamBase *stream, AbstractProtocol *parent = 0)
: Ip4over4Combo(stream, parent)
{
}
static Ip4over4Protocol* createInstance(StreamBase *stream,
AbstractProtocol *parent)
{
return new Ip4over4Protocol(stream, parent);
}
virtual void protoDataCopyInto(OstProto::Protocol &protocol) const
{
OstProto::Protocol tempProto;
protoA->protoDataCopyInto(tempProto);
protocol.MutableExtension(OstProto::ip4over4)
->MutableExtension(OstProto::ip4_outer)
->CopyFrom(tempProto.GetExtension(OstProto::ip4));
tempProto.Clear();
protoB->protoDataCopyInto(tempProto);
protocol.MutableExtension(OstProto::ip4over4)
->MutableExtension(OstProto::ip4_inner)
->CopyFrom(tempProto.GetExtension(OstProto::ip4));
protocol.mutable_protocol_id()->set_id(protocolNumber());
}
virtual void protoDataCopyFrom(const OstProto::Protocol &protocol)
{
if (protocol.protocol_id().id() == protocolNumber()
&& protocol.HasExtension(OstProto::ip4over4))
{
OstProto::Protocol tempProto;
// NOTE: To use protoX->protoDataCopyFrom() we need to arrange
// so that it sees its own protocolNumber() and its own extension
// in 'protocol'
tempProto.mutable_protocol_id()->set_id(protoA->protocolNumber());
tempProto.MutableExtension(OstProto::ip4)->CopyFrom(
protocol.GetExtension(OstProto::ip4over4).GetExtension(
OstProto::ip4_outer));
protoA->protoDataCopyFrom(tempProto);
tempProto.Clear();
tempProto.mutable_protocol_id()->set_id(protoB->protocolNumber());
tempProto.MutableExtension(OstProto::ip4)->CopyFrom(
protocol.GetExtension(OstProto::ip4over4).GetExtension(
OstProto::ip4_inner));
protoB->protoDataCopyFrom(tempProto);
}
}
virtual quint32 protocolFrameCksum(int streamIndex = 0,
CksumType cksumType = CksumIp) const
{
// For a Pseudo IP cksum, we assume it is the succeeding protocol
// that is requesting it and hence return protoB's cksum;
if (cksumType == CksumIpPseudo)
return protoB->protocolFrameCksum(streamIndex, cksumType);
return Ip4over4Combo::protocolFrameCksum(streamIndex, cksumType);
}
};
#endif

37
common/ip4over4.proto Normal file
View File

@ -0,0 +1,37 @@
/*
Copyright (C) 2010 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/>
*/
import "protocol.proto";
import "ip4.proto";
package OstProto;
// IP 4over4 (also called IPIP)
message Ip4over4 {
extensions 1 to 2;
}
extend Ip4over4 {
optional Ip4 ip4_outer = 1;
optional Ip4 ip4_inner = 2;
}
extend Protocol {
optional Ip4over4 ip4over4 = 132;
}

View File

@ -34,6 +34,7 @@ PROTOS += \
vlanstack.proto \
arp.proto \
ip4.proto \
ip4over4.proto \
icmp.proto \
tcp.proto \
udp.proto \
@ -60,6 +61,7 @@ HEADERS += \
vlanstack.h \
arp.h \
ip4.h \
ip4over4.h \
icmp.h \
tcp.h \
udp.h \

View File

@ -101,6 +101,7 @@ message Protocol {
kIp4FieldNumber = 130;
kArpFieldNumber = 131;
kIp4over4FieldNumber = 132;
kTcpFieldNumber = 140;
kUdpFieldNumber = 141;

View File

@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "vlanstack.h"
#include "arp.h"
#include "ip4.h"
#include "ip4over4.h"
#include "icmp.h"
#include "tcp.h"
#include "udp.h"
@ -49,6 +50,7 @@ ProtocolManager::ProtocolManager()
*/
registerProtocol(OstProto::Protocol::kMacFieldNumber,
(void*) MacProtocol::createInstance);
registerProtocol(OstProto::Protocol::kEth2FieldNumber,
(void*) Eth2Protocol::createInstance);
registerProtocol(OstProto::Protocol::kDot3FieldNumber,
@ -61,23 +63,27 @@ ProtocolManager::ProtocolManager()
(void*) Dot2LlcProtocol::createInstance);
registerProtocol(OstProto::Protocol::kDot2SnapFieldNumber,
(void*) Dot2SnapProtocol::createInstance);
registerProtocol(OstProto::Protocol::kSvlanFieldNumber,
(void*) SVlanProtocol::createInstance);
registerProtocol(OstProto::Protocol::kVlanFieldNumber,
(void*) VlanProtocol::createInstance);
registerProtocol(OstProto::Protocol::kVlanStackFieldNumber,
(void*) VlanStackProtocol::createInstance);
registerProtocol(OstProto::Protocol::kArpFieldNumber,
(void*) ArpProtocol::createInstance);
registerProtocol(OstProto::Protocol::kIp4FieldNumber,
(void*) Ip4Protocol::createInstance);
registerProtocol(OstProto::Protocol::kIp4over4FieldNumber,
(void*) Ip4over4Protocol::createInstance);
registerProtocol(OstProto::Protocol::kIcmpFieldNumber,
(void*) IcmpProtocol::createInstance);
registerProtocol(OstProto::Protocol::kTcpFieldNumber,
(void*) TcpProtocol::createInstance);
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
(void*) UdpProtocol::createInstance);
registerProtocol(OstProto::Protocol::kTextProtocolFieldNumber,
(void*) TextProtocol::createInstance);