INetworkManager.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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(bool ignoreVirtualInterface);
  36. bool IsAddressInSubnets(string addressString, string[] subnets);
  37. bool IsInSameSubnet(IPAddress address1, IPAddress address2, IPAddress subnetMask);
  38. IPAddress GetLocalIpSubnetMask(IPAddress address);
  39. }
  40. }