INetworkManager.cs 1.8 KB

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