From 4bedfeeaa534e5e59b7fad745c5be0d6b7d587df Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Wed, 14 Jul 2010 16:13:57 +0200 Subject: Make interface configurable. --- src/net/mcast/McastConfiguration.h | 13 +++++++++++++ src/net/mcast/McastConstants.h | 3 ++- src/net/mcast/McastPGMSocket.cpp | 2 +- src/net/mcast/trial_programs/McastConfigArgParser.cpp | 10 ++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) (limited to 'src/net/mcast') 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 #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; -- cgit v1.2.3-55-g7522