Implemented the remaining IP Tunneling protocols - IP6over4, IP4over6, IP6over6; renumbered L3 protocol protobuf "field numbers". ComboProtocol now implements PseudoIp cksum as protoB's cksum as a convenience for the IP tunneling protocols. Also found and fixed an issue with IPv6's pseudoIp cksum which was causing the TCP/UDP cksums to be incorrect

This commit is contained in:
Srivats P. 2010-05-23 16:46:43 +05:30
parent 4a70d52e3e
commit 956455137c
18 changed files with 357 additions and 46 deletions

View File

@ -198,11 +198,17 @@ void StreamConfigDialog::setupUiExtra()
bgProto[ProtoL3]->addButton(btn);
#else
bgProto[ProtoL3]->addButton(rbL3None, ButtonIdNone);
bgProto[ProtoL3]->addButton(rbL3Arp, OstProto::Protocol::kArpFieldNumber);
bgProto[ProtoL3]->addButton(rbL3Ipv4, OstProto::Protocol::kIp4FieldNumber);
bgProto[ProtoL3]->addButton(rbL3Ipv6, OstProto::Protocol::kIp6FieldNumber);
bgProto[ProtoL3]->addButton(rbL3Arp, OstProto::Protocol::kArpFieldNumber);
bgProto[ProtoL3]->addButton(rbL3Ip6over4,
OstProto::Protocol::kIp6over4FieldNumber);
bgProto[ProtoL3]->addButton(rbL3Ip4over6,
OstProto::Protocol::kIp4over6FieldNumber);
bgProto[ProtoL3]->addButton(rbL3Ip4over4,
OstProto::Protocol::kIp4over4FieldNumber);
bgProto[ProtoL3]->addButton(rbL3Ip6over6,
OstProto::Protocol::kIp6over6FieldNumber);
bgProto[ProtoL3]->addButton(rbL3Other, ButtonIdOther);
#endif

View File

@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>579</width>
<height>481</height>
<width>626</width>
<height>507</height>
</rect>
</property>
<property name="sizePolicy" >
@ -173,8 +173,8 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff
<rect>
<x>0</x>
<y>0</y>
<width>537</width>
<height>243</height>
<width>584</width>
<height>269</height>
</rect>
</property>
<attribute name="label" >
@ -306,6 +306,16 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff
</widget>
</item>
<item row="0" column="1" >
<widget class="QRadioButton" name="rbL3Arp" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>ARP</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QRadioButton" name="rbL3Ipv4" >
<property name="enabled" >
<bool>false</bool>
@ -318,7 +328,7 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff
</property>
</widget>
</item>
<item row="0" column="2" >
<item row="1" column="0" >
<widget class="QRadioButton" name="rbL3Ipv6" >
<property name="enabled" >
<bool>false</bool>
@ -328,17 +338,33 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QRadioButton" name="rbL3Arp" >
<item row="1" column="1" >
<widget class="QRadioButton" name="rbL3Ip6over4" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>ARP</string>
<string>IP 6over4</string>
</property>
<property name="checked" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1" >
<item row="1" column="2" >
<widget class="QRadioButton" name="rbL3Ip4over6" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>IP 4over6</string>
</property>
<property name="checked" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QRadioButton" name="rbL3Ip4over4" >
<property name="enabled" >
<bool>false</bool>
@ -351,7 +377,20 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff
</property>
</widget>
</item>
<item row="1" column="2" >
<item row="2" column="1" >
<widget class="QRadioButton" name="rbL3Ip6over6" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>IP 6over6</string>
</property>
<property name="checked" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QRadioButton" name="rbL3Other" >
<property name="enabled" >
<bool>false</bool>
@ -520,19 +559,6 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff
</layout>
</widget>
</item>
<item rowspan="2" row="2" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>71</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2" >
<widget class="QGroupBox" name="gbL5Proto" >
<property name="enabled" >
@ -575,6 +601,19 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff
</layout>
</widget>
</item>
<item row="3" column="3" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2" >

View File

@ -63,5 +63,5 @@ message Arp {
}
extend Protocol {
optional Arp arp = 131;
optional Arp arp = 130;
}

View File

@ -170,9 +170,17 @@ public:
|| protoB->isProtocolFrameSizeVariable());
}
#if 0
virtual quint32 protocolFrameCksum(int streamIndex = 0,
CksumType cksumType = CksumIp) const;
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 AbstractProtocol::protocolFrameCksum(streamIndex, cksumType);
}
#if 0
quint32 protocolFrameHeaderCksum(int streamIndex = 0,
CksumType cksumType = CksumIp) const;
quint32 protocolFramePayloadCksum(int streamIndex = 0,

View File

@ -61,5 +61,5 @@ message Ip4 {
}
extend Protocol {
optional Ip4 ip4 = 130;
optional Ip4 ip4 = 131;
}

View File

@ -86,16 +86,6 @@ public:
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

View File

@ -33,5 +33,5 @@ extend Ip4over4 {
}
extend Protocol {
optional Ip4over4 ip4over4 = 132;
optional Ip4over4 ip4over4 = 135;
}

30
common/ip4over6.h Normal file
View File

@ -0,0 +1,30 @@
/*
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_6_H
#define _IP_4_OVER_6_H
#include "comboprotocol.h"
#include "ip4.h"
#include "ip6.h"
typedef ComboProtocol<OstProto::Protocol::kIp4over6FieldNumber,
Ip6Protocol, Ip4Protocol> Ip4over6Protocol;
#endif

31
common/ip4over6.proto Normal file
View File

@ -0,0 +1,31 @@
/*
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";
package OstProto;
// IP Tunelling - IP 4over6
message Ip4over6 {
// Empty since this is a 'combo' protocol
}
extend Protocol {
optional Ip4over6 ip4over6 = 134;
}

View File

@ -819,13 +819,13 @@ quint32 Ip6Protocol::protocolFrameCksum(int streamIndex,
.toByteArray();
Q_ASSERT(addr.size() == 16);
for (int i = 0; i < addr.size(); i+=2)
sum += (addr.at(i) << 8) + addr.at(i+1);
sum += (quint8(addr.at(i)) << 8) + quint8(addr.at(i+1));
addr = fieldData(ip6_dstAddress, FieldFrameValue, streamIndex)
.toByteArray();
Q_ASSERT(addr.size() == 16);
for (int i = 0; i < addr.size(); i+=2)
sum += (addr.at(i) << 8) + addr.at(i+1);
sum += (quint8(addr.at(i)) << 8) + quint8(addr.at(i+1));
sum += fieldData(ip6_payloadLength, FieldValue, streamIndex)
.toUInt() & 0xFFFF;

View File

@ -57,5 +57,5 @@ message Ip6 {
}
extend Protocol {
optional Ip6 ip6 = 133;
optional Ip6 ip6 = 132;
}

30
common/ip6over4.h Normal file
View File

@ -0,0 +1,30 @@
/*
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_6_OVER_4_H
#define _IP_6_OVER_4_H
#include "comboprotocol.h"
#include "ip4.h"
#include "ip6.h"
typedef ComboProtocol<OstProto::Protocol::kIp6over4FieldNumber,
Ip4Protocol, Ip6Protocol> Ip6over4Protocol;
#endif

31
common/ip6over4.proto Normal file
View File

@ -0,0 +1,31 @@
/*
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";
package OstProto;
// IP Tunelling - IP 6over4
message Ip6over4 {
// Empty since this is a 'combo' protocol
}
extend Protocol {
optional Ip6over4 ip6over4 = 133;
}

91
common/ip6over6.h Normal file
View File

@ -0,0 +1,91 @@
/*
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_6_OVER_6_H
#define _IP_6_OVER_6_H
#include "ip6over6.pb.h"
#include "comboprotocol.h"
#include "ip6.h"
typedef ComboProtocol<OstProto::Protocol::kIp6over6FieldNumber,
Ip6Protocol, Ip6Protocol> Ip6over6Combo;
class Ip6over6Protocol : public Ip6over6Combo
{
public:
Ip6over6Protocol(StreamBase *stream, AbstractProtocol *parent = 0)
: Ip6over6Combo(stream, parent)
{
}
static Ip6over6Protocol* createInstance(StreamBase *stream,
AbstractProtocol *parent)
{
return new Ip6over6Protocol(stream, parent);
}
virtual void protoDataCopyInto(OstProto::Protocol &protocol) const
{
OstProto::Protocol tempProto;
protoA->protoDataCopyInto(tempProto);
protocol.MutableExtension(OstProto::ip6over6)
->MutableExtension(OstProto::ip6_outer)
->CopyFrom(tempProto.GetExtension(OstProto::ip6));
tempProto.Clear();
protoB->protoDataCopyInto(tempProto);
protocol.MutableExtension(OstProto::ip6over6)
->MutableExtension(OstProto::ip6_inner)
->CopyFrom(tempProto.GetExtension(OstProto::ip6));
protocol.mutable_protocol_id()->set_id(protocolNumber());
}
virtual void protoDataCopyFrom(const OstProto::Protocol &protocol)
{
if (protocol.protocol_id().id() == protocolNumber()
&& protocol.HasExtension(OstProto::ip6over6))
{
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::ip6)->CopyFrom(
protocol.GetExtension(OstProto::ip6over6).GetExtension(
OstProto::ip6_outer));
protoA->protoDataCopyFrom(tempProto);
tempProto.Clear();
tempProto.mutable_protocol_id()->set_id(protoB->protocolNumber());
tempProto.MutableExtension(OstProto::ip6)->CopyFrom(
protocol.GetExtension(OstProto::ip6over6).GetExtension(
OstProto::ip6_inner));
protoB->protoDataCopyFrom(tempProto);
}
}
};
#endif

37
common/ip6over6.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 "ip6.proto";
package OstProto;
// IP Tunnelling - IP 6over6
message Ip6over6 {
extensions 1 to 2;
}
extend Ip6over6 {
optional Ip6 ip6_outer = 1;
optional Ip6 ip6_inner = 2;
}
extend Protocol {
optional Ip6over6 ip6over6 = 136;
}

View File

@ -36,7 +36,10 @@ PROTOS += \
arp.proto \
ip4.proto \
ip6.proto \
ip6over4.proto \
ip4over6.proto \
ip4over4.proto \
ip6over6.proto \
icmp.proto \
tcp.proto \
udp.proto \
@ -64,7 +67,10 @@ HEADERS += \
arp.h \
ip4.h \
ip6.h \
ip6over4.h \
ip4over6.h \
ip4over4.h \
ip6over6.h \
icmp.h \
tcp.h \
udp.h \

View File

@ -99,10 +99,13 @@ message Protocol {
kDot2SnapFieldNumber = 128;
kVlanStackFieldNumber = 129;
kIp4FieldNumber = 130;
kArpFieldNumber = 131;
kIp4over4FieldNumber = 132;
kIp6FieldNumber = 133;
kArpFieldNumber = 130;
kIp4FieldNumber = 131;
kIp6FieldNumber = 132;
kIp6over4FieldNumber = 133;
kIp4over6FieldNumber = 134;
kIp4over4FieldNumber = 135;
kIp6over6FieldNumber = 136;
kTcpFieldNumber = 140;
kUdpFieldNumber = 141;

View File

@ -34,7 +34,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "arp.h"
#include "ip4.h"
#include "ip6.h"
#include "ip6over4.h"
#include "ip4over6.h"
#include "ip4over4.h"
#include "ip6over6.h"
#include "icmp.h"
#include "tcp.h"
#include "udp.h"
@ -78,8 +81,14 @@ ProtocolManager::ProtocolManager()
(void*) Ip4Protocol::createInstance);
registerProtocol(OstProto::Protocol::kIp6FieldNumber,
(void*) Ip6Protocol::createInstance);
registerProtocol(OstProto::Protocol::kIp6over4FieldNumber,
(void*) Ip6over4Protocol::createInstance);
registerProtocol(OstProto::Protocol::kIp4over6FieldNumber,
(void*) Ip4over6Protocol::createInstance);
registerProtocol(OstProto::Protocol::kIp4over4FieldNumber,
(void*) Ip4over4Protocol::createInstance);
registerProtocol(OstProto::Protocol::kIp6over6FieldNumber,
(void*) Ip6over6Protocol::createInstance);
registerProtocol(OstProto::Protocol::kIcmpFieldNumber,
(void*) IcmpProtocol::createInstance);