ConvertLengthToIpv4Mask function (netioapi.h)

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

Syntax

IPHLPAPI_DLL_LINKAGE NETIOAPI_API ConvertLengthToIpv4Mask(
  [in]  ULONG  MaskLength,
  [out] PULONG Mask
);

Parameters

[in] MaskLength

The IPv4 prefix length, in bits.

[out] Mask

A pointer to a LONG value to hold the IPv4 subnet mask when the function returns successfully.

Return value

On success, ConvertLengthToIpv4Mask returns NO_ERROR. Any nonzero return value indicates failure and the Mask parameter is set to INADDR_NONE defined in the Ws2def.h header file.

Error code Meaning
ERROR_INVALID_PARAMETER
One of the parameters was invalid. This error is returned if the MaskLength parameter was invalid.

Remarks

The ConvertLengthToIpv4Mask function is available on Windows Vista and later.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header netioapi.h (include Iphlpapi.h)
Library Iphlpapi.lib
DLL Iphlpapi.dll

See also

ConvertIpv4MaskToLength