diff --git a/client/streamconfigdialog.cpp b/client/streamconfigdialog.cpp index e4544e5..993cd1c 100644 --- a/client/streamconfigdialog.cpp +++ b/client/streamconfigdialog.cpp @@ -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 diff --git a/client/streamconfigdialog.ui b/client/streamconfigdialog.ui index 687b970..43c56b6 100644 --- a/client/streamconfigdialog.ui +++ b/client/streamconfigdialog.ui @@ -8,8 +8,8 @@ 0 0 - 579 - 481 + 626 + 507 @@ -173,8 +173,8 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff 0 0 - 537 - 243 + 584 + 269 @@ -306,6 +306,16 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff + + + false + + + ARP + + + + false @@ -318,7 +328,7 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff - + false @@ -328,17 +338,33 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff - - + + false - ARP + IP 6over4 + + + false - + + + + false + + + IP 4over6 + + + false + + + + false @@ -351,7 +377,20 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff - + + + + false + + + IP 6over6 + + + false + + + + false @@ -520,19 +559,6 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff - - - - Qt::Vertical - - - - 20 - 71 - - - - @@ -575,6 +601,19 @@ QLineEdit:enabled[inputMask = "HH HH HH HH HH HH; "] { background-color: #ccccff + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/common/arp.proto b/common/arp.proto index 9a4bd52..c4a60e4 100644 --- a/common/arp.proto +++ b/common/arp.proto @@ -63,5 +63,5 @@ message Arp { } extend Protocol { - optional Arp arp = 131; + optional Arp arp = 130; } diff --git a/common/comboprotocol.h b/common/comboprotocol.h index c7d4053..29cf71d 100644 --- a/common/comboprotocol.h +++ b/common/comboprotocol.h @@ -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, diff --git a/common/ip4.proto b/common/ip4.proto index 9914977..6014321 100644 --- a/common/ip4.proto +++ b/common/ip4.proto @@ -61,5 +61,5 @@ message Ip4 { } extend Protocol { - optional Ip4 ip4 = 130; + optional Ip4 ip4 = 131; } diff --git a/common/ip4over4.h b/common/ip4over4.h index cf6c5f5..9ca1be7 100644 --- a/common/ip4over4.h +++ b/common/ip4over4.h @@ -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 diff --git a/common/ip4over4.proto b/common/ip4over4.proto index df25a32..3da405a 100644 --- a/common/ip4over4.proto +++ b/common/ip4over4.proto @@ -33,5 +33,5 @@ extend Ip4over4 { } extend Protocol { - optional Ip4over4 ip4over4 = 132; + optional Ip4over4 ip4over4 = 135; } diff --git a/common/ip4over6.h b/common/ip4over6.h new file mode 100644 index 0000000..41bcce0 --- /dev/null +++ b/common/ip4over6.h @@ -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 +*/ + +#ifndef _IP_4_OVER_6_H +#define _IP_4_OVER_6_H + +#include "comboprotocol.h" +#include "ip4.h" +#include "ip6.h" + +typedef ComboProtocol Ip4over6Protocol; + +#endif diff --git a/common/ip4over6.proto b/common/ip4over6.proto new file mode 100644 index 0000000..11d26e4 --- /dev/null +++ b/common/ip4over6.proto @@ -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 +*/ + +import "protocol.proto"; + +package OstProto; + +// IP Tunelling - IP 4over6 +message Ip4over6 { + // Empty since this is a 'combo' protocol +} + +extend Protocol { + optional Ip4over6 ip4over6 = 134; +} diff --git a/common/ip6.cpp b/common/ip6.cpp index ea1f22c..8ac6fca 100644 --- a/common/ip6.cpp +++ b/common/ip6.cpp @@ -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; diff --git a/common/ip6.proto b/common/ip6.proto index f47f26a..aed96f2 100644 --- a/common/ip6.proto +++ b/common/ip6.proto @@ -57,5 +57,5 @@ message Ip6 { } extend Protocol { - optional Ip6 ip6 = 133; + optional Ip6 ip6 = 132; } diff --git a/common/ip6over4.h b/common/ip6over4.h new file mode 100644 index 0000000..08ee19b --- /dev/null +++ b/common/ip6over4.h @@ -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 +*/ + +#ifndef _IP_6_OVER_4_H +#define _IP_6_OVER_4_H + +#include "comboprotocol.h" +#include "ip4.h" +#include "ip6.h" + +typedef ComboProtocol Ip6over4Protocol; + +#endif diff --git a/common/ip6over4.proto b/common/ip6over4.proto new file mode 100644 index 0000000..47fee75 --- /dev/null +++ b/common/ip6over4.proto @@ -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 +*/ + +import "protocol.proto"; + +package OstProto; + +// IP Tunelling - IP 6over4 +message Ip6over4 { + // Empty since this is a 'combo' protocol +} + +extend Protocol { + optional Ip6over4 ip6over4 = 133; +} diff --git a/common/ip6over6.h b/common/ip6over6.h new file mode 100644 index 0000000..133d4f9 --- /dev/null +++ b/common/ip6over6.h @@ -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 +*/ + +#ifndef _IP_6_OVER_6_H +#define _IP_6_OVER_6_H + +#include "ip6over6.pb.h" + +#include "comboprotocol.h" +#include "ip6.h" + +typedef ComboProtocol 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 diff --git a/common/ip6over6.proto b/common/ip6over6.proto new file mode 100644 index 0000000..f260916 --- /dev/null +++ b/common/ip6over6.proto @@ -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 +*/ + +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; +} diff --git a/common/ostproto.pro b/common/ostproto.pro index 8a4c65b..e16b4b3 100644 --- a/common/ostproto.pro +++ b/common/ostproto.pro @@ -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 \ diff --git a/common/protocol.proto b/common/protocol.proto index dddc087..2a5502a 100644 --- a/common/protocol.proto +++ b/common/protocol.proto @@ -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; diff --git a/common/protocolmanager.cpp b/common/protocolmanager.cpp index 64a537a..0910e1a 100644 --- a/common/protocolmanager.cpp +++ b/common/protocolmanager.cpp @@ -34,7 +34,10 @@ along with this program. If not, see #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);