From 610ee312a0bad8cc6c27dc12f7ded531033c10c7 Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Sun, 3 Apr 2011 14:13:57 +0530 Subject: [PATCH] snapshot before rewriting PDML TextProto --- common/pdml_p.cpp | 60 +++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/common/pdml_p.cpp b/common/pdml_p.cpp index 063dd63..f76e116 100644 --- a/common/pdml_p.cpp +++ b/common/pdml_p.cpp @@ -211,9 +211,9 @@ PdmlReader::PdmlReader(OstProto::StreamConfigList *streams) factory_.insert("ip", PdmlIp4Protocol::createInstance); factory_.insert("ipv6", PdmlIp6Protocol::createInstance); factory_.insert("llc", PdmlLlcProtocol::createInstance); - //factory_.insert("nntp", PdmlTextProtocol::createInstance); - //factory_.insert("rtsp", PdmlTextProtocol::createInstance); - //factory_.insert("sip", PdmlTextProtocol::createInstance); + factory_.insert("nntp", PdmlTextProtocol::createInstance); + factory_.insert("rtsp", PdmlTextProtocol::createInstance); + factory_.insert("sip", PdmlTextProtocol::createInstance); factory_.insert("tcp", PdmlTcpProtocol::createInstance); factory_.insert("udp", PdmlUdpProtocol::createInstance); factory_.insert("udplite", PdmlUdpProtocol::createInstance); @@ -409,8 +409,8 @@ void PdmlReader::readProto() if (!attributes().value("size").isEmpty()) size = attributes().value("size").toString().toInt(); - qDebug("proto: %s, pos = %d, expPos_ = %d", - protoName.toAscii().constData(), pos, expPos_); + qDebug("proto: %s, pos = %d, expPos_ = %d, size = %d", + protoName.toAscii().constData(), pos, expPos_, size); // This is a heuristic to skip protocols which are not part of // this frame, but of a reassembled segment spanning several frames @@ -1456,6 +1456,7 @@ void PdmlTextProtocol::preProtocolHandler(QString name, endPos_ = expPos_ + size; _skip_pos_size_proc: + qDebug("expPos_ = %d, endPos_ = %d", expPos_, endPos_); OstProto::TextProtocol *text = pbProto->MutableExtension( OstProto::textProtocol); @@ -1469,30 +1470,49 @@ void PdmlTextProtocol::unknownFieldHandler(QString name, int pos, int size, const QXmlStreamAttributes &attributes, OstProto::Protocol *pbProto, OstProto::Stream *stream) { + if (name == "data") + contentType_ = kOtherContent; + + if (contentType_ == kOtherContent) + return; + if (contentType_ == kUnknownContent) - { - if (name == "data") - contentType_ = kOtherContent; - else - contentType_ = kTextContent; - } - else if (contentType_ == kOtherContent) - return; - else // kTextContent - { - if (name == "data") - contentType_ = kOtherContent; - return; - } + contentType_ = kTextContent; // We process only kTextContent - if (pos != expPos_) + if (pos < expPos_) return; if ((pos + size) > endPos_) return; + if (pos > expPos_) + { + int gap = pos - expPos_; + QString eol; + QByteArray filler; + OstProto::TextProtocol *text = pbProto->MutableExtension( + OstProto::textProtocol); + + switch(text->eol()) + { + case OstProto::TextProtocol::kCr: eol = "\r"; break; + case OstProto::TextProtocol::kLf: eol = "\n"; break; + case OstProto::TextProtocol::kCrLf: eol = "\r\n"; break; + default: Q_ASSERT(false); + } + eol = "\n"; + + for (int i = 0; i < gap; i++) + filler += eol; + + filler.resize(gap); + + text->mutable_text()->append(filler.constData(), filler.size()); + expPos_ += gap; + } + if (attributes.value("show") == "HTTP chunked response") return;