Merge 65d8a1592d
into 318fe124bf
This commit is contained in:
commit
993d57a8a2
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "emulproto.pb.h"
|
#include "emulproto.pb.h"
|
||||||
|
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kIp4Address,
|
kIp4Address,
|
||||||
@ -110,7 +111,7 @@ QVariant ArpStatusModel::data(const QModelIndex &index, int role) const
|
|||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return QString("%1").arg(arp.mac(), 6*2, 16, QChar('0'))
|
return QString("%1").arg(arp.mac(), 6*2, 16, QChar('0'))
|
||||||
.replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:")
|
.replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:")
|
||||||
.toUpper();
|
.toUpper();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -31,7 +31,7 @@ class DeviceGroupDialog: public QDialog, private Ui::DeviceGroupDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DeviceGroupDialog(Port *port, int deviceGroupIndex,
|
DeviceGroupDialog(Port *port, int deviceGroupIndex,
|
||||||
QWidget *parent = NULL, Qt::WindowFlags flags = 0);
|
QWidget *parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||||
|
|
||||||
virtual void accept();
|
virtual void accept();
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
#include <QRegularExpression>>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kMacAddress,
|
kMacAddress,
|
||||||
@ -119,7 +120,7 @@ QVariant DeviceModel::data(const QModelIndex &index, int role) const
|
|||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return QString("%1").arg(dev->mac(), 6*2, 16, QChar('0'))
|
return QString("%1").arg(dev->mac(), 6*2, 16, QChar('0'))
|
||||||
.replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:")
|
.replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:")
|
||||||
.toUpper();
|
.toUpper();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -31,7 +31,7 @@ DumpView::DumpView(QWidget *parent)
|
|||||||
|
|
||||||
// NOTE: Monospaced fonts only !!!!!!!!!!!
|
// NOTE: Monospaced fonts only !!!!!!!!!!!
|
||||||
setFont(QFont("Courier"));
|
setFont(QFont("Courier"));
|
||||||
w = fontMetrics().width('X');
|
w = fontMetrics().horizontalAdvance("X");
|
||||||
h = fontMetrics().height();
|
h = fontMetrics().height();
|
||||||
|
|
||||||
mLineHeight = h;
|
mLineHeight = h;
|
||||||
|
@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
#include <google/protobuf/stubs/common.h>
|
#include <google/protobuf/stubs/common.h>
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
ThemeManager::instance()->setTheme(appSettings->value(kThemeKey).toString());
|
ThemeManager::instance()->setTheme(appSettings->value(kThemeKey).toString());
|
||||||
|
|
||||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
// qsrand(QDateTime::currentDateTime().toTime_t());
|
||||||
|
|
||||||
mainWindow = new MainWindow;
|
mainWindow = new MainWindow;
|
||||||
mainWindow->show();
|
mainWindow->show();
|
||||||
|
@ -49,6 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
#define WIN32_NO_STATUS
|
#define WIN32_NO_STATUS
|
||||||
@ -326,7 +327,7 @@ _retry:
|
|||||||
goto _exit;
|
goto _exit;
|
||||||
|
|
||||||
if (QFileInfo(fileName).suffix().isEmpty()) {
|
if (QFileInfo(fileName).suffix().isEmpty()) {
|
||||||
QString fileExt = fileType.section(QRegExp("[\\*\\)]"), 1, 1);
|
QString fileExt = fileType.section(QRegularExpression("[\\*\\)]"), 1, 1);
|
||||||
qDebug("Adding extension '%s' to '%s'",
|
qDebug("Adding extension '%s' to '%s'",
|
||||||
qPrintable(fileExt), qPrintable(fileName));
|
qPrintable(fileExt), qPrintable(fileName));
|
||||||
fileName.append(fileExt);
|
fileName.append(fileExt);
|
||||||
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "uint128.h"
|
#include "uint128.h"
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
#include <QRegularExpression>>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kIp4Address,
|
kIp4Address,
|
||||||
@ -114,7 +115,7 @@ QVariant NdpStatusModel::data(const QModelIndex &index, int role) const
|
|||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return QString("%1").arg(ndp.mac(), 6*2, 16, QChar('0'))
|
return QString("%1").arg(ndp.mac(), 6*2, 16, QChar('0'))
|
||||||
.replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:")
|
.replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:")
|
||||||
.toUpper();
|
.toUpper();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
@ -294,7 +294,7 @@ QPixmap PortModel::statusIcon(
|
|||||||
QString key = QString("$ost:portStatusIcon:%1:%2:%3:%4")
|
QString key = QString("$ost:portStatusIcon:%1:%2:%3:%4")
|
||||||
.arg(linkState).arg(exclusive).arg(transmit).arg(capture);
|
.arg(linkState).arg(exclusive).arg(transmit).arg(capture);
|
||||||
|
|
||||||
if (QPixmapCache::find(key, pixmap))
|
if (QPixmapCache::find(key, &pixmap))
|
||||||
return pixmap;
|
return pixmap;
|
||||||
|
|
||||||
static int sz = QPixmap(":/icons/frag_link_up.png").width();
|
static int sz = QPixmap(":/icons/frag_link_up.png").width();
|
||||||
|
@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "portstatsfilterdialog.h"
|
#include "portstatsfilterdialog.h"
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
PortStatsFilterDialog::PortStatsFilterDialog(QWidget *parent)
|
PortStatsFilterDialog::PortStatsFilterDialog(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
@ -88,7 +90,7 @@ void PortStatsFilterDialog::on_tbSelectIn_clicked()
|
|||||||
|
|
||||||
foreach(QModelIndex idx, lvUnselected->selectionModel()->selectedIndexes())
|
foreach(QModelIndex idx, lvUnselected->selectionModel()->selectedIndexes())
|
||||||
rows.append(idx.row());
|
rows.append(idx.row());
|
||||||
std::sort(rows.begin(), rows.end(), qGreater<int>());
|
std::sort(rows.begin(), rows.end(), std::greater<int>());
|
||||||
|
|
||||||
QModelIndex idx = lvSelected->selectionModel()->currentIndex();
|
QModelIndex idx = lvSelected->selectionModel()->currentIndex();
|
||||||
int insertAt = idx.isValid() ? idx.row() : mSelected.rowCount();
|
int insertAt = idx.isValid() ? idx.row() : mSelected.rowCount();
|
||||||
@ -106,7 +108,7 @@ void PortStatsFilterDialog::on_tbSelectOut_clicked()
|
|||||||
|
|
||||||
foreach(QModelIndex idx, lvSelected->selectionModel()->selectedIndexes())
|
foreach(QModelIndex idx, lvSelected->selectionModel()->selectedIndexes())
|
||||||
rows.append(idx.row());
|
rows.append(idx.row());
|
||||||
std::sort(rows.begin(), rows.end(), qGreater<int>());
|
std::sort(rows.begin(), rows.end(), std::greater<int>());
|
||||||
|
|
||||||
foreach(int row, rows)
|
foreach(int row, rows)
|
||||||
{
|
{
|
||||||
|
@ -431,7 +431,7 @@ QPixmap PortStatsModel::statusIcons(
|
|||||||
QString key = QString("$ost:statusList:%1:%2:%3")
|
QString key = QString("$ost:statusList:%1:%2:%3")
|
||||||
.arg(linkState).arg(transmit).arg(capture);
|
.arg(linkState).arg(transmit).arg(capture);
|
||||||
|
|
||||||
if (QPixmapCache::find(key, pixmap))
|
if (QPixmapCache::find(key, &pixmap))
|
||||||
return pixmap;
|
return pixmap;
|
||||||
|
|
||||||
static int sz = QPixmap(":/icons/transmit_on.png").width();
|
static int sz = QPixmap(":/icons/transmit_on.png").width();
|
||||||
|
@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#define _PORT_STATS_PROXY_MODEL_H
|
#define _PORT_STATS_PROXY_MODEL_H
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
class PortStatsProxyModel : public QSortFilterProxyModel
|
class PortStatsProxyModel : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
@ -29,7 +30,7 @@ public:
|
|||||||
PortStatsProxyModel(int userRow, QObject *parent = 0)
|
PortStatsProxyModel(int userRow, QObject *parent = 0)
|
||||||
: QSortFilterProxyModel(parent), userRow_(userRow)
|
: QSortFilterProxyModel(parent), userRow_(userRow)
|
||||||
{
|
{
|
||||||
setFilterRegExp(QRegExp(".*"));
|
setFilterRegularExpression(QRegularExpression(".*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -39,7 +40,7 @@ protected:
|
|||||||
QModelIndex index = sourceModel()->index(userRow_, sourceColumn,sourceParent);
|
QModelIndex index = sourceModel()->index(userRow_, sourceColumn,sourceParent);
|
||||||
QString user = sourceModel()->data(index).toString();
|
QString user = sourceModel()->data(index).toString();
|
||||||
|
|
||||||
return filterRegExp().exactMatch(user) ? true : false;
|
return filterRegularExpression().match(user).hasMatch() ? true : false;
|
||||||
}
|
}
|
||||||
bool filterAcceptsRow(int sourceRow,
|
bool filterAcceptsRow(int sourceRow,
|
||||||
const QModelIndex &/*sourceParent*/) const
|
const QModelIndex &/*sourceParent*/) const
|
||||||
|
@ -32,6 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QRegularExpression>>
|
||||||
|
|
||||||
extern QMainWindow *mainWindow;
|
extern QMainWindow *mainWindow;
|
||||||
|
|
||||||
@ -113,10 +114,10 @@ void PortStatsWindow::showMyReservedPortsOnly(bool enabled)
|
|||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
QString rx(appSettings->value(kUserKey, kUserDefaultValue).toString());
|
QString rx(appSettings->value(kUserKey, kUserDefaultValue).toString());
|
||||||
proxyStatsModel->setFilterRegExp(QRegExp::escape(rx));
|
proxyStatsModel->setFilterRegularExpression(QRegularExpression::escape(rx));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
proxyStatsModel->setFilterRegExp(QRegExp(".*")); // match all
|
proxyStatsModel->setFilterRegularExpression(QRegularExpression(".*")); // match all
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------- SLOTS (private) -------------- */
|
/* ------------- SLOTS (private) -------------- */
|
||||||
|
@ -266,14 +266,14 @@ void PortsWindow::showMyReservedPortsOnly(bool enabled)
|
|||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
QString rx = "Port Group|\\["
|
QString rx = "Port Group|\\["
|
||||||
+ QRegExp::escape(appSettings->value(kUserKey,
|
+ QRegularExpression::escape(appSettings->value(kUserKey,
|
||||||
kUserDefaultValue).toString())
|
kUserDefaultValue).toString())
|
||||||
+ "\\]";
|
+ "\\]";
|
||||||
qDebug("%s: regexp: <%s>", __FUNCTION__, qPrintable(rx));
|
qDebug("%s: RegularExpression: <%s>", __FUNCTION__, qPrintable(rx));
|
||||||
proxyPortModel->setFilterRegExp(QRegExp(rx));
|
proxyPortModel->setFilterRegularExpression(QRegularExpression(rx));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
proxyPortModel->setFilterRegExp(QRegExp(""));
|
proxyPortModel->setFilterRegularExpression(QRegularExpression(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortsWindow::when_portView_currentChanged(const QModelIndex& currentIndex,
|
void PortsWindow::when_portView_currentChanged(const QModelIndex& currentIndex,
|
||||||
|
@ -219,9 +219,9 @@ StreamConfigDialog::StreamConfigDialog(
|
|||||||
|
|
||||||
void StreamConfigDialog::setupUiExtra()
|
void StreamConfigDialog::setupUiExtra()
|
||||||
{
|
{
|
||||||
QRegExp reHex2B("[0-9,a-f,A-F]{1,4}");
|
QRegularExpression reHex2B("[0-9,a-f,A-F]{1,4}");
|
||||||
QRegExp reHex4B("[0-9,a-f,A-F]{1,8}");
|
QRegularExpression reHex4B("[0-9,a-f,A-F]{1,8}");
|
||||||
QRegExp reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}");
|
QRegularExpression reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}");
|
||||||
|
|
||||||
// ---- Setup default stuff that cannot be done in designer ----
|
// ---- Setup default stuff that cannot be done in designer ----
|
||||||
bgProto[ProtoL1] = new QButtonGroup();
|
bgProto[ProtoL1] = new QButtonGroup();
|
||||||
@ -1253,7 +1253,7 @@ bool StreamConfigDialog::isCurrentStreamValid()
|
|||||||
if (QMessageBox::warning(this, "Preflight Check",
|
if (QMessageBox::warning(this, "Preflight Check",
|
||||||
tr("<p>We found possible problems with this stream -</p>")
|
tr("<p>We found possible problems with this stream -</p>")
|
||||||
+ "<ul>"
|
+ "<ul>"
|
||||||
+ log.replaceInStrings(QRegExp("(.*)"), "<li>\\1</li>")
|
+ log.replaceInStrings(QRegularExpression("(.*)"), "<li>\\1</li>")
|
||||||
.join("\n")
|
.join("\n")
|
||||||
+ "</ul>"
|
+ "</ul>"
|
||||||
+ tr("<p>Ignore?</p>"),
|
+ tr("<p>Ignore?</p>"),
|
||||||
|
@ -37,7 +37,7 @@ protected:
|
|||||||
{
|
{
|
||||||
QString title = sourceModel()->headerData(sourceColumn, Qt::Horizontal)
|
QString title = sourceModel()->headerData(sourceColumn, Qt::Horizontal)
|
||||||
.toString();
|
.toString();
|
||||||
return filterRegExp().exactMatch(title) ? true : false;
|
return filterRegularExpression().match(title).hasMatch() ? true : false;
|
||||||
}
|
}
|
||||||
bool filterAcceptsRow(int /*sourceRow*/,
|
bool filterAcceptsRow(int /*sourceRow*/,
|
||||||
const QModelIndex &/*sourceParent*/) const
|
const QModelIndex &/*sourceParent*/) const
|
||||||
|
@ -39,7 +39,7 @@ StreamStatsWindow::StreamStatsWindow(QAbstractItemModel *model, QWidget *parent)
|
|||||||
count++;
|
count++;
|
||||||
|
|
||||||
filterModel_ = new StreamStatsFilterModel(this);
|
filterModel_ = new StreamStatsFilterModel(this);
|
||||||
filterModel_->setFilterRegExp(QRegExp(kDefaultFilter_));
|
filterModel_->setFilterRegularExpression(QRegularExpression(kDefaultFilter_));
|
||||||
filterModel_->setSourceModel(model);
|
filterModel_->setSourceModel(model);
|
||||||
streamStats->setModel(filterModel_);
|
streamStats->setModel(filterModel_);
|
||||||
|
|
||||||
@ -63,9 +63,9 @@ StreamStatsWindow::~StreamStatsWindow()
|
|||||||
void StreamStatsWindow::on_actionShowDetails_triggered(bool checked)
|
void StreamStatsWindow::on_actionShowDetails_triggered(bool checked)
|
||||||
{
|
{
|
||||||
if (checked)
|
if (checked)
|
||||||
filterModel_->setFilterRegExp(QRegExp(".*"));
|
filterModel_->setFilterRegularExpression(QRegularExpression(".*"));
|
||||||
else
|
else
|
||||||
filterModel_->setFilterRegExp(QRegExp(kDefaultFilter_));
|
filterModel_->setFilterRegularExpression(QRegularExpression(kDefaultFilter_));
|
||||||
|
|
||||||
streamStats->resizeColumnsToContents();
|
streamStats->resizeColumnsToContents();
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ _retry:
|
|||||||
goto _exit;
|
goto _exit;
|
||||||
|
|
||||||
if (QFileInfo(fileName).suffix().isEmpty()) {
|
if (QFileInfo(fileName).suffix().isEmpty()) {
|
||||||
QString fileExt = fileType.section(QRegExp("[\\*\\)]"), 1, 1);
|
QString fileExt = fileType.section(QRegularExpression("[\\*\\)]"), 1, 1);
|
||||||
qDebug("Adding extension '%s' to '%s'",
|
qDebug("Adding extension '%s' to '%s'",
|
||||||
qPrintable(fileExt), qPrintable(fileName));
|
qPrintable(fileExt), qPrintable(fileName));
|
||||||
fileName.append(fileExt);
|
fileName.append(fileExt);
|
||||||
@ -491,7 +491,7 @@ _retry:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileType = fileType.remove(QRegExp("\\(.*\\)")).trimmed();
|
fileType = fileType.remove(QRegularExpression("\\(.*\\)")).trimmed();
|
||||||
if (!fileType.startsWith("Ostinato")
|
if (!fileType.startsWith("Ostinato")
|
||||||
&& !fileType.startsWith("Python"))
|
&& !fileType.startsWith("Python"))
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include <qendian.h>
|
#include <qendian.h>
|
||||||
|
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#ifdef qDebug
|
#ifdef qDebug
|
||||||
#undef qDebug
|
#undef qDebug
|
||||||
@ -1160,7 +1162,7 @@ bool varyCounter(QString protocolName, QByteArray &buf, int frameIndex,
|
|||||||
break;
|
break;
|
||||||
case OstProto::VariableField::kRandom:
|
case OstProto::VariableField::kRandom:
|
||||||
newfv = (oldfv & ~varField.mask())
|
newfv = (oldfv & ~varField.mask())
|
||||||
| ((varField.value() + qrand()) & varField.mask());
|
| ((varField.value() + QRandomGenerator::global()->generate()) & varField.mask());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning("%s Unsupported varField mode %d",
|
qWarning("%s Unsupported varField mode %d",
|
||||||
|
@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QFlags>
|
#include <QFlags>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QLinkedList>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <qendian.h>
|
#include <qendian.h>
|
||||||
@ -109,6 +108,7 @@ public:
|
|||||||
|
|
||||||
//! Flags affecting cksum calculation, can be OR'd
|
//! Flags affecting cksum calculation, can be OR'd
|
||||||
enum CksumFlag {
|
enum CksumFlag {
|
||||||
|
ExcludeCksumField = 0x0,
|
||||||
IncludeCksumField = 0x1, //!< Default: exclude cksum field(s)
|
IncludeCksumField = 0x1, //!< Default: exclude cksum field(s)
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(CksumFlags, CksumFlag); //!< \private abcd
|
Q_DECLARE_FLAGS(CksumFlags, CksumFlag); //!< \private abcd
|
||||||
@ -171,7 +171,7 @@ public:
|
|||||||
bool protocolHasPayload() const;
|
bool protocolHasPayload() const;
|
||||||
|
|
||||||
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
||||||
CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const;
|
CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const;
|
||||||
quint32 protocolFrameHeaderCksum(int streamIndex = 0,
|
quint32 protocolFrameHeaderCksum(int streamIndex = 0,
|
||||||
CksumType cksumType = CksumIp,
|
CksumType cksumType = CksumIp,
|
||||||
CksumScope cksumScope = CksumScopeAdjacentProtocol) const;
|
CksumScope cksumScope = CksumScopeAdjacentProtocol) const;
|
||||||
|
@ -20,11 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "arp.h"
|
#include "arp.h"
|
||||||
|
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
#define uintToMacStr(num) \
|
#define uintToMacStr(num) \
|
||||||
QString("%1").arg(num, 6*2, BASE_HEX, QChar('0')) \
|
QString("%1").arg(num, 6*2, BASE_HEX, QChar('0')) \
|
||||||
.replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper()
|
.replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper()
|
||||||
|
|
||||||
ArpProtocol::ArpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
ArpProtocol::ArpProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
: AbstractProtocol(stream, parent)
|
: AbstractProtocol(stream, parent)
|
||||||
@ -348,7 +349,7 @@ QVariant ArpProtocol::fieldData(int index, FieldAttrib attrib,
|
|||||||
case OstProto::Arp::kRandomHost:
|
case OstProto::Arp::kRandomHost:
|
||||||
subnet = data.sender_proto_addr()
|
subnet = data.sender_proto_addr()
|
||||||
& data.sender_proto_addr_mask();
|
& data.sender_proto_addr_mask();
|
||||||
host = (qrand() & ~data.sender_proto_addr_mask());
|
host = (QRandomGenerator::global()->generate() & ~data.sender_proto_addr_mask());
|
||||||
protoAddr = subnet | host;
|
protoAddr = subnet | host;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -456,7 +457,7 @@ QVariant ArpProtocol::fieldData(int index, FieldAttrib attrib,
|
|||||||
case OstProto::Arp::kRandomHost:
|
case OstProto::Arp::kRandomHost:
|
||||||
subnet = data.target_proto_addr()
|
subnet = data.target_proto_addr()
|
||||||
& data.target_proto_addr_mask();
|
& data.target_proto_addr_mask();
|
||||||
host = (qrand() & ~data.target_proto_addr_mask());
|
host = (QRandomGenerator::global()->generate() & ~data.target_proto_addr_mask());
|
||||||
protoAddr = subnet | host;
|
protoAddr = subnet | host;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -188,7 +188,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
||||||
CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const
|
CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const
|
||||||
{
|
{
|
||||||
// For a Pseudo IP cksum, we assume it is the succeeding protocol
|
// For a Pseudo IP cksum, we assume it is the succeeding protocol
|
||||||
// that is requesting it and hence return protoB's cksum;
|
// that is requesting it and hence return protoB's cksum;
|
||||||
|
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "emulproto.pb.h"
|
#include "emulproto.pb.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
static inline OstProto::DeviceGroup* newDeviceGroup(uint portId)
|
static inline OstProto::DeviceGroup* newDeviceGroup(uint portId)
|
||||||
{
|
{
|
||||||
@ -37,10 +38,10 @@ static inline OstProto::DeviceGroup* newDeviceGroup(uint portId)
|
|||||||
// Create a mac address as per RFC 4814 Sec 4.2
|
// Create a mac address as per RFC 4814 Sec 4.2
|
||||||
// (RR & 0xFC):PP:PP:RR:RR:RR
|
// (RR & 0xFC):PP:PP:RR:RR:RR
|
||||||
// where RR is a random number, PP:PP is 1-indexed port index
|
// where RR is a random number, PP:PP is 1-indexed port index
|
||||||
// NOTE: although qrand() return type is a int, the max value
|
// NOTE: although QRandomGenerator::global()->generate() return type is a int, the max value
|
||||||
// is RAND_MAX (stdlib.h) which is often 16-bit only, so we
|
// is RAND_MAX (stdlib.h) which is often 16-bit only, so we
|
||||||
// use two random numbers
|
// use two random numbers
|
||||||
quint32 r1 = qrand(), r2 = qrand();
|
quint32 r1 = QRandomGenerator::global()->generate(), r2 = QRandomGenerator::global()->generate();
|
||||||
quint64 mac;
|
quint64 mac;
|
||||||
mac = quint64(r1 & 0xfc00) << 32
|
mac = quint64(r1 & 0xfc00) << 32
|
||||||
| quint64(portId + 1) << 24
|
| quint64(portId + 1) << 24
|
||||||
|
@ -25,12 +25,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
struct FrameValueAttrib
|
struct FrameValueAttrib
|
||||||
{
|
{
|
||||||
enum ErrorFlag {
|
enum ErrorFlag {
|
||||||
|
NoError = 0x0,
|
||||||
UnresolvedSrcMacError = 0x1,
|
UnresolvedSrcMacError = 0x1,
|
||||||
UnresolvedDstMacError = 0x2,
|
UnresolvedDstMacError = 0x2,
|
||||||
OutOfMemoryError = 0x4,
|
OutOfMemoryError = 0x4,
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(ErrorFlags, ErrorFlag);
|
Q_DECLARE_FLAGS(ErrorFlags, ErrorFlag);
|
||||||
ErrorFlags errorFlags{0};
|
ErrorFlags errorFlags{ErrorFlag::NoError};
|
||||||
// TODO?: int len;
|
// TODO?: int len;
|
||||||
|
|
||||||
FrameValueAttrib& operator+=(const FrameValueAttrib& rhs) {
|
FrameValueAttrib& operator+=(const FrameValueAttrib& rhs) {
|
||||||
|
@ -25,8 +25,8 @@ GmpConfigForm::GmpConfigForm(QWidget *parent)
|
|||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
auxData->setValidator(new QRegExpValidator(
|
auxData->setValidator(new QRegularExpressionValidator(
|
||||||
QRegExp("[0-9A-Fa-f]*"), this));
|
QRegularExpression("[0-9A-Fa-f]*"), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
GmpConfigForm::~GmpConfigForm()
|
GmpConfigForm::~GmpConfigForm()
|
||||||
@ -272,7 +272,7 @@ void GmpConfigForm::on_addGroupRecord_clicked()
|
|||||||
grpRec["overrideAuxDataLength"] = defRec.is_override_aux_data_length();
|
grpRec["overrideAuxDataLength"] = defRec.is_override_aux_data_length();
|
||||||
grpRec["auxDataLength"] = defRec.aux_data_length();
|
grpRec["auxDataLength"] = defRec.aux_data_length();
|
||||||
grpRec["auxData"] = QByteArray().append(
|
grpRec["auxData"] = QByteArray().append(
|
||||||
QString().fromStdString(defRec.aux_data()));
|
QString().fromStdString(defRec.aux_data()).toUtf8());
|
||||||
|
|
||||||
item->setData(Qt::UserRole, grpRec);
|
item->setData(Qt::UserRole, grpRec);
|
||||||
item->setText(QString("%1: %2")
|
item->setText(QString("%1: %2")
|
||||||
@ -320,7 +320,7 @@ void GmpConfigForm::on_groupList_currentItemChanged(QListWidgetItem *current,
|
|||||||
rec["groupRecordSourceCount"] = groupRecordSourceCount->text().toUInt();
|
rec["groupRecordSourceCount"] = groupRecordSourceCount->text().toUInt();
|
||||||
rec["overrideAuxDataLength"] = overrideAuxDataLength->isChecked();
|
rec["overrideAuxDataLength"] = overrideAuxDataLength->isChecked();
|
||||||
rec["auxDataLength"] = auxDataLength->text().toUInt();
|
rec["auxDataLength"] = auxDataLength->text().toUInt();
|
||||||
rec["auxData"] = QByteArray().fromHex(QByteArray().append(auxData->text()));
|
rec["auxData"] = QByteArray().fromHex(QByteArray().append(auxData->text().toUtf8()));
|
||||||
|
|
||||||
previous->setData(Qt::UserRole, rec);
|
previous->setData(Qt::UserRole, rec);
|
||||||
previous->setText(QString("%1: %2")
|
previous->setText(QString("%1: %2")
|
||||||
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "ip4.h"
|
#include "ip4.h"
|
||||||
|
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
Ip4Protocol::Ip4Protocol(StreamBase *stream, AbstractProtocol *parent)
|
Ip4Protocol::Ip4Protocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
: AbstractProtocol(stream, parent)
|
: AbstractProtocol(stream, parent)
|
||||||
@ -433,7 +434,7 @@ QVariant Ip4Protocol::fieldData(int index, FieldAttrib attrib,
|
|||||||
break;
|
break;
|
||||||
case OstProto::Ip4::e_im_random_host:
|
case OstProto::Ip4::e_im_random_host:
|
||||||
subnet = data.src_ip() & data.src_ip_mask();
|
subnet = data.src_ip() & data.src_ip_mask();
|
||||||
host = (qrand() & ~data.src_ip_mask());
|
host = (QRandomGenerator::global()->generate() & ~data.src_ip_mask());
|
||||||
srcIp = subnet | host;
|
srcIp = subnet | host;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -486,7 +487,7 @@ QVariant Ip4Protocol::fieldData(int index, FieldAttrib attrib,
|
|||||||
break;
|
break;
|
||||||
case OstProto::Ip4::e_im_random_host:
|
case OstProto::Ip4::e_im_random_host:
|
||||||
subnet = data.dst_ip() & data.dst_ip_mask();
|
subnet = data.dst_ip() & data.dst_ip_mask();
|
||||||
host = (qrand() & ~data.dst_ip_mask());
|
host = (QRandomGenerator::global()->generate() & ~data.dst_ip_mask());
|
||||||
dstIp = subnet | host;
|
dstIp = subnet | host;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -89,7 +89,7 @@ public:
|
|||||||
virtual int protocolFrameVariableCount() const;
|
virtual int protocolFrameVariableCount() const;
|
||||||
|
|
||||||
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
||||||
CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const;
|
CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const;
|
||||||
|
|
||||||
virtual bool hasErrors(QStringList *errors = nullptr) const;
|
virtual bool hasErrors(QStringList *errors = nullptr) const;
|
||||||
private:
|
private:
|
||||||
|
@ -29,7 +29,7 @@ Ip4ConfigForm::Ip4ConfigForm(QWidget *parent)
|
|||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
leIpVersion->setValidator(new QIntValidator(0, 15, this));
|
leIpVersion->setValidator(new QIntValidator(0, 15, this));
|
||||||
leIpOptions->setValidator(new QRegExpValidator(QRegExp("[0-9a-fA-F]*"),
|
leIpOptions->setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]*"),
|
||||||
this));
|
this));
|
||||||
leIpSrcAddr->setValidator(new IPv4AddressValidator(this));
|
leIpSrcAddr->setValidator(new IPv4AddressValidator(this));
|
||||||
leIpSrcAddrMask->setValidator(new IPv4AddressValidator(this));
|
leIpSrcAddrMask->setValidator(new IPv4AddressValidator(this));
|
||||||
@ -277,7 +277,7 @@ void Ip4ConfigForm::storeWidget(AbstractProtocol *proto)
|
|||||||
QHostAddress(leIpDstAddrMask->text()).toIPv4Address());
|
QHostAddress(leIpDstAddrMask->text()).toIPv4Address());
|
||||||
proto->setFieldData(
|
proto->setFieldData(
|
||||||
Ip4Protocol::ip4_options,
|
Ip4Protocol::ip4_options,
|
||||||
QByteArray::fromHex(QByteArray().append(leIpOptions->text())));
|
QByteArray::fromHex(QByteArray().append(leIpOptions->text().toUtf8())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "uint128.h"
|
#include "uint128.h"
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
|
|
||||||
Ip6Protocol::Ip6Protocol(StreamBase *stream, AbstractProtocol *parent)
|
Ip6Protocol::Ip6Protocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
@ -340,7 +341,7 @@ QVariant Ip6Protocol::fieldData(int index, FieldAttrib attrib,
|
|||||||
else if (data.src_addr_mode()==OstProto::Ip6::kRandomHost) {
|
else if (data.src_addr_mode()==OstProto::Ip6::kRandomHost) {
|
||||||
// XXX: qrand is int (32bit) not 64bit, some stdlib
|
// XXX: qrand is int (32bit) not 64bit, some stdlib
|
||||||
// implementations have RAND_MAX as low as 0x7FFF
|
// implementations have RAND_MAX as low as 0x7FFF
|
||||||
host = UInt128(qrand(), qrand()) & ~mask;
|
host = UInt128(QRandomGenerator::global()->generate(), QRandomGenerator::global()->generate()) & ~mask;
|
||||||
}
|
}
|
||||||
src = prefix | host;
|
src = prefix | host;
|
||||||
break;
|
break;
|
||||||
@ -403,7 +404,7 @@ QVariant Ip6Protocol::fieldData(int index, FieldAttrib attrib,
|
|||||||
else if (data.dst_addr_mode()==OstProto::Ip6::kRandomHost) {
|
else if (data.dst_addr_mode()==OstProto::Ip6::kRandomHost) {
|
||||||
// XXX: qrand is int (32bit) not 64bit, some stdlib
|
// XXX: qrand is int (32bit) not 64bit, some stdlib
|
||||||
// implementations have RAND_MAX as low as 0x7FFF
|
// implementations have RAND_MAX as low as 0x7FFF
|
||||||
host = UInt128(qrand(), qrand()) & ~mask;
|
host = UInt128(QRandomGenerator::global()->generate(), QRandomGenerator::global()->generate()) & ~mask;
|
||||||
}
|
}
|
||||||
dst = prefix | host;
|
dst = prefix | host;
|
||||||
break;
|
break;
|
||||||
|
@ -103,7 +103,7 @@ public:
|
|||||||
virtual int protocolFrameVariableCount() const;
|
virtual int protocolFrameVariableCount() const;
|
||||||
|
|
||||||
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
||||||
CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const;
|
CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const;
|
||||||
|
|
||||||
virtual bool hasErrors(QStringList *errors = nullptr) const;
|
virtual bool hasErrors(QStringList *errors = nullptr) const;
|
||||||
private:
|
private:
|
||||||
|
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "uint128.h"
|
#include "uint128.h"
|
||||||
|
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
namespace ipUtils {
|
namespace ipUtils {
|
||||||
enum AddrMode {
|
enum AddrMode {
|
||||||
@ -60,7 +61,7 @@ quint32 inline ipAddress(quint32 baseIp, int prefix, AddrMode mode, int count,
|
|||||||
break;
|
break;
|
||||||
case kRandom:
|
case kRandom:
|
||||||
subnet = baseIp & mask;
|
subnet = baseIp & mask;
|
||||||
host = (qrand() & ~mask);
|
host = (QRandomGenerator::global()->generate() & ~mask);
|
||||||
ip = subnet | host;
|
ip = subnet | host;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -111,8 +112,8 @@ void inline ipAddress(quint64 baseIpHi, quint64 baseIpLo, int prefix,
|
|||||||
hostLo = ((baseIpLo & ~maskLo) - u) & ~maskLo;
|
hostLo = ((baseIpLo & ~maskLo) - u) & ~maskLo;
|
||||||
}
|
}
|
||||||
else if (mode==kRandom) {
|
else if (mode==kRandom) {
|
||||||
hostHi = qrand() & ~maskHi;
|
hostHi = QRandomGenerator::global()->generate() & ~maskHi;
|
||||||
hostLo = qrand() & ~maskLo;
|
hostLo = QRandomGenerator::global()->generate() & ~maskLo;
|
||||||
}
|
}
|
||||||
ipHi = prefixHi | hostHi;
|
ipHi = prefixHi | hostHi;
|
||||||
ipLo = prefixLo | hostLo;
|
ipLo = prefixLo | hostLo;
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
virtual void fixup(QString &input) const
|
virtual void fixup(QString &input) const
|
||||||
{
|
{
|
||||||
QStringList bytes = input.split('.', QString::SkipEmptyParts);
|
QStringList bytes = input.split('.', Qt::SkipEmptyParts);
|
||||||
|
|
||||||
while (bytes.count() < 4)
|
while (bytes.count() < 4)
|
||||||
bytes.append("0");
|
bytes.append("0");
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
if (addr.protocol() == QAbstractSocket::IPv6Protocol)
|
if (addr.protocol() == QAbstractSocket::IPv6Protocol)
|
||||||
state = Acceptable;
|
state = Acceptable;
|
||||||
else
|
else
|
||||||
if (_ip6ValidChars.exactMatch(input))
|
if (_ip6ValidChars.match(input).hasMatch())
|
||||||
state = Intermediate;
|
state = Intermediate;
|
||||||
else
|
else
|
||||||
state = Invalid;
|
state = Invalid;
|
||||||
@ -69,7 +69,7 @@ public:
|
|||||||
input = addr.toString();
|
input = addr.toString();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
QRegExp _ip6ValidChars;
|
QRegularExpression _ip6ValidChars;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "llc.pb.h"
|
#include "llc.pb.h"
|
||||||
#include "snap.pb.h"
|
#include "snap.pb.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
PdmlLlcProtocol::PdmlLlcProtocol()
|
PdmlLlcProtocol::PdmlLlcProtocol()
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ void PdmlLlcProtocol::unknownFieldHandler(QString name, int /*pos*/,
|
|||||||
.toUInt(&isOk, kBaseHex));
|
.toUInt(&isOk, kBaseHex));
|
||||||
snap->set_is_override_oui(true);
|
snap->set_is_override_oui(true);
|
||||||
}
|
}
|
||||||
else if ((name == "llc.type") || (name.contains(QRegExp("llc\\..*pid"))))
|
else if ((name == "llc.type") || (name.contains(QRegularExpression("llc\\..*pid"))))
|
||||||
{
|
{
|
||||||
OstProto::Snap *snap = stream->mutable_protocol(
|
OstProto::Snap *snap = stream->mutable_protocol(
|
||||||
stream->protocol_size()-1)->MutableExtension(OstProto::snap);
|
stream->protocol_size()-1)->MutableExtension(OstProto::snap);
|
||||||
|
@ -22,11 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "framevalueattrib.h"
|
#include "framevalueattrib.h"
|
||||||
#include "../common/streambase.h"
|
#include "../common/streambase.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#define uintToMacStr(num) \
|
#define uintToMacStr(num) \
|
||||||
QString("%1").arg(num, 6*2, BASE_HEX, QChar('0')) \
|
QString("%1").arg(num, 6*2, BASE_HEX, QChar('0')) \
|
||||||
.replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper()
|
.replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper()
|
||||||
|
|
||||||
MacProtocol::MacProtocol(StreamBase *stream, AbstractProtocol *parent)
|
MacProtocol::MacProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
: AbstractProtocol(stream, parent)
|
: AbstractProtocol(stream, parent)
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
virtual void fixup(QString &input) const
|
virtual void fixup(QString &input) const
|
||||||
{
|
{
|
||||||
QStringList bytes = input.split(QRegularExpression("[:-]"),
|
QStringList bytes = input.split(QRegularExpression("[:-]"),
|
||||||
QString::SkipEmptyParts);
|
Qt::SkipEmptyParts);
|
||||||
|
|
||||||
if (!bytes.isEmpty() && bytes.last().size() == 1)
|
if (!bytes.isEmpty() && bytes.last().size() == 1)
|
||||||
bytes.last().prepend("0");
|
bytes.last().prepend("0");
|
||||||
|
@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#define _MAC_EDIT_H
|
#define _MAC_EDIT_H
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRegExpValidator>
|
#include <QRegularExpressionValidator>
|
||||||
|
|
||||||
class MacEdit: public QLineEdit
|
class MacEdit: public QLineEdit
|
||||||
{
|
{
|
||||||
@ -39,14 +39,14 @@ inline MacEdit::MacEdit(QWidget *parent)
|
|||||||
: QLineEdit(parent)
|
: QLineEdit(parent)
|
||||||
{
|
{
|
||||||
// Allow : or - as separator
|
// Allow : or - as separator
|
||||||
QRegExp reMac("([0-9,a-f,A-F]{0,2}[:-]){5,5}[0-9,a-f,A-F]{0,2}");
|
QRegularExpression reMac("([0-9,a-f,A-F]{0,2}[:-]){5,5}[0-9,a-f,A-F]{0,2}");
|
||||||
|
|
||||||
setValidator(new QRegExpValidator(reMac, this));
|
setValidator(new QRegularExpressionValidator(reMac, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline quint64 MacEdit::value()
|
inline quint64 MacEdit::value()
|
||||||
{
|
{
|
||||||
QStringList bytes = text().split(QRegExp("[:-]"));
|
QStringList bytes = text().split(QRegularExpression("[:-]"));
|
||||||
quint64 mac = 0;
|
quint64 mac = 0;
|
||||||
|
|
||||||
while (bytes.count() > 6)
|
while (bytes.count() > 6)
|
||||||
@ -61,7 +61,7 @@ inline quint64 MacEdit::value()
|
|||||||
inline void MacEdit::setValue(quint64 val)
|
inline void MacEdit::setValue(quint64 val)
|
||||||
{
|
{
|
||||||
setText(QString("%1").arg(val, 6*2, 16, QChar('0'))
|
setText(QString("%1").arg(val, 6*2, 16, QChar('0'))
|
||||||
.replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper());
|
.replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MacEdit::focusOutEvent(QFocusEvent *e)
|
inline void MacEdit::focusOutEvent(QFocusEvent *e)
|
||||||
|
@ -64,8 +64,8 @@ NativeFileFormat::NativeFileFormat()
|
|||||||
// TODO: convert Q_ASSERT to something that will run in RELEASE mode also
|
// TODO: convert Q_ASSERT to something that will run in RELEASE mode also
|
||||||
Q_ASSERT(magic.IsInitialized());
|
Q_ASSERT(magic.IsInitialized());
|
||||||
Q_ASSERT(cksum.IsInitialized());
|
Q_ASSERT(cksum.IsInitialized());
|
||||||
Q_ASSERT(magic.ByteSize() == kFileMagicSize);
|
Q_ASSERT(magic.ByteSizeLong() == kFileMagicSize);
|
||||||
Q_ASSERT(cksum.ByteSize() == kFileChecksumSize);
|
Q_ASSERT(cksum.ByteSizeLong() == kFileChecksumSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeFileFormat::open(
|
bool NativeFileFormat::open(
|
||||||
|
@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "payload.h"
|
#include "payload.h"
|
||||||
#include "streambase.h"
|
#include "streambase.h"
|
||||||
|
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
PayloadProtocol::PayloadProtocol(StreamBase *stream, AbstractProtocol *parent)
|
PayloadProtocol::PayloadProtocol(StreamBase *stream, AbstractProtocol *parent)
|
||||||
: AbstractProtocol(stream, parent)
|
: AbstractProtocol(stream, parent)
|
||||||
{
|
{
|
||||||
@ -149,7 +151,7 @@ QVariant PayloadProtocol::fieldData(int index, FieldAttrib attrib,
|
|||||||
case OstProto::Payload::e_dp_random:
|
case OstProto::Payload::e_dp_random:
|
||||||
//! \todo (HIGH) cksum is incorrect for random pattern
|
//! \todo (HIGH) cksum is incorrect for random pattern
|
||||||
for (int i = 0; i < dataLen; i++)
|
for (int i = 0; i < dataLen; i++)
|
||||||
fv[i] = qrand() % (0xFF + 1);
|
fv[i] = QRandomGenerator::global()->generate() % (0xFF + 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning("Unhandled data pattern %d",
|
qWarning("Unhandled data pattern %d",
|
||||||
|
@ -20,11 +20,11 @@ This module is developed by PLVision <developers@plvision.eu>
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stp.h"
|
#include "stp.h"
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#define uintToMacStr(num) \
|
#define uintToMacStr(num) \
|
||||||
QString("%1").arg(num, 6 * 2, BASE_HEX, QChar('0')) \
|
QString("%1").arg(num, 6 * 2, BASE_HEX, QChar('0')) \
|
||||||
.replace(QRegExp("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper()
|
.replace(QRegularExpression("([0-9a-fA-F]{2}\\B)"), "\\1:").toUpper()
|
||||||
#define ONE_BIT(pos) ((unsigned int)(1 << (pos)))
|
#define ONE_BIT(pos) ((unsigned int)(1 << (pos)))
|
||||||
#define BITS(bit) (bit)
|
#define BITS(bit) (bit)
|
||||||
#define BYTES(byte) (byte)
|
#define BYTES(byte) (byte)
|
||||||
|
@ -22,7 +22,7 @@ This module is developed by PLVision <developers@plvision.eu>
|
|||||||
#include "stpconfig.h"
|
#include "stpconfig.h"
|
||||||
#include "stp.h"
|
#include "stp.h"
|
||||||
|
|
||||||
#include <QRegExpValidator>
|
#include <QRegularExpressionValidator>
|
||||||
#include <QIntValidator>
|
#include <QIntValidator>
|
||||||
|
|
||||||
#define ONE_BYTE_MAX 255
|
#define ONE_BYTE_MAX 255
|
||||||
@ -59,11 +59,11 @@ public:
|
|||||||
StpConfigForm::StpConfigForm(QWidget *parent)
|
StpConfigForm::StpConfigForm(QWidget *parent)
|
||||||
: AbstractProtocolConfigForm(parent)
|
: AbstractProtocolConfigForm(parent)
|
||||||
{
|
{
|
||||||
QRegExp reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}");
|
QRegularExpression reMac("([0-9,a-f,A-F]{2,2}[:-]){5,5}[0-9,a-f,A-F]{2,2}");
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
QRegExpValidator *validateMACAddress =
|
QRegularExpressionValidator *validateMACAddress =
|
||||||
new QRegExpValidator(reMac, this);
|
new QRegularExpressionValidator(reMac, this);
|
||||||
UNumberValidator *validateByte =
|
UNumberValidator *validateByte =
|
||||||
new UNumberValidator(0, ONE_BYTE_MAX, this);
|
new UNumberValidator(0, ONE_BYTE_MAX, this);
|
||||||
UNumberValidator *validate2Byte =
|
UNumberValidator *validate2Byte =
|
||||||
|
@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include "uint128.h"
|
#include "uint128.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
extern ProtocolManager *OstProtocolManager;
|
extern ProtocolManager *OstProtocolManager;
|
||||||
extern quint64 getDeviceMacAddress(int portId, int streamId, int frameIndex);
|
extern quint64 getDeviceMacAddress(int portId, int streamId, int frameIndex);
|
||||||
@ -235,9 +236,11 @@ quint16 StreamBase::frameLen(int streamIndex) const
|
|||||||
case e_fl_random:
|
case e_fl_random:
|
||||||
//! \todo (MED) This 'random' sequence is same across iterations
|
//! \todo (MED) This 'random' sequence is same across iterations
|
||||||
pktLen = 64; // to avoid the 'maybe used uninitialized' warning
|
pktLen = 64; // to avoid the 'maybe used uninitialized' warning
|
||||||
qsrand(reinterpret_cast<ulong>(this));
|
|
||||||
|
// qsrand(reinterpret_cast<ulong>(this));
|
||||||
|
|
||||||
for (int i = 0; i <= streamIndex; i++)
|
for (int i = 0; i <= streamIndex; i++)
|
||||||
pktLen = qrand();
|
pktLen = QRandomGenerator::global()->generate();
|
||||||
pktLen = frameLenMin() + (pktLen %
|
pktLen = frameLenMin() + (pktLen %
|
||||||
(frameLenMax() - frameLenMin() + 1));
|
(frameLenMax() - frameLenMin() + 1));
|
||||||
break;
|
break;
|
||||||
@ -622,13 +625,13 @@ int StreamBase::findReplace(quint32 protocolNumber, int fieldIndex,
|
|||||||
qDebug() << "findReplace:"
|
qDebug() << "findReplace:"
|
||||||
<< "stream" << mStreamId->id()
|
<< "stream" << mStreamId->id()
|
||||||
<< "field" << fieldValue
|
<< "field" << fieldValue
|
||||||
<< "findMask" << hex << findMask.value<T>() << dec
|
<< "findMask" << Qt::hex << findMask.value<T>() << Qt::dec
|
||||||
<< "findValue" << findValue.value<T>();
|
<< "findValue" << findValue.value<T>();
|
||||||
if ((fieldValue & findMask.value<T>()) == findValue.value<T>()) {
|
if ((fieldValue & findMask.value<T>()) == findValue.value<T>()) {
|
||||||
T newValue = (fieldValue & ~replaceMask.value<T>())
|
T newValue = (fieldValue & ~replaceMask.value<T>())
|
||||||
| (replaceValue.value<T>() & replaceMask.value<T>());
|
| (replaceValue.value<T>() & replaceMask.value<T>());
|
||||||
qDebug() << "findReplace:"
|
qDebug() << "findReplace:"
|
||||||
<< "replaceMask" << hex << replaceMask.value<T>() << dec
|
<< "replaceMask" << Qt::hex << replaceMask.value<T>() << Qt::dec
|
||||||
<< "replaceValue" << replaceValue.value<T>()
|
<< "replaceValue" << replaceValue.value<T>()
|
||||||
<< "newValue" << newValue;
|
<< "newValue" << newValue;
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#define _STREAM_BASE_H
|
#define _STREAM_BASE_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QLinkedList>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "protocol.pb.h"
|
#include "protocol.pb.h"
|
||||||
|
@ -219,7 +219,7 @@ template <> inline UInt128 qToBigEndian<UInt128>(const UInt128 src)
|
|||||||
inline QDebug operator<<(QDebug debug, const UInt128 &value)
|
inline QDebug operator<<(QDebug debug, const UInt128 &value)
|
||||||
{
|
{
|
||||||
QDebugStateSaver saver(debug);
|
QDebugStateSaver saver(debug);
|
||||||
debug.maybeSpace() << hex << value.hi64() << " " << value.lo64();
|
debug.maybeSpace() << Qt::hex << value.hi64() << " " << value.lo64();
|
||||||
|
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ public:
|
|||||||
virtual int protocolFrameVariableCount() const;
|
virtual int protocolFrameVariableCount() const;
|
||||||
|
|
||||||
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
virtual quint32 protocolFrameCksum(int streamIndex = 0,
|
||||||
CksumType cksumType = CksumIp, CksumFlags cksumFlags = 0) const;
|
CksumType cksumType = CksumIp, CksumFlags cksumFlags = CksumFlag::ExcludeCksumField) const;
|
||||||
|
|
||||||
void evaluateUserScript() const;
|
void evaluateUserScript() const;
|
||||||
bool isScriptValid() const;
|
bool isScriptValid() const;
|
||||||
|
@ -443,12 +443,12 @@ void ModelTest::data()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// General Purpose roles that should return a QColor
|
// General Purpose roles that should return a QColor
|
||||||
QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole );
|
QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundRole );
|
||||||
if ( colorVariant.isValid() ) {
|
if ( colorVariant.isValid() ) {
|
||||||
QVERIFY( colorVariant.canConvert<QColor>() );
|
QVERIFY( colorVariant.canConvert<QColor>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole );
|
colorVariant = model->data ( model->index ( 0, 0 ), Qt::ForegroundRole );
|
||||||
if ( colorVariant.isValid() ) {
|
if ( colorVariant.isValid() ) {
|
||||||
QVERIFY( colorVariant.canConvert<QColor>() );
|
QVERIFY( colorVariant.canConvert<QColor>() );
|
||||||
}
|
}
|
||||||
|
6
extra/modeltest/target_wrapper.sh
Executable file
6
extra/modeltest/target_wrapper.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
LD_LIBRARY_PATH=/usr/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
QT_PLUGIN_PATH=/usr/lib64/qt5/plugins${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}
|
||||||
|
export QT_PLUGIN_PATH
|
||||||
|
exec "$@"
|
@ -66,7 +66,7 @@ void tst_ModelTest::stringListModel()
|
|||||||
model.setStringList(QStringList() << "a" << "e" << "plop" << "b" << "c" );
|
model.setStringList(QStringList() << "a" << "e" << "plop" << "b" << "c" );
|
||||||
|
|
||||||
proxy.setDynamicSortFilter(true);
|
proxy.setDynamicSortFilter(true);
|
||||||
proxy.setFilterRegExp(QRegExp("[^b]"));
|
proxy.setFilterRegularExpression(QRegularExpression("[^b]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_ModelTest::treeWidgetModel()
|
void tst_ModelTest::treeWidgetModel()
|
||||||
|
@ -426,7 +426,7 @@ QString QHexEdit::selectionToReadableString()
|
|||||||
void QHexEdit::setFont(const QFont &font)
|
void QHexEdit::setFont(const QFont &font)
|
||||||
{
|
{
|
||||||
QWidget::setFont(font);
|
QWidget::setFont(font);
|
||||||
_pxCharWidth = fontMetrics().width(QLatin1Char('2'));
|
_pxCharWidth = fontMetrics().horizontalAdvance("2");
|
||||||
_pxCharHeight = fontMetrics().height();
|
_pxCharHeight = fontMetrics().height();
|
||||||
_pxGapAdr = _pxCharWidth / 2;
|
_pxGapAdr = _pxCharWidth / 2;
|
||||||
_pxGapAdrHex = _pxCharWidth;
|
_pxGapAdrHex = _pxCharWidth;
|
||||||
|
@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QThreadStorage>
|
#include <QThreadStorage>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include <qendian.h>
|
#include <qendian.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -83,7 +84,8 @@ void RpcConnection::start()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug("clientSock Thread = %p", clientSock->thread());
|
qDebug("clientSock Thread = %p", clientSock->thread());
|
||||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
|
||||||
|
// qsrand(QDateTime::currentDateTime().toTime_t());
|
||||||
|
|
||||||
connId.setLocalData(new QString(id.arg(clientSock->peerAddress().toString())
|
connId.setLocalData(new QString(id.arg(clientSock->peerAddress().toString())
|
||||||
.arg(clientSock->peerPort())));
|
.arg(clientSock->peerPort())));
|
||||||
|
@ -78,7 +78,7 @@ private:
|
|||||||
AbstractPort *port_;
|
AbstractPort *port_;
|
||||||
|
|
||||||
QMutex listLock_; // protects all the lists
|
QMutex listLock_; // protects all the lists
|
||||||
QHash<uint, OstProto::DeviceGroup*> deviceGroupList_;
|
QMultiHash<uint, OstProto::DeviceGroup*> deviceGroupList_;
|
||||||
QHash<DeviceKey, Device*> deviceList_; // fast access to devices
|
QHash<DeviceKey, Device*> deviceList_; // fast access to devices
|
||||||
QMap<DeviceKey, Device*> sortedDeviceList_; // sorted access to devices
|
QMap<DeviceKey, Device*> sortedDeviceList_; // sorted access to devices
|
||||||
QMultiHash<DeviceKey, Device*> bcastList_;
|
QMultiHash<DeviceKey, Device*> bcastList_;
|
||||||
|
@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QTime>
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -982,7 +982,7 @@ void LinuxPort::StatsMonitor::stop()
|
|||||||
|
|
||||||
bool LinuxPort::StatsMonitor::waitForSetupFinished(int msecs)
|
bool LinuxPort::StatsMonitor::waitForSetupFinished(int msecs)
|
||||||
{
|
{
|
||||||
QTime t;
|
QElapsedTimer t;
|
||||||
|
|
||||||
t.start();
|
t.start();
|
||||||
while (!setupDone_)
|
while (!setupDone_)
|
||||||
|
@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QRegularExpression>>
|
||||||
|
|
||||||
PortManager *PortManager::instance_ = NULL;
|
PortManager *PortManager::instance_ = NULL;
|
||||||
|
|
||||||
@ -242,13 +243,11 @@ AbstractPort::Accuracy PortManager::rateAccuracy()
|
|||||||
|
|
||||||
bool PortManager::filterAcceptsPort(const char *name)
|
bool PortManager::filterAcceptsPort(const char *name)
|
||||||
{
|
{
|
||||||
QRegExp pattern;
|
|
||||||
QStringList includeList = appSettings->value(kPortListIncludeKey)
|
QStringList includeList = appSettings->value(kPortListIncludeKey)
|
||||||
.toStringList();
|
.toStringList();
|
||||||
QStringList excludeList = appSettings->value(kPortListExcludeKey)
|
QStringList excludeList = appSettings->value(kPortListExcludeKey)
|
||||||
.toStringList();
|
.toStringList();
|
||||||
|
|
||||||
pattern.setPatternSyntax(QRegExp::Wildcard);
|
|
||||||
|
|
||||||
// An empty (or missing) includeList accepts all ports
|
// An empty (or missing) includeList accepts all ports
|
||||||
// NOTE: A blank "IncludeList=" is read as a stringlist with one
|
// NOTE: A blank "IncludeList=" is read as a stringlist with one
|
||||||
@ -258,8 +257,10 @@ bool PortManager::filterAcceptsPort(const char *name)
|
|||||||
goto _include_pass;
|
goto _include_pass;
|
||||||
|
|
||||||
foreach (QString str, includeList) {
|
foreach (QString str, includeList) {
|
||||||
pattern.setPattern(str);
|
QString wildcardExp = QRegularExpression::wildcardToRegularExpression(str);
|
||||||
if (pattern.exactMatch(name))
|
QRegularExpression pattern(QRegularExpression::anchoredPattern(wildcardExp),
|
||||||
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
|
if (pattern.match(name).hasMatch())
|
||||||
goto _include_pass;
|
goto _include_pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,8 +269,10 @@ bool PortManager::filterAcceptsPort(const char *name)
|
|||||||
|
|
||||||
_include_pass:
|
_include_pass:
|
||||||
foreach (QString str, excludeList) {
|
foreach (QString str, excludeList) {
|
||||||
pattern.setPattern(str);
|
QString wildcardExp = QRegularExpression::wildcardToRegularExpression(str);
|
||||||
if (pattern.exactMatch(name))
|
QRegularExpression pattern(QRegularExpression::anchoredPattern(wildcardExp),
|
||||||
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
|
if (pattern.match(name).hasMatch())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user