ParseNetworkString function
The ParseNetworkString function parses the input network string and checks whether it is a legal representation of the specified IP network string type. If the string matches a type and its specification, the function can optionally return the parsed result.
Syntax
DWORD WINAPI ParseNetworkString(
_In_ const WCHAR *NetworkString,
_In_ DWORD Types,
_Out_opt_ PNET_ADDRESS_INFO AddressInfo,
_Out_opt_ USHORT *PortNumber,
_Out_opt_ BYTE *PrefixLength
);
Parameters
- NetworkString [in]
-
A pointer to the NULL-terminated network string to parse.
- Types [in]
-
The type of IP network string to parse. This parameter consists of one of network string types as defined in the Iphlpapi.h header file.
- AddressInfo [out, optional]
-
On success, the function returns a pointer to a NET_ADDRESS_INFO structure that contains the parsed IP address information if a NULL pointer was not passed in this parameter.
- PortNumber [out, optional]
-
On success, the function returns a pointer to the parsed network port in host order if a NULL pointer was not passed in this parameter. If a network port was not present in the NetworkString parameter, then a pointer to a value of zero is returned.
- PrefixLength [out, optional]
-
On success, the function returns a pointer to the parsed prefix length if a NULL pointer was not passed in this parameter. If a prefix was not present in the NetworkString parameter, then a pointer to a value of -1 is returned.
Return value
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is one of the following error codes.
| Return code | Description |
|---|---|
|
The buffer passed to the function is too small. This error is returned if the buffer pointed to by the AddressInfo parameter is too small to hold the parsed network address. |
|
An invalid parameter was passed to the function. This error is returned if a NULL pointer is passed in the NetworkString parameter |
Remarks
The ParseNetworkString function parses the input network string passed in the NetworkString parameter and checks whether it is a legal representation of one of the string types as specified in the Types argument. If the string matches a type and its specification, the function succeeds and can optionally return the parsed result to the caller in the optional AddressInfo, PortNumber, and PrefixLength parameters when these parameters are not NULL pointers.
The ParseNetworkString function can parse representations of IPv4 or IPv6 addresses, services, and networks, as well as named Internet addresses and services using DNS names.
The SOCKADDR_IN, SOCKADDR_IN6, and SOCKADDR structures are used in the NET_ADDRESS_INFO structure pointed to by the AddressInfo parameter. The SOCKADDR_IN and SOCKADDR structures are defined in the Ws2def.h header file which is automatically included by the Winsock2.h header file. The SOCKADDR_IN6 structure is defined in the Ws2ipdef.h header file which is automatically included by the Ws2tcpip.h header file. In order to use the ParseNetworkString function and the NET_ADDRESS_INFO structure, the Winsock2.h and Ws2tcpip.h header files must be included before the Iphlpapi.h header file.
Requirements
|
Minimum supported client |
Windows Vista [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows Server 2008 [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- NET_ADDRESS_FORMAT
- NET_ADDRESS_INFO
- SOCKADDR
- SOCKADDR_IN
- SOCKADDR_IN6