- AFINET.; 2 minutes to read; In this article. The AFINET address family is the address family for IPv4. Socket Address Structure. An IPv4 transport address is specified with the SOCKADDRIN structure. Socket Types. IPv4 supports the following socket types: SOCKSTREAM Supports reliable connection-oriented byte stream communication.
- On macOS you can use IPPROTOIP and you will receive all IP packets but on Linux this may not work, hence the created a new socket PFPACKET socket type. What should work on both systems is specifying a sub-protocol: int soc = socket(PFINET, SOCKRAW, IPPROTOUDP); Of course, now you can only send/receive UDP packets over that socket.
2020-05-21 01:41 TLS: Initial packet from AFINET172.83.43.131:1194, sid=45959a3e b58f9ea4 2020-05-21 01:47 WARNING: this configuration may cache passwords in memory - use the auth-nocache option to prevent this. Jan 10, 2019 2019-01-10 15:21:04 TLS: Initial packet from AFINET 185.18.205.78:143, sid=2f89a7d4 a69e02bd 2019-01-10 15:21:04 WARNING: this configuration may cache passwords in memory - use the auth-nocache option to prevent this.
-->TheInetNtop function converts an IPv4 or IPv6 Internet network address into a string in Internet standard format. The ANSI version of this function is inet_ntop.
Syntax
Parameters
Family
The address family.
Possible values for the address family are defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically included in Winsock2.h, and should never be used directly. Note that the values for the AF_ address family and PF_ protocol family constants are identical (for example, AF_INET and PF_INET), so either constant can be used.
The values currently supported are AF_INET and AF_INET6.
Value | Meaning |
---|---|
| The Internet Protocol version 4 (IPv4) address family. When this parameter is specified, this function returns an IPv4 address string. |
| The Internet Protocol version 6 (IPv6) address family. When this parameter is specified, this function returns an IPv6 address string. |
pAddr
A pointer to the IP address in network byte to convert to a string.
When the Family parameter is AF_INET, then the pAddr parameter must point to an IN_ADDR structure with the IPv4 address to convert.
When the Family parameter is AF_INET6, then the pAddr parameter must point to an IN6_ADDR structure with the IPv6 address to convert.
pStringBuf
A pointer to a buffer in which to store the NULL-terminated string representation of the IP address.
For an IPv4 address, this buffer should be large enough to hold at least 16 characters.
For an IPv6 address, this buffer should be large enough to hold at least 46 characters.
StringBufSize
On input, the length, in characters, of the buffer pointed to by the pStringBuf parameter.
Return value
If no error occurs,InetNtop function returns a pointer to a buffer containing the string representation of IP address in standard format.
Otherwise, a value of NULL is returned, and a specific error code can be retrieved by calling the
WSAGetLastError for extended error information.
WSAGetLastError for extended error information.
If the function fails, the extended error code returned by WSAGetLastError can be one of the following values.
Error code | Meaning |
---|---|
| The address family specified in the Family parameter is not supported. This error is returned if the Family parameter specified was not AF_INET or AF_INET6. |
| An invalid parameter was passed to the function. This error is returned if a NULL pointer is passed in the pStringBuf or the StringBufSize parameter is zero. This error is also returned if the length of the buffer pointed to by the pStringBuf parameter is not large enough to receive the string representation of the IP address. |
Remarks
TheInetNtop function is supported on Windows Vista and later.
TheInetNtop function provides a protocol-independent address-to-string translation. TheInetNtop function takes an Internet address structure specified by the pAddr parameter and returns a NULL-terminated string that represents the IP address. While the inet_ntoa function works only with IPv4 addresses, the InetNtop function works with either IPv4 or IPv6 addresses.
The ANSI version of this function is inet_ntop as defined in RFC 2553. For more information, see RFC 2553 available at the IETF website.
TheInetNtop function does not require that the Windows Sockets DLL be loaded to perform IP address to string conversion.
If the Family parameter specified is AF_INET, then the pAddr parameter must point to an IN_ADDR structure with the IPv4 address to convert. The address string returned in the buffer pointed to by the pStringBuf parameter is in dotted-decimal notation as in '192.168.16.0', an example of an IPv4 address in dotted-decimal notation.
If the Family parameter specified is AF_INET6, then the pAddr parameter must point to an IN6_ADDR structure with the IPv6 address to convert. The address string returned in the buffer pointed to by the pStringBuf parameter is in Internet standard format. The basic string representation consists of 8 hexadecimal numbers separated by colons. A string of consecutive zero numbers is replaced with a double-colon. There can only be one double-colon in the string representation of the IPv6 address. The last 32 bits are represented in IPv4-style dotted-octet notation if the address is a IPv4-compatible address.
If the length of the buffer pointed to by the pStringBuf parameter is not large enough to receive the string representation of the IP address, InetNtop returns ERROR_INVALID_PARAMETER.
When UNICODE or _UNICODE is defined, InetNtop is defined to InetNtopW, the Unicode version of this function. The pStringBuf parameter is defined to the PSTR data type.
When UNICODE or _UNICODE is not defined, InetNtop is defined to InetNtopA, the ANSI version of this function. The ANSI version of this function is always defined as inet_ntop. The pStringBuf parameter is defined to the PWSTR data type.
The IN_ADDR structure is defined in the Inaddr.h header file.
The IN6_ADDR structure is defined in the In6addr.h header file.
On Windows Vista and later, the RtlIpv4AddressToString and RtlIpv4AddressToStringEx functions can be used to convert an IPv4 address represented as an IN_ADDR structure to a string representation of an IPv4 address in Internet standard dotted-decimal notation. On Windows Vista and later, the RtlIpv6AddressToString and RtlIpv6AddressToStringEx functions can be used to convert an IPv6 address represented as an IN6_ADDR structure to a string representation of an IPv6 address. The RtlIpv6AddressToStringEx function is more flexible since it also converts an IPv6 address, scope ID, and port to a IPv6 string in standard format.
Windows 8.1 and Windows Server 2012 R2: The InetNtopW function is supported for Windows Store apps on Windows 8.1, Windows Server 2012 R2, and later.
Requirements
Minimum supported client | Windows 8.1, Windows Vista [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | ws2tcpip.h |
Library | Ws2_32.lib |
DLL | Ws2_32.dll |
See also
-->The AF_INET address family is the address family for IPv4.
Socket Address Structure
An IPv4 transport address is specified with the SOCKADDR_IN structure.
Socket Types
IPv4 supports the following socket types:
SOCK_STREAM
Supports reliable connection-oriented byte stream communication.
Supports reliable connection-oriented byte stream communication.
SOCK_DGRAM
Supports unreliable connectionless datagram communication.
Supports unreliable connectionless datagram communication.
SOCK_RAW
Supports raw access to the transport protocol.
Supports raw access to the transport protocol.
A WSK application specifies a socket type when it calls the WskSocket function or the WskSocketConnect function to create a new socket.
Protocols
The following IPv4 IPPROTO_XXX protocol values of the IPPROTO enumeration are defined in the WSK header files:
IPPROTO_IP
Internet protocol options
Internet protocol options
IPPROTO_ICMP
Internet control message protocol
Internet control message protocol
IPPROTO_IGMP
Internet group management protocol
Internet group management protocol
IPPROTO_GGP
Gateway to gateway protocol
Gateway to gateway protocol
IPPROTO_IPV4
IPv4 encapsulation
IPv4 encapsulation
IPPROTO_ST
Stream protocol
Stream protocol
IPPROTO_TCP
Transmission control protocol
Transmission control protocol
IPPROTO_CBT
Core based trees protocol
Core based trees protocol
IPPROTO_EGP
Exterior gateway protocol
Exterior gateway protocol
IPPROTO_IGP
Private interior gateway protocol
Private interior gateway protocol
IPPROTO_PUP
PARC universal packet protocol
PARC universal packet protocol
IPPROTO_UDP
User datagram protocol
User datagram protocol
IPPROTO_IDP
Internet datagram protocol
Internet datagram protocol
IPPROTO_RDP
Reliable data protocol
Reliable data protocol
IPPROTO_ND
Net disk protocol
Net disk protocol
IPPROTO_ICLFXBM
Wideband monitoring
Wideband monitoring
IPPROTO_PIM
Protocol independent multicast
Protocol independent multicast
IPPROTO_PGM
Pragmatic general multicast
Pragmatic general multicast
IPPROTO_L2TP
Level 2 tunneling protocol
Level 2 tunneling protocol
IPPROTO_SCTP
Stream control transmission protocol
Stream control transmission protocol
IPPROTO_RAW
Raw IP packets
Raw IP packets
Additional protocols are supported through the use of raw sockets.
A WSK application specifies a protocol when it calls the WskSocket function or the WskSocketConnect function to create a new socket.
Af_inet For Macos 7
A WSK application also specifies a protocol (as the Level parameter) when it calls the WskControlSocket function to set or retrieve transport protocol level or network protocol level socket options.
Combinations
IPv4 supports the following combinations of socket types and protocols for each WSK socket category:
Af_inet For Macos X
Basic SocketsSOCK_STREAM + IPPROTO_TCPSOCK_DGRAM + IPPROTO_UDPSOCK_RAW + IPPROTO_XxxListening SocketsSOCK_STREAM + IPPROTO_TCP
Af_inet For Macos X
Datagram SocketsSOCK_DGRAM + IPPROTO_UDPSOCK_RAW + IPPROTO_XxxConnection-Oriented SocketsSOCK_STREAM + IPPROTO_TCP
Requirements
Af_inet For Macos Download
Version | Available in Windows Vista and later versions of the Windows operating systems. |
Header | Ws2def.h (include Wsk.h) |