summaryrefslogtreecommitdiff
path: root/csharp/src
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
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')
-rw-r--r--csharp/src/Ice/Network.cs76
-rw-r--r--csharp/src/Ice/UdpEndpointI.cs18
-rw-r--r--csharp/src/Ice/UdpTransceiver.cs8
3 files changed, 54 insertions, 48 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)
{
diff --git a/csharp/src/Ice/UdpEndpointI.cs b/csharp/src/Ice/UdpEndpointI.cs
index 2e3418eaa9d..452eace26f6 100644
--- a/csharp/src/Ice/UdpEndpointI.cs
+++ b/csharp/src/Ice/UdpEndpointI.cs
@@ -158,6 +158,24 @@ namespace IceInternal
return null;
}
+ public override void initWithOptions(List<string> args, bool oaEndpoint)
+ {
+ base.initWithOptions(args, oaEndpoint);
+
+ if(_mcastInterface.Equals("*"))
+ {
+ if(oaEndpoint)
+ {
+ _mcastInterface = "";
+ }
+ else
+ {
+ throw new Ice.EndpointParseException("`--interface *' not valid for proxy endpoint `" +
+ ToString() + "'");
+ }
+ }
+ }
+
public UdpEndpointI endpoint(UdpTransceiver transceiver)
{
return new UdpEndpointI(instance_, host_, transceiver.effectivePort(), sourceAddr_, _mcastInterface,
diff --git a/csharp/src/Ice/UdpTransceiver.cs b/csharp/src/Ice/UdpTransceiver.cs
index d456b792a74..05f569c7b40 100644
--- a/csharp/src/Ice/UdpTransceiver.cs
+++ b/csharp/src/Ice/UdpTransceiver.cs
@@ -652,8 +652,12 @@ namespace IceInternal
public string toDetailedString()
{
StringBuilder s = new StringBuilder(ToString());
- List<string> intfs = Network.getHostsForEndpointExpand(
- Network.endpointAddressToString(_addr), _instance.protocolSupport(), true);
+ string addr = _mcastAddr != null ? _mcastInterface : Network.endpointAddressToString(_addr);
+ List<string> intfs = Network.getHostsForEndpointExpand(addr, _instance.protocolSupport(), true);
+ if(_mcastAddr != null && intfs.Count == 0)
+ {
+ intfs.Add(_mcastInterface);
+ }
if(intfs.Count != 0)
{
s.Append("\nlocal interfaces = ");