Changeset 43923 in vbox
- Timestamp:
- Nov 21, 2012 8:47:57 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r43861 r43923 41 41 /* All lwip header files are not C++ safe. So hack around this. */ 42 42 RT_C_DECLS_BEGIN 43 #include <lwip/opt.h> 43 44 #include <lwip/inet.h> 44 45 #include <lwip/tcp.h> 45 46 #include <lwip/sockets.h> 47 # ifdef VBOX_WITH_NEW_LWIP 48 # include <lwip/inet6.h> 49 # endif 46 50 RT_C_DECLS_END 47 51 #endif /* VBOX_WITH_INIP */ … … 616 620 *******************************************************************************/ 617 621 622 /** 623 * vvl: this structure duplicate meaning of sockaddr, 624 * perhaps it'd be better to get rid of it. 625 */ 618 626 typedef union INIPSOCKADDRUNION 619 627 { 620 628 struct sockaddr Addr; 621 629 struct sockaddr_in Ipv4; 630 #ifdef VBOX_WITH_NEW_LWIP 631 struct sockaddr_in6 Ipv6; 632 #endif 622 633 } INIPSOCKADDRUNION; 623 634 … … 666 677 int rc = VINF_SUCCESS; 667 678 PINIPSOCKET pSocketInt = (PINIPSOCKET)Sock; 668 679 int iInetFamily = PF_INET; 680 struct in_addr ip; 681 #ifdef VBOX_WITH_NEW_LWIP 682 ip6_addr_t ip6; 683 #endif 684 669 685 /* Check whether lwIP is set up in this VM instance. */ 670 686 if (!DevINIPConfigured()) … … 675 691 /* Resolve hostname. As there is no standard resolver for lwIP yet, 676 692 * just accept numeric IP addresses for now. */ 677 struct in_addr ip; 678 if (!lwip_inet_aton(pszAddress, &ip)) 693 #ifdef VBOX_WITH_NEW_LWIP 694 if (inet6_aton(pszAddress, &ip6)) 695 iInetFamily = PF_INET6; 696 else /* concatination with if */ 697 #endif 698 if (!lwip_inet_aton(pszAddress, &ip)) 679 699 { 680 700 LogRelFunc(("cannot resolve IP %s\n", pszAddress)); … … 682 702 } 683 703 /* Create socket and connect. */ 684 int iSock = lwip_socket( PF_INET, SOCK_STREAM, 0);704 int iSock = lwip_socket(iInetFamily, SOCK_STREAM, 0); 685 705 if (iSock != -1) 686 706 { 687 struct sockaddr_in InAddr = {0}; 688 InAddr.sin_family = AF_INET; 689 InAddr.sin_port = htons(uPort); 690 InAddr.sin_addr = ip; 691 if (!lwip_connect(iSock, (struct sockaddr *)&InAddr, sizeof(InAddr))) 707 struct sockaddr *pSockAddr = NULL; 708 if (iInetFamily == PF_INET) 709 { 710 struct sockaddr_in InAddr = {0}; 711 InAddr.sin_family = AF_INET; 712 InAddr.sin_port = htons(uPort); 713 InAddr.sin_addr = ip; 714 InAddr.sin_len = sizeof(InAddr); 715 pSockAddr = (struct sockaddr *)&InAddr; 716 } 717 #ifdef VBOX_WITH_NEW_LWIP 718 else 719 { 720 struct sockaddr_in6 In6Addr = {0}; 721 In6Addr.sin6_family = AF_INET6; 722 In6Addr.sin6_port = htons(uPort); 723 memcpy(&In6Addr.sin6_addr, &ip6, sizeof(ip6)); 724 In6Addr.sin6_len = sizeof(In6Addr); 725 pSockAddr = (struct sockaddr *)&In6Addr; 726 } 727 #endif 728 if ( pSockAddr 729 && !lwip_connect(iSock, pSockAddr, pSockAddr->sa_len)) 692 730 { 693 731 pSocketInt->hSock = iSock; … … 883 921 pAddr->uAddr.IPv4.u = u.Ipv4.sin_addr.s_addr; 884 922 } 885 else 923 #ifdef VBOX_WITH_NEW_LWIP 924 else if ( cbAddr == sizeof(struct sockaddr_in6) 925 && u.Addr.sa_family == AF_INET6) 926 { 927 RT_ZERO(*pAddr); 928 pAddr->enmType = RTNETADDRTYPE_IPV6; 929 pAddr->uPort = RT_N2H_U16(u.Ipv6.sin6_port); 930 memcpy(&pAddr->uAddr.IPv6, &u.Ipv6.sin6_addr, sizeof(RTNETADDRIPV6)); 931 } 932 #endif 933 else 886 934 return VERR_NET_ADDRESS_FAMILY_NOT_SUPPORTED; 887 935 return VINF_SUCCESS; … … 910 958 pAddr->uAddr.IPv4.u = u.Ipv4.sin_addr.s_addr; 911 959 } 960 #ifdef VBOX_WITH_NEW_LWIP 961 else if ( cbAddr == sizeof(struct sockaddr_in6) 962 && u.Addr.sa_family == AF_INET6) 963 { 964 RT_ZERO(*pAddr); 965 pAddr->enmType = RTNETADDRTYPE_IPV6; 966 pAddr->uPort = RT_N2H_U16(u.Ipv6.sin6_port); 967 memcpy(&pAddr->uAddr.IPv6, &u.Ipv6.sin6_addr, sizeof(RTNETADDRIPV6)); 968 } 969 #endif 912 970 else 913 971 return VERR_NET_ADDRESS_FAMILY_NOT_SUPPORTED;
Note:
See TracChangeset
for help on using the changeset viewer.