Skip to main content
ConvertIpv4MaskToLength function

The ConvertIpv4MaskToLength function converts an IPv4 subnet mask to an IPv4 prefix length.

Syntax


NETIO_STATUS WINAPI ConvertIpv4MaskToLength(
  _In_   ULONG Mask,
  _Out_  PUINT8 MaskLength
);

Parameters

Mask [in]

The IPv4 subnet mask.

MaskLength [out]

A pointer to a UINT8 value to hold the IPv4 prefix length, in bits, when the function returns successfully.

Return value

On success, ConvertIpv4MaskToLength returns NO_ERROR. Any nonzero return value indicates failure.

Error codeMeaning
ERROR_INVALID_PARAMETER

One of the parameters was invalid. This error is returned if the Mask parameter was invalid.

 

Remarks

The ConvertIpv4MaskToLength function is available on Windows Vista and later.

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Netioapi.h (include Iphlpapi.h)

Library

Iphlpapi.lib

DLL

Iphlpapi.dll

See also

ConvertLengthToIpv4Mask