Skip to content

Commit

Permalink
https://tools.ietf.org/html/rfc7346
Browse files Browse the repository at this point in the history
  • Loading branch information
ikpil committed Sep 24, 2024
1 parent 9d0ff54 commit 6929fb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions test/UniNetty.Transport.Tests/Channel/Sockets/NetUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ namespace UniNetty.Transport.Tests.Channel.Sockets

public static class NetUtil
{
/**
* See <a href="https://tools.ietf.org/html/rfc7346#section-2">RFC7346, IPv6 Multicast Address Scopes</a>
*/
public static readonly IPAddress MULTICAST_IPV4 = IPAddress.Parse("230.0.0.1");
public static readonly IPAddress MULTICAST_IPV6_INTERFACE_LOCAL = IPAddress.Parse("FF01::1");

public static readonly IPAddress MULTICAST_IPV6_SITE_LOCAL = IPAddress.Parse("FF05::1");

internal static readonly AddressFamily[] AddressFamilyTypes =
{
Expand Down Expand Up @@ -64,7 +68,7 @@ public static IPAddress GetLoopbackAddress(AddressFamily addressFamily)

throw new NotSupportedException($"Address family {addressFamily} is not supported. Expecting InterNetwork/InterNetworkV6");
}

public static NetworkInterface LoopbackInterface(AddressFamily addressFamily)
{
var nis = NetworkInterface.GetAllNetworkInterfaces();
Expand All @@ -75,7 +79,7 @@ public static NetworkInterface LoopbackInterface(AddressFamily addressFamily)

if (ni.NetworkInterfaceType != NetworkInterfaceType.Loopback)
continue;

var ipProps = ni.GetIPProperties();
foreach (var multicast in ipProps.UnicastAddresses)
{
Expand All @@ -97,7 +101,7 @@ public static NetworkInterface SupportsMulticastInterface(AddressFamily addressF
{
if (ni.NetworkInterfaceType == NetworkInterfaceType.Loopback)
continue;

if (!ni.SupportsMulticast)
continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void Multicast(AddressFamily addressFamily, IByteBufferAllocator allocato

IPAddress multicastAddress = addressFamily == AddressFamily.InterNetwork
? NetUtil.MULTICAST_IPV4
: NetUtil.MULTICAST_IPV6_INTERFACE_LOCAL;
: NetUtil.MULTICAST_IPV6_SITE_LOCAL;

var groupAddress = new IPEndPoint(multicastAddress, serverEndPoint.Port);
Task joinTask = serverChannel.JoinGroup(groupAddress);
Expand Down

0 comments on commit 6929fb1

Please sign in to comment.