Debugger: Add dumper support for IPv6 in QHostAddress

Change-Id: Ia542cf9e3c695a2c3c4b6340c3d72dfe743339c6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Thiago Macieira
2013-07-09 14:19:45 -07:00
parent f6a9a69ee4
commit 62fb22278c
6 changed files with 72 additions and 14 deletions

View File

@@ -32,6 +32,7 @@
#include <QCoreApplication>
#include <QDateTime>
#include <QDebug>
#include <QHostAddress>
#include <ctype.h>
@@ -611,6 +612,18 @@ QString decodeData(const QByteArray &ba, int encoding)
const QTime time = timeFromData(ba.mid(p + 1 ).toInt());
return QDateTime(date, time).toString(Qt::TextDate);
}
case IPv6AddressAndHexScopeId: { // 27, 16 hex-encoded bytes, "%" and the string-encoded scope
const int p = ba.indexOf('%');
QHostAddress ip6(QString::fromLatin1(p == -1 ? ba : ba.left(p)));
if (ip6.isNull())
break;
const QByteArray scopeId = p == -1 ? QByteArray() : QByteArray::fromHex(ba.mid(p + 1));
if (!scopeId.isEmpty())
ip6.setScopeId(QString::fromUtf16(reinterpret_cast<const ushort *>(scopeId.constData()),
scopeId.length() / 2));
return ip6.toString();
}
}
qDebug() << "ENCODING ERROR: " << encoding;
return QCoreApplication::translate("Debugger", "<Encoding error>");