RuntimeHelperCheckSubnetMask - метод

Validates if the provided IP address matches the given subnet mask.

Definition

Пространство имён: Tessa.Platform.Runtime
Сборка: Tessa (в Tessa.dll) Версия: 4.1.3+7e2b1422f9b8c7c41fbbc4b151a843bed05319ab
C#
public static bool CheckSubnetMask(
	string? subnetMask,
	string? ipAddress,
	bool mapToIPv4 = true
)

Параметры

subnetMask  String
The subnet mask with prefix length (e.g., 255.255.255.0/24 or 2001:0db8::/32).
ipAddress  String
The IP address to be validated, in string format. It can be either IPv4 or IPv6 address.
mapToIPv4  Boolean  (Optional)
Takes the last 4 bytes of an IPv6 address and converts it to an IPv4 address. This does not restrict to address with the ::FFFF: prefix because other types of addresses display the tail segments as IPv4 like Terado.

Возвращаемое значение

Boolean
Returns if the IP address matches the subnet mask, otherwise.

Заметки

The subnet mask must include a prefix length (e.g., 255.255.255.0/24 or 2001:0db8::/32). The method supports both IPv4 and IPv6 address families.

Исключения

ArgumentException Thrown when the subnet mask is invalid (e.g., prefix length is negative).
ArgumentOutOfRangeException Thrown if the subnet mask length is not within the acceptable range for the address family (e.g., a prefix length that exceeds the maximum allowed length for IPv4 or IPv6).
FormatException Thrown when the subnet mask has invalid format (e.g., missing prefix length).
InvalidOperationException Thrown when there is a mismatch between the address family of the IP address and subnet mask (e.g., mixing IPv4 and IPv6 addresses if mapToIPv4 is ).

См. также