ConvertLengthToIpv4Mask function

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

Syntax

IPHLPAPI_DLL_LINKAGE NETIOAPI_API ConvertLengthToIpv4Mask(
  ULONG  MaskLength,
  PULONG Mask
);

Parameters

MaskLength

The IPv4 prefix length, in bits.

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 Vistaand later.

Requirements

   
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