#ifdef WIN32 # pragma comment(lib, "ws2_32.lib") # include <winsock2.H># include <WS2TCPIP.H> #else #endif #include <stdio.h> /** @code RFC 3493 3.7 Compatibility with IPv4 Nodes The IPv4 address is encoded into the low-order 32 bits of the IPv6 address, and the high-order 96 bits hold the fixed prefix 0:0:0:0:0:FFFF. IPv4-mapped addresses are written as follows: ::FFFF: @endcode */ struct in_addr6 IPv4ToIPv6(struct in_addr IPv4) { struct in_addr6 IPv6; memset(&IPv6, 0x00, sizeof(IPv6)); IPv6.s6_addr[10] = IPv6.s6_addr[11] = 0xFF; memcpy(&IPv6.s6_addr[12], &IPv4.s_addr, sizeof(IPv4)); return IPv6; } int main(int argc, char **argv) { struct in_addr IPv4; struct in_addr6 IPv6; const char *pszIPv4 = "192.168.0.1"; IPv4.s_addr = inet_addr(pszIPv4); IPv6 = IPv4ToIPv6(IPv4); return 0; }http://blog.daum.net/aswip/3206874?srchid=BR1http%3A%2F%2Fblog.daum.net%2Faswip%2F3206874
'컴퓨터 > 프로그램,각종팁' 카테고리의 다른 글
Visual C++ 자주 쓰이는 단축키 모음 (0) | 2009.05.02 |
---|---|
Visual C++ 6.0 단축키 (0) | 2009.05.02 |
ActiveX Control 삭제 프로그램 'CleanAX' (0) | 2009.04.16 |
VMware로 OS설치 중, CD/디스켓(이미지) 변경(교체) 방법 (0) | 2009.04.15 |
VMware server(freeware)와 workstation 차이는? (0) | 2009.04.15 |