INetworkManager.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Net;
  5. using System.Net.NetworkInformation;
  6. namespace MediaBrowser.Common.Net
  7. {
  8. public interface INetworkManager
  9. {
  10. event EventHandler NetworkChanged;
  11. Func<string[]> LocalSubnetsFn { get; set; }
  12. /// <summary>
  13. /// Gets a random port number that is currently available.
  14. /// </summary>
  15. /// <returns>System.Int32.</returns>
  16. int GetRandomUnusedTcpPort();
  17. int GetRandomUnusedUdpPort();
  18. /// <summary>
  19. /// Returns the MAC Address from first Network Card in Computer.
  20. /// </summary>
  21. /// <returns>The MAC Address.</returns>
  22. List<PhysicalAddress> GetMacAddresses();
  23. /// <summary>
  24. /// Determines whether [is in private address space] [the specified endpoint].
  25. /// </summary>
  26. /// <param name="endpoint">The endpoint.</param>
  27. /// <returns><c>true</c> if [is in private address space] [the specified endpoint]; otherwise, <c>false</c>.</returns>
  28. bool IsInPrivateAddressSpace(string endpoint);
  29. /// <summary>
  30. /// Determines whether [is in local network] [the specified endpoint].
  31. /// </summary>
  32. /// <param name="endpoint">The endpoint.</param>
  33. /// <returns><c>true</c> if [is in local network] [the specified endpoint]; otherwise, <c>false</c>.</returns>
  34. bool IsInLocalNetwork(string endpoint);
  35. IPAddress[] GetLocalIpAddresses();
  36. bool IsAddressInSubnets(string addressString, string[] subnets);
  37. bool IsAddressInSubnets(IPAddress address, bool excludeInterfaces, bool excludeRFC);
  38. bool IsInSameSubnet(IPAddress address1, IPAddress address2, IPAddress subnetMask);
  39. IPAddress GetLocalIpSubnetMask(IPAddress address);
  40. }
  41. }