summaryrefslogtreecommitdiff
path: root/csharp/src/Ice/Network.cs
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-01-20 16:52:33 +0100
committerBenoit Foucher <benoit@zeroc.com>2017-01-20 16:52:33 +0100
commit10d9e3aae20e55d9824b632e77d8f14fd67b122f (patch)
treee38f0c77e423d9c1a8a5faf4abfccdfa63a905b3 /csharp/src/Ice/Network.cs
parentjava:UserException metadata for both local and remote operations (diff)
downloadice-10d9e3aae20e55d9824b632e77d8f14fd67b122f.tar.bz2
ice-10d9e3aae20e55d9824b632e77d8f14fd67b122f.tar.xz
ice-10d9e3aae20e55d9824b632e77d8f14fd67b122f.zip
Fixed ICE-6708 - the UDP transport now join the multicast group on all interfaces by default
Diffstat (limited to 'csharp/src/Ice/Network.cs')
-rw-r--r--csharp/src/Ice/Network.cs76
1 files changed, 30 insertions, 46 deletions
diff --git a/csharp/src/Ice/Network.cs b/csharp/src/Ice/Network.cs
index 0d068ddebcf..2d410d6a944 100644
--- a/csharp/src/Ice/Network.cs
+++ b/csharp/src/Ice/Network.cs
@@ -435,19 +435,6 @@ namespace IceInternal
try
{
int ifaceIndex = getInterfaceIndex(iface, family);
- if(ifaceIndex == -1)
- {
- try
- {
- ifaceIndex = int.Parse(iface, CultureInfo.InvariantCulture);
- }
- catch(FormatException ex)
- {
- closeSocketNoThrow(socket);
- throw new Ice.SocketException(ex);
- }
- }
-
if(family == AddressFamily.InterNetwork)
{
ifaceIndex = IPAddress.HostToNetworkOrder(ifaceIndex);
@@ -469,33 +456,41 @@ namespace IceInternal
{
try
{
- int index = getInterfaceIndex(iface, group.AddressFamily);
- if(group.AddressFamily == AddressFamily.InterNetwork)
+ int protocolSupport = group.AddressFamily == AddressFamily.InterNetwork ? EnableIPv4 : EnableIPv6;
+ List<string> interfaces = getHostsForEndpointExpand(iface, protocolSupport, true);
+ if(interfaces.Count == 0)
{
- MulticastOption option;
- if(index == -1)
- {
- option = new MulticastOption(group);
- }
-
- else
- {
- option = new MulticastOption(group, index);
- }
- s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, option);
+ interfaces.Add(iface);
}
- else
+ foreach(string intf in interfaces)
{
- IPv6MulticastOption option;
- if(index == -1)
+ int index = getInterfaceIndex(intf, group.AddressFamily);
+ if(group.AddressFamily == AddressFamily.InterNetwork)
{
- option = new IPv6MulticastOption(group);
+ MulticastOption option;
+ if(index == -1)
+ {
+ option = new MulticastOption(group);
+ }
+ else
+ {
+ option = new MulticastOption(group, index);
+ }
+ s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, option);
}
else
{
- option = new IPv6MulticastOption(group, index);
+ IPv6MulticastOption option;
+ if(index == -1)
+ {
+ option = new IPv6MulticastOption(group);
+ }
+ else
+ {
+ option = new IPv6MulticastOption(group, index);
+ }
+ s.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.AddMembership, option);
}
- s.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.AddMembership, option);
}
}
catch(Exception ex)
@@ -841,18 +836,6 @@ namespace IceInternal
}
}
}
-
- foreach(IPAddress a in Dns.GetHostAddresses(Dns.GetHostName()))
- {
- if((a.AddressFamily == AddressFamily.InterNetwork && protocol != EnableIPv6) ||
- (a.AddressFamily == AddressFamily.InterNetworkV6 && protocol != EnableIPv4))
- {
- if(includeLoopback || !IPAddress.IsLoopback(a))
- {
- addresses.Add(a);
- }
- }
- }
}
catch(SocketException ex)
{
@@ -1178,7 +1161,8 @@ namespace IceInternal
}
}
}
- return -1;
+
+ throw new ArgumentException("couldn't find interface `" + iface + "'");
}
public static EndPoint
@@ -1187,7 +1171,7 @@ namespace IceInternal
EndPoint addr = null;
if(!string.IsNullOrEmpty(sourceAddress))
{
- List<EndPoint> addrs = getAddresses(sourceAddress, 0, EnableBoth, Ice.EndpointSelectionType.Ordered,
+ List<EndPoint> addrs = getAddresses(sourceAddress, 0, EnableBoth, Ice.EndpointSelectionType.Ordered,
false, false);
if(addrs.Count != 0)
{