summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorSebastien Braun2010-07-14 16:13:57 +0200
committerSebastien Braun2010-07-14 16:13:57 +0200
commit4bedfeeaa534e5e59b7fad745c5be0d6b7d587df (patch)
treea9ea01cb62fe8a5b97d608a4d54fc2a1c1abcffd /src/net
parentMake UDP encapsulation correctly configurable. (diff)
downloadpvs-4bedfeeaa534e5e59b7fad745c5be0d6b7d587df.tar.gz
pvs-4bedfeeaa534e5e59b7fad745c5be0d6b7d587df.tar.xz
pvs-4bedfeeaa534e5e59b7fad745c5be0d6b7d587df.zip
Make interface configurable.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/mcast/McastConfiguration.h13
-rw-r--r--src/net/mcast/McastConstants.h3
-rw-r--r--src/net/mcast/McastPGMSocket.cpp2
-rw-r--r--src/net/mcast/trial_programs/McastConfigArgParser.cpp10
4 files changed, 26 insertions, 2 deletions
diff --git a/src/net/mcast/McastConfiguration.h b/src/net/mcast/McastConfiguration.h
index c32ac4f..4e0e2ad 100644
--- a/src/net/mcast/McastConfiguration.h
+++ b/src/net/mcast/McastConfiguration.h
@@ -29,6 +29,7 @@ Q_OBJECT
public:
McastConfiguration(QObject* parent = 0) :
QObject(parent),
+ _multicastInterface(DEFAULT_MULTICAST_INTERFACE),
_multicastAddress(DEFAULT_MULTICAST_ADDRESS),
_multicastRate(DEFAULT_MULTICAST_RATE),
_multicastSPort(DEFAULT_MULTICAST_SPORT),
@@ -41,6 +42,7 @@ public:
}
McastConfiguration(McastConfiguration const& other) :
+ _multicastInterface(other._multicastInterface),
QObject(),
_multicastAddress(other._multicastAddress),
_multicastRate(other._multicastRate),
@@ -137,6 +139,16 @@ public:
return this;
}
+ QString multicastInterface() const
+ {
+ return _multicastInterface;
+ }
+ McastConfiguration* multicastInterface(QString const& interface)
+ {
+ _multicastInterface = interface;
+ return this;
+ }
+
quint16 multicastUDPUPort() const
{
return _multicastUDPPortBase;
@@ -156,6 +168,7 @@ signals:
void changed();
private:
+ QString _multicastInterface;
QString _multicastAddress;
quint32 _multicastRate;
quint16 _multicastSPort;
diff --git a/src/net/mcast/McastConstants.h b/src/net/mcast/McastConstants.h
index 9913457..b4c71a5 100644
--- a/src/net/mcast/McastConstants.h
+++ b/src/net/mcast/McastConstants.h
@@ -20,7 +20,8 @@
#include <stdint.h>
#define MCASTFT_MAGIC UINT64_C(0x6d60ad83825fb7f9)
-#define DEFAULT_MULTICAST_ADDRESS ";239.255.220.207"
+#define DEFAULT_MULTICAST_INTERFACE ""
+#define DEFAULT_MULTICAST_ADDRESS "239.255.220.207"
#define DEFAULT_MULTICAST_SPORT 6964
#define DEFAULT_MULTICAST_DPORT 6965
#define DEFAULT_MULTICAST_USEUDP true
diff --git a/src/net/mcast/McastPGMSocket.cpp b/src/net/mcast/McastPGMSocket.cpp
index 41764d5..ebf6ae7 100644
--- a/src/net/mcast/McastPGMSocket.cpp
+++ b/src/net/mcast/McastPGMSocket.cpp
@@ -132,7 +132,7 @@ bool McastPGMSocket::open(McastConfiguration const* config, Direction direction)
pgm_addrinfo_t* addrinfo;
// parse the address string
- good = pgm_getaddrinfo(config->multicastAddress().toLatin1().constData(),
+ good = pgm_getaddrinfo((config->multicastInterface() + ";" + config->multicastAddress()).toLatin1().constData(),
0, &addrinfo, &err);
if (!good)
{
diff --git a/src/net/mcast/trial_programs/McastConfigArgParser.cpp b/src/net/mcast/trial_programs/McastConfigArgParser.cpp
index efea0b5..881f728 100644
--- a/src/net/mcast/trial_programs/McastConfigArgParser.cpp
+++ b/src/net/mcast/trial_programs/McastConfigArgParser.cpp
@@ -146,6 +146,16 @@ bool parseMcastConfigArg(QStringList::iterator& i, QStringList::iterator const&
}
config->multicastUDPPortBase(udpport);
}
+ else if (arg == "-intf")
+ {
+ i++;
+ if (i == end)
+ {
+ cerr << "Option " << arg.toLatin1().constData() << "is missing argument" << endl;
+ return false;
+ }
+ config->multicastInterface(*i);
+ }
else
{
return false;