summaryrefslogtreecommitdiffstats
path: root/src/net/mcast/trial_programs/McastConfigArgParser.cpp
diff options
context:
space:
mode:
authorSebastien Braun2010-07-12 04:15:13 +0200
committerSebastien Braun2010-07-12 04:15:13 +0200
commit6940ab33b5009b79c3141dde7f98ea78a2662449 (patch)
treee72dfc8f8d53419f1bd9704b82789bba284482e9 /src/net/mcast/trial_programs/McastConfigArgParser.cpp
parentImport OpenPGM into the tree, and provide a rudimentary build script. (diff)
downloadpvs-6940ab33b5009b79c3141dde7f98ea78a2662449.tar.gz
pvs-6940ab33b5009b79c3141dde7f98ea78a2662449.tar.xz
pvs-6940ab33b5009b79c3141dde7f98ea78a2662449.zip
Implement multicast transfer protocol.
Diffstat (limited to 'src/net/mcast/trial_programs/McastConfigArgParser.cpp')
-rw-r--r--src/net/mcast/trial_programs/McastConfigArgParser.cpp151
1 files changed, 151 insertions, 0 deletions
diff --git a/src/net/mcast/trial_programs/McastConfigArgParser.cpp b/src/net/mcast/trial_programs/McastConfigArgParser.cpp
new file mode 100644
index 0000000..8849544
--- /dev/null
+++ b/src/net/mcast/trial_programs/McastConfigArgParser.cpp
@@ -0,0 +1,151 @@
+/*
+# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# src/net/mcast/trial_programs/McastConfigArgParser.cpp
+# - Parse common Multicast Configuration CLI arguments
+# -----------------------------------------------------------------------------
+*/
+
+#include <iostream>
+
+#include <QCoreApplication>
+
+#include "McastConfigArgParser.h"
+
+using namespace std;
+
+bool parseMcastConfigArg(QStringList::iterator& i, QStringList::iterator const& end, McastConfiguration* config)
+{
+ QString arg = *i;
+
+ if (arg == "-addr")
+ {
+ i++;
+ if(i == end)
+ {
+ cerr << "Option " << arg.toLatin1().constData() << " is missing argument" << endl;
+ return false;
+ }
+ config->multicastAddress(*i);
+ }
+ else if (arg == "-dport")
+ {
+ i++;
+ if(i == end)
+ {
+ cerr << "Option " << arg.toLatin1().constData() << " is missing argument" << endl;
+ return false;
+ }
+ bool ok;
+ quint16 dport = (quint16)i->toInt(&ok);
+ if (!ok)
+ {
+ cerr << "Error: dport is not an integer" << endl;
+ return false;
+ }
+ config->multicastDPort(dport);
+ }
+ else if (arg == "-sport")
+ {
+ i++;
+ if(i == end)
+ {
+ cerr << "Option " << arg.toLatin1().constData() << " is missing argument" << endl;
+ return false;
+ }
+ bool ok;
+ quint16 sport = (quint16)i->toInt(&ok);
+ if (!ok)
+ {
+ cerr << "Error: sport is not an integer" << endl;
+ return false;
+ }
+ config->multicastSPort(sport);
+ }
+ else if (arg == "-mtu")
+ {
+ i++;
+ if(i == end)
+ {
+ cerr << "Option " << arg.toLatin1().constData() << " is missing argument" << endl;
+ return false;
+ }
+ bool ok;
+ quint16 mtu = (quint16)i->toInt(&ok);
+ if (!ok)
+ {
+ cerr << "Error: MTU is not an integer" << endl;
+ return false;
+ }
+ config->multicastMTU(mtu);
+ }
+ else if (arg == "-rate")
+ {
+ i++;
+ if(i == end)
+ {
+ cerr << "Option " << arg.toLatin1().constData() << " is missing argument" << endl;
+ return false;
+ }
+ bool ok;
+ quint32 rate = i->toInt(&ok);
+ if (!ok)
+ {
+ cerr << "Error: Rate is not an integer" << endl;
+ return false;
+ }
+ config->multicastRate(rate);
+ }
+ else if (arg == "-winsize")
+ {
+ i++;
+ if(i == end)
+ {
+ cerr << "Option " << arg.toLatin1().constData() << " is missing argument" << endl;
+ return false;
+ }
+ bool ok;
+ quint16 winsize = (quint16)i->toInt(&ok);
+ if (!ok)
+ {
+ cerr << "Error: Winsize is not an integer" << endl;
+ return false;
+ }
+ config->multicastWinSize(winsize);
+ }
+ else if (arg == "-udp")
+ {
+ config->multicastUseUDP(true);
+ }
+ else if (arg == "-udp-port")
+ {
+ i++;
+ if(i == end)
+ {
+ cerr << "Option " << arg.toLatin1().constData() << " is missing argument" << endl;
+ return false;
+ }
+ bool ok;
+ quint16 udpport = (quint16)i->toInt(&ok);
+ if (!ok)
+ {
+ cerr << "Error: UDP-Port is not an integer" << endl;
+ return false;
+ }
+ config->multicastUDPPort(udpport);
+ }
+ else
+ {
+ return false;
+ }
+
+ return true;
+}