-------------------------- - AbstractProtocol Constructor and Factory function now take an optional (default NULL) "parent" abstract protocol in addition to the stream; this "parent" protocol is non-NULL for protocols which are aggregated in a ComboProtocol - All subclasses of AbstractProtocol modified as per the above interface change - ProtocolManager also modifed as per the above interface change - new data members in AbstractProtocol - prev, next; the AbstractProtocol implementation now uses these members to traverse protocols on the list instead of ProtocolListIterator; this change required for ComboProtocol - ProtocolListIterator updates these new members - prev/next on insert/remove/replace - ComboProtocol and ProtocolListIterator classes made friends of AbstractProtocol - ComboProtocol implemented as a template class (completed) - Dot2LLc implemented as a combo of Dot3Raw and LLC - Dot2Snap implemented as a combo of Dot2Llc and SNAP - VlanStack implemented as a combo of VLAN + VLAN - ProtocolManager now uses the ProtocolId enums rather than hardcoded values Stream Config Dialog -------------------- - "None" radio button added to all protocol levels - Protocol Level 1 added with 'mac' as the only valid protocol in the "simple" mode widget - With Dot2Llc, Dot2Snap and VlanStack implemented as "combo" protocols, the protocol choice radiobuttons in the "simple" mode are now 1:1 with a protocol; this has the following implications/advantages: - Updates of the "simple" mode widget from/to stream's protocolList is simpler; this code has now been rewritten to take advantage of 1:1 - This paves the way for exporting tunneled protocols 4over4, 4over6, 6over4 etc. in the "simple" mode - This should also (hopefully) require less changes when adding a new protocol; more work needs to be done to reach this goal Fixes ----- - Dot3Protocol now derives "length" correctly for VLAN tagged packets - StreamBase now uses the ProtocolListIterator to append the default protocols in a stream instead of directly manipulating ProtocolList; also in protoDataCopyFrom() Others (Client/Server) ---------------------- - Port Packet Capture implemented; "view capture" is pending (hack put in place now for testing)
89 lines
2.9 KiB
C++
89 lines
2.9 KiB
C++
#include "protocolmanager.h"
|
|
|
|
// FIXME(HI): remove
|
|
#include "protocol.pb.h"
|
|
#include "abstractprotocol.h"
|
|
|
|
#include "mac.h"
|
|
#include "payload.h"
|
|
|
|
#include "eth2.h"
|
|
#include "dot3.h"
|
|
#include "llc.h"
|
|
#include "snap.h"
|
|
#include "dot2llc.h"
|
|
#include "dot2snap.h"
|
|
#include "vlan.h"
|
|
#include "vlanstack.h"
|
|
#include "ip4.h"
|
|
#include "tcp.h"
|
|
#include "udp.h"
|
|
|
|
ProtocolManager OstProtocolManager;
|
|
|
|
ProtocolManager::ProtocolManager()
|
|
{
|
|
registerProtocol(OstProto::Protocol::kMacFieldNumber,
|
|
QString("mac"), (void*) MacProtocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kPayloadFieldNumber,
|
|
QString("payload"), (void*) PayloadProtocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kEth2FieldNumber,
|
|
QString("eth2"), (void*) Eth2Protocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kDot3FieldNumber,
|
|
QString("dot3"), (void*) Dot3Protocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kLlcFieldNumber,
|
|
QString("llc"), (void*) LlcProtocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kSnapFieldNumber,
|
|
QString("snap"), (void*) SnapProtocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kDot2LlcFieldNumber,
|
|
QString("dot2Llc"), (void*) Dot2LlcProtocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kDot2SnapFieldNumber,
|
|
QString("dot2Snap"), (void*) Dot2SnapProtocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kVlanFieldNumber,
|
|
QString("vlan"), (void*) VlanProtocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kVlanStackFieldNumber,
|
|
QString("vlanstack"), (void*) VlanStackProtocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kIp4FieldNumber,
|
|
QString("ip4"), (void*) Ip4Protocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kTcpFieldNumber,
|
|
QString("tcp"), (void*) TcpProtocol::createInstance);
|
|
registerProtocol(OstProto::Protocol::kUdpFieldNumber,
|
|
QString("udp"), (void*) UdpProtocol::createInstance);
|
|
}
|
|
|
|
void ProtocolManager::registerProtocol(int protoNumber, QString protoName,
|
|
void *protoInstanceCreator)
|
|
{
|
|
// TODO: validate incoming params for duplicates with existing
|
|
nameToNumberMap.insert(protoName, protoNumber);
|
|
numberToNameMap.insert(protoNumber, protoName);
|
|
factory.insert(protoNumber, protoInstanceCreator);
|
|
}
|
|
|
|
AbstractProtocol* ProtocolManager::createProtocol(int protoNumber,
|
|
StreamBase *stream, AbstractProtocol *parent)
|
|
{
|
|
AbstractProtocol* (*pc)(StreamBase*, AbstractProtocol*);
|
|
AbstractProtocol* p;
|
|
|
|
pc = (AbstractProtocol* (*)(StreamBase*, AbstractProtocol*))
|
|
factory.value(protoNumber);
|
|
|
|
Q_ASSERT(pc != NULL);
|
|
|
|
p = (*pc)(stream, parent);
|
|
|
|
return p;
|
|
}
|
|
|
|
AbstractProtocol* ProtocolManager::createProtocol(QString protoName,
|
|
StreamBase *stream, AbstractProtocol *parent)
|
|
{
|
|
return createProtocol(nameToNumberMap.value(protoName), stream, parent);
|
|
}
|
|
|
|
QStringList ProtocolManager::protocolDatabase()
|
|
{
|
|
return numberToNameMap.values();
|
|
}
|