summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-12-23 00:01:25 +0100
committerJose <jose@zeroc.com>2016-12-23 00:01:25 +0100
commitceba96fd8069cfb480f22ae5fb7f6f55634d8f1e (patch)
tree945009173817c906aaaec26a93661b7d9a888b00 /cpp/src
parentFix android test suite builds to use compat mapping (diff)
downloadice-ceba96fd8069cfb480f22ae5fb7f6f55634d8f1e.tar.bz2
ice-ceba96fd8069cfb480f22ae5fb7f6f55634d8f1e.tar.xz
ice-ceba96fd8069cfb480f22ae5fb7f6f55634d8f1e.zip
Fixed (ICE-7472) UWP and Mcast interface
In UWP the multicast interface must be send when the datagram socket is bind.
Diffstat (limited to 'cpp/src')
-rwxr-xr-xcpp/src/Ice/Network.cpp39
-rwxr-xr-xcpp/src/Ice/Network.h3
-rwxr-xr-xcpp/src/Ice/UdpTransceiver.cpp2
3 files changed, 36 insertions, 8 deletions
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index f14f7c1fb2e..e53532c48d9 100755
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -2047,7 +2047,7 @@ IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string&)
try
{
//
- // NOTE: UWP doesn't allow specyfing the interface.
+ // NOTE: UWP mcast interface is set earlier in doBind.
//
safe_cast<DatagramSocket^>(fd)->JoinMulticastGroup(group.host);
@@ -2219,10 +2219,10 @@ checkResultAndWait(IAsyncAction^ action)
}
#endif
+#ifdef ICE_OS_UWP
Address
-IceInternal::doBind(SOCKET fd, const Address& addr)
+IceInternal::doBind(SOCKET fd, const Address& addr, const string& intf)
{
-#ifdef ICE_OS_UWP
Address local;
try
{
@@ -2246,7 +2246,32 @@ IceInternal::doBind(SOCKET fd, const Address& addr)
{
if(addr.host == nullptr) // inaddr_any
{
- checkResultAndWait(datagram->BindServiceNameAsync(addr.port));
+ NetworkAdapter^ adapter;
+ if(!intf.empty())
+ {
+ auto s = ref new String(Ice::stringToWstring(intf).c_str());
+ auto profiles = NetworkInformation::GetConnectionProfiles();
+ for(auto i = profiles->First(); adapter == nullptr && i->HasCurrent; i->MoveNext())
+ {
+ auto names = i->Current->GetNetworkNames();
+ for(auto j = names->First(); adapter == nullptr && j->HasCurrent; j->MoveNext())
+ {
+ if(j->Current->Equals(s))
+ {
+ adapter = i->Current->NetworkAdapter;
+ }
+ }
+ }
+ }
+
+ if(adapter)
+ {
+ checkResultAndWait(datagram->BindServiceNameAsync(addr.port, adapter));
+ }
+ else
+ {
+ checkResultAndWait(datagram->BindServiceNameAsync(addr.port));
+ }
}
else
{
@@ -2262,7 +2287,11 @@ IceInternal::doBind(SOCKET fd, const Address& addr)
throw;
}
return local;
+}
#else
+Address
+IceInternal::doBind(SOCKET fd, const Address& addr, const string&)
+{
int size = getAddressStorageSize(addr);
assert(size != 0);
@@ -2283,8 +2312,8 @@ IceInternal::doBind(SOCKET fd, const Address& addr)
assert(ret != SOCKET_ERROR);
# endif
return local;
-#endif
}
+#endif
#ifndef ICE_OS_UWP
diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h
index 441fa79b893..f558cff3e13 100755
--- a/cpp/src/Ice/Network.h
+++ b/cpp/src/Ice/Network.h
@@ -303,8 +303,7 @@ ICE_API void setMcastGroup(SOCKET, const Address&, const std::string&);
ICE_API void setMcastInterface(SOCKET, const std::string&, const Address&);
ICE_API void setMcastTtl(SOCKET, int, const Address&);
ICE_API void setReuseAddress(SOCKET, bool);
-
-ICE_API Address doBind(SOCKET, const Address&);
+ICE_API Address doBind(SOCKET, const Address&, const std::string& intf = "");
ICE_API void doListen(SOCKET, int);
#ifndef ICE_OS_UWP
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index 4621750689e..00c035b557a 100755
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -142,7 +142,7 @@ IceInternal::UdpTransceiver::bind()
const_cast<Address&>(_addr) = getAddressForServer("", _port, getProtocolSupport(_addr), false);
#endif
- const_cast<Address&>(_addr) = doBind(_fd, _addr);
+ const_cast<Address&>(_addr) = doBind(_fd, _addr, _mcastInterface);
if(getPort(_mcastAddr) == 0)
{
setPort(_mcastAddr, getPort(_addr));