diff --git a/client/main.cpp b/client/main.cpp
index a13ff77..07b073f 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -18,7 +18,9 @@ along with this program. If not, see
*/
#include "mainwindow.h"
+#include "../common/ostprotolib.h"
#include "../common/protocolmanager.h"
+#include "settings.h"
#include
#include
@@ -31,11 +33,23 @@ extern ProtocolManager *OstProtocolManager;
QSettings *appSettings;
QMainWindow *mainWindow;
+#if defined(Q_OS_WIN32)
+QString kGzipPathDefaultValue;
+QString kDiffPathDefaultValue;
+QString kAwkPathDefaultValue;
+#endif
+
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
int exitCode;
+#if defined(Q_OS_WIN32)
+ kGzipPathDefaultValue = app.applicationDirPath() + "/gzip.exe";
+ kDiffPathDefaultValue = app.applicationDirPath() + "/diff.exe";
+ kAwkPathDefaultValue = app.applicationDirPath() + "/gawk.exe";
+#endif
+
app.setApplicationName("Ostinato");
app.setOrganizationName("Ostinato");
app.setProperty("version", version);
@@ -53,6 +67,12 @@ int main(int argc, char* argv[])
else
appSettings = new QSettings();
+ OstProtoLib::setExternalApplicationPaths(
+ appSettings->value(kTsharkPathKey, kTsharkPathDefaultValue).toString(),
+ appSettings->value(kGzipPathKey, kGzipPathDefaultValue).toString(),
+ appSettings->value(kDiffPathKey, kDiffPathDefaultValue).toString(),
+ appSettings->value(kAwkPathKey, kAwkPathDefaultValue).toString());
+
mainWindow = new MainWindow;
mainWindow->show();
exitCode = app.exec();
diff --git a/client/preferences.cpp b/client/preferences.cpp
index 4f372ee..0e54bbd 100644
--- a/client/preferences.cpp
+++ b/client/preferences.cpp
@@ -19,6 +19,7 @@ along with this program. If not, see
#include "preferences.h"
+#include "../common/ostprotolib.h"
#include "settings.h"
#include
@@ -31,6 +32,14 @@ Preferences::Preferences()
wiresharkPathEdit->setText(appSettings->value(kWiresharkPathKey,
kWiresharkPathDefaultValue).toString());
+ tsharkPathEdit->setText(appSettings->value(kTsharkPathKey,
+ kTsharkPathDefaultValue).toString());
+ gzipPathEdit->setText(appSettings->value(kGzipPathKey,
+ kGzipPathDefaultValue).toString());
+ diffPathEdit->setText(appSettings->value(kDiffPathKey,
+ kDiffPathDefaultValue).toString());
+ awkPathEdit->setText(appSettings->value(kAwkPathKey,
+ kAwkPathDefaultValue).toString());
}
Preferences::~Preferences()
@@ -40,6 +49,16 @@ Preferences::~Preferences()
void Preferences::accept()
{
appSettings->setValue(kWiresharkPathKey, wiresharkPathEdit->text());
+ appSettings->setValue(kTsharkPathKey, tsharkPathEdit->text());
+ appSettings->setValue(kGzipPathKey, gzipPathEdit->text());
+ appSettings->setValue(kDiffPathKey, diffPathEdit->text());
+ appSettings->setValue(kAwkPathKey, awkPathEdit->text());
+
+ OstProtoLib::setExternalApplicationPaths(
+ appSettings->value(kTsharkPathKey, kTsharkPathDefaultValue).toString(),
+ appSettings->value(kGzipPathKey, kGzipPathDefaultValue).toString(),
+ appSettings->value(kDiffPathKey, kDiffPathDefaultValue).toString(),
+ appSettings->value(kAwkPathKey, kAwkPathDefaultValue).toString());
QDialog::accept();
}
@@ -54,3 +73,47 @@ void Preferences::on_wiresharkPathButton_clicked()
if (!path.isEmpty())
wiresharkPathEdit->setText(path);
}
+
+void Preferences::on_tsharkPathButton_clicked()
+{
+ QString path;
+
+ path = QFileDialog::getOpenFileName(0, "Locate tshark",
+ tsharkPathEdit->text());
+
+ if (!path.isEmpty())
+ tsharkPathEdit->setText(path);
+}
+
+void Preferences::on_gzipPathButton_clicked()
+{
+ QString path;
+
+ path = QFileDialog::getOpenFileName(0, "Locate gzip",
+ gzipPathEdit->text());
+
+ if (!path.isEmpty())
+ gzipPathEdit->setText(path);
+}
+
+void Preferences::on_diffPathButton_clicked()
+{
+ QString path;
+
+ path = QFileDialog::getOpenFileName(0, "Locate diff",
+ diffPathEdit->text());
+
+ if (!path.isEmpty())
+ diffPathEdit->setText(path);
+}
+
+void Preferences::on_awkPathButton_clicked()
+{
+ QString path;
+
+ path = QFileDialog::getOpenFileName(0, "Locate awk",
+ awkPathEdit->text());
+
+ if (!path.isEmpty())
+ awkPathEdit->setText(path);
+}
diff --git a/client/preferences.h b/client/preferences.h
index 1821346..78109ab 100644
--- a/client/preferences.h
+++ b/client/preferences.h
@@ -36,6 +36,10 @@ public slots:
private slots:
void on_wiresharkPathButton_clicked();
+ void on_tsharkPathButton_clicked();
+ void on_gzipPathButton_clicked();
+ void on_diffPathButton_clicked();
+ void on_awkPathButton_clicked();
};
#endif
diff --git a/client/preferences.ui b/client/preferences.ui
index 514ed42..d64b4cb 100644
--- a/client/preferences.ui
+++ b/client/preferences.ui
@@ -6,7 +6,7 @@
0
0
400
- 164
+ 220
@@ -24,37 +24,136 @@
QFrame::Sunken
-
- -
-
-
-
-
-
- Wireshark Path
-
-
-
- -
-
-
- -
-
-
- ...
-
-
-
-
+
+ -
+
+
+ 'wireshark' Path
+
+
+ wiresharkPathEdit
+
+
- -
+
-
+
+
+ false
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+ 'tshark' Path
+
+
+ tsharkPathEdit
+
+
+
+ -
+
+
+ false
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+ 'gzip' Path
+
+
+ diffPathEdit
+
+
+
+ -
+
+
+ false
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+ 'diff' Path
+
+
+ diffPathEdit
+
+
+
+ -
+
+
+ false
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+ 'awk' Path
+
+
+ awkPathEdit
+
+
+
+ -
+
+
+ false
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
Qt::Vertical
- 20
- 40
+ 21
+ 61
@@ -74,6 +173,19 @@
+
+ wiresharkPathEdit
+ wiresharkPathButton
+ tsharkPathEdit
+ tsharkPathButton
+ gzipPathEdit
+ gzipPathButton
+ diffPathEdit
+ diffPathButton
+ awkPathEdit
+ awkPathButton
+ buttonBox
+
diff --git a/client/settings.h b/client/settings.h
index 3fbf4cf..2f0666c 100644
--- a/client/settings.h
+++ b/client/settings.h
@@ -36,6 +36,44 @@ const QString kWiresharkPathDefaultValue(
const QString kWiresharkPathDefaultValue("/usr/bin/wireshark");
#endif
+const QString kTsharkPathKey("TsharkPath");
+#if defined(Q_OS_WIN32)
+const QString kTsharkPathDefaultValue(
+ "C:/Program Files/Wireshark/tshark.exe");
+#elif defined(Q_OS_MAC)
+const QString kTsharkPathDefaultValue(
+ "/Applications/Wireshark.app/Contents/Resources/bin/tshark");
+#else
+const QString kTsharkPathDefaultValue("/usr/bin/tshark");
+#endif
+
+const QString kGzipPathKey("GzipPath");
+#if defined(Q_OS_WIN32)
+extern QString kGzipPathDefaultValue;
+#elif defined(Q_OS_MAC)
+const QString kGzipPathDefaultValue("/usr/bin/gzip");
+#else
+const QString kGzipPathDefaultValue("/usr/bin/gzip");
+#endif
+
+const QString kDiffPathKey("DiffPath");
+#if defined(Q_OS_WIN32)
+extern QString kDiffPathDefaultValue;
+#elif defined(Q_OS_MAC)
+const QString kDiffPathDefaultValue("/usr/bin/diff");
+#else
+const QString kDiffPathDefaultValue("/usr/bin/diff");
+#endif
+
+const QString kAwkPathKey("AwkPath");
+#if defined(Q_OS_WIN32)
+extern QString kAwkPathDefaultValue;
+#elif defined(Q_OS_MAC)
+const QString kAwkPathDefaultValue("/usr/bin/awk");
+#else
+const QString kAwkPathDefaultValue("/usr/bin/awk");
+#endif
+
#endif
diff --git a/common/ostproto.pro b/common/ostproto.pro
index 7e3c80a..3fe62f2 100644
--- a/common/ostproto.pro
+++ b/common/ostproto.pro
@@ -56,6 +56,7 @@ PROTOS += \
hexdump.proto \
sample.proto
HEADERS += \
+ ostprotolib.h \
abstractprotocol.h \
comboprotocol.h \
abstractfileformat.h \
@@ -98,6 +99,7 @@ HEADERS += \
hexdump.h \
sample.h
SOURCES += \
+ ostprotolib.cpp \
abstractprotocol.cpp \
crc32c.cpp \
abstractfileformat.cpp \
diff --git a/common/ostprotolib.cpp b/common/ostprotolib.cpp
new file mode 100644
index 0000000..e46dc8c
--- /dev/null
+++ b/common/ostprotolib.cpp
@@ -0,0 +1,55 @@
+/*
+Copyright (C) 2011 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
+*/
+
+#include "ostprotolib.h"
+
+QString OstProtoLib::tsharkPath_;
+QString OstProtoLib::gzipPath_;
+QString OstProtoLib::diffPath_;
+QString OstProtoLib::awkPath_;
+
+void OstProtoLib::setExternalApplicationPaths(QString tsharkPath,
+ QString gzipPath, QString diffPath, QString awkPath)
+{
+ tsharkPath_ = tsharkPath;
+ gzipPath_ = gzipPath;
+ diffPath_ = diffPath;
+ awkPath_ = awkPath;
+}
+
+QString OstProtoLib::tsharkPath()
+{
+ return tsharkPath_;
+}
+
+QString OstProtoLib::gzipPath()
+{
+ return gzipPath_;
+}
+
+QString OstProtoLib::diffPath()
+{
+ return diffPath_;
+}
+
+QString OstProtoLib::awkPath()
+{
+ return awkPath_;
+}
+
diff --git a/common/ostprotolib.h b/common/ostprotolib.h
new file mode 100644
index 0000000..4d10626
--- /dev/null
+++ b/common/ostprotolib.h
@@ -0,0 +1,42 @@
+/*
+Copyright (C) 2011 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 _OST_PROTO_LIB_H
+#define _OST_PROTO_LIB_H
+
+#include
+
+class OstProtoLib
+{
+public:
+ static void setExternalApplicationPaths(QString tsharkPath,
+ QString gzipPath, QString diffPath, QString awkPath);
+
+ static QString tsharkPath();
+ static QString gzipPath();
+ static QString diffPath();
+ static QString awkPath();
+
+private:
+ static QString tsharkPath_;
+ static QString gzipPath_;
+ static QString diffPath_;
+ static QString awkPath_;
+};
+
+#endif
diff --git a/common/pcapfileformat.cpp b/common/pcapfileformat.cpp
index 89e122b..106399f 100644
--- a/common/pcapfileformat.cpp
+++ b/common/pcapfileformat.cpp
@@ -20,6 +20,7 @@ along with this program. If not, see
#include "pcapfileformat.h"
#include "pdml_p.h"
+#include "ostprotolib.h"
#include "streambase.h"
#include "hexdump.pb.h"
@@ -131,15 +132,14 @@ bool PcapFileFormat::openStreams(const QString fileName,
qDebug("decompressing to %s", file2.fileName().toAscii().constData());
gzip.setStandardOutputFile(file2.fileName());
- // FIXME: hardcoded prog name
- gzip.start("C:/Program Files/CmdLineTools/gzip.exe",
+ gzip.start(OstProtoLib::gzipPath(),
QStringList()
<< "-d"
<< "-c"
<< fileName);
if (!gzip.waitForStarted(-1))
{
- error.append(QString("Unable to start gzip\n"));
+ error.append(QString("Unable to start gzip. Check path in Preferences.\n"));
goto _err_unzip_fail;
}
@@ -214,15 +214,14 @@ bool PcapFileFormat::openStreams(const QString fileName,
emit target(0);
tshark.setStandardOutputFile(pdmlFile.fileName());
- // FIXME: hardcoded prog name
- tshark.start("C:/Program Files/Wireshark/Tshark.exe",
+ tshark.start(OstProtoLib::tsharkPath(),
QStringList()
<< QString("-r%1").arg(fileName)
<< "-otcp.desegment_tcp_streams:FALSE"
<< "-Tpdml");
if (!tshark.waitForStarted(-1))
{
- error.append(QString("Unable to start tshark\n"));
+ error.append(QString("Unable to start tshark. Check path in preferences.\n"));
goto _non_pdml;
}
@@ -287,27 +286,23 @@ bool PcapFileFormat::openStreams(const QString fileName,
tshark.setStandardOutputProcess(&awk);
awk.setStandardOutputFile(originalTextFile.fileName());
- // FIXME: hardcoded prog name
- tshark.start("C:/Program Files/Wireshark/Tshark.exe",
+ tshark.start(OstProtoLib::tsharkPath(),
QStringList()
<< QString("-r%1").arg(fileName)
<< "-otcp.desegment_tcp_streams:FALSE"
<< "-x");
if (!tshark.waitForStarted(-1))
{
- error.append(QString("Unable to start tshark - %1\n")
- .arg(tshark.exitCode()));
+ error.append(QString("Unable to start tshark. Check path in Preferences.\n"));
goto _diff_fail;
}
- // FIXME: hardcoded prog name
- awk.start("D:/srivatsp/projects/ostinato/pdml/bin/gawk.exe",
+ awk.start(OstProtoLib::awkPath(),
QStringList() << kAwkFilter);
if (!awk.waitForStarted(-1))
{
tshark.kill();
- error.append(QString("Unable to start awk - %1\n")
- .arg(awk.exitCode()));
+ error.append(QString("Unable to start awk. Check path in Preferences.\n"));
goto _diff_fail;
}
@@ -351,27 +346,23 @@ bool PcapFileFormat::openStreams(const QString fileName,
tshark.setStandardOutputProcess(&awk);
awk.setStandardOutputFile(importedTextFile.fileName());
- // FIXME: hardcoded prog name
- tshark.start("C:/Program Files/Wireshark/Tshark.exe",
+ tshark.start(OstProtoLib::tsharkPath(),
QStringList()
<< QString("-r%1").arg(importedPcapFile.fileName())
<< "-otcp.desegment_tcp_streams:FALSE"
<< "-x");
if (!tshark.waitForStarted(-1))
{
- error.append(QString("Unable to start tshark - %1\n")
- .arg(tshark.exitCode()));
+ error.append(QString("Unable to start tshark. Check path in Preferences.\n"));
goto _diff_fail;
}
- // FIXME: hardcoded prog name
- awk.start("D:/srivatsp/projects/ostinato/pdml/bin/gawk.exe",
+ awk.start(OstProtoLib::awkPath(),
QStringList() << kAwkFilter);
if (!awk.waitForStarted(-1))
{
tshark.kill();
- error.append(QString("Unable to start awk - %1\n")
- .arg(awk.exitCode()));
+ error.append(QString("Unable to start awk. Check path in Preferences.\n"));
goto _diff_fail;
}
@@ -401,8 +392,7 @@ bool PcapFileFormat::openStreams(const QString fileName,
emit target(0);
diff.setStandardOutputFile(diffFile.fileName());
- // FIXME: hardcoded prog name
- diff.start("D:/srivatsp/projects/ostinato/pdml/bin/diff.exe",
+ diff.start(OstProtoLib::diffPath(),
QStringList()
<< "-u"
<< "-F^ [1-9]"
@@ -414,7 +404,7 @@ bool PcapFileFormat::openStreams(const QString fileName,
<< importedTextFile.fileName());
if (!diff.waitForStarted(-1))
{
- error.append(QString("Unable to start diff\n")
+ error.append(QString("Unable to start diff. Check path in Preferences.\n")
.arg(diff.exitCode()));
goto _diff_fail;
}