Changeset 26588 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Feb 16, 2010 5:02:59 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/tcp.cpp
r26252 r26588 910 910 911 911 912 RTR3DECL(int) RTTcpGetPeerAddress(RTSOCKET Sock, PRTNETADDR pAddr) 913 { 914 union 915 { 916 struct sockaddr Addr; 917 struct sockaddr_in Ipv4; 918 struct sockaddr_in6 Ipv6; 919 } u; 920 #ifdef RT_OS_WINDOWS 921 int cbAddr = sizeof(u); 922 #else 923 socklen_t cbAddr = sizeof(u); 924 #endif 925 RT_ZERO(u); 926 if (!getpeername(Sock, &u.Addr, &cbAddr)) 927 { 928 /* 929 * Convert the address. 930 */ 931 if ( cbAddr == sizeof(struct sockaddr_in) 932 && u.Addr.sa_family == AF_INET) 933 { 934 RT_ZERO(*pAddr); 935 pAddr->enmType = RTNETADDRTYPE_IPV4; 936 pAddr->uPort = u.Ipv4.sin_port; 937 pAddr->uAddr.IPv4.u = u.Ipv4.sin_addr.s_addr; 938 } 939 #ifdef AF_INET6 940 else if ( cbAddr == sizeof(struct sockaddr_in6) 941 && u.Addr.sa_family == AF_INET6) 942 { 943 RT_ZERO(*pAddr); 944 pAddr->enmType = RTNETADDRTYPE_IPV6; 945 pAddr->uPort = u.Ipv6.sin6_port; 946 pAddr->uAddr.IPv6.au32[0] = u.Ipv6.sin6_addr.s6_addr32[0]; 947 pAddr->uAddr.IPv6.au32[1] = u.Ipv6.sin6_addr.s6_addr32[1]; 948 pAddr->uAddr.IPv6.au32[2] = u.Ipv6.sin6_addr.s6_addr32[2]; 949 pAddr->uAddr.IPv6.au32[3] = u.Ipv6.sin6_addr.s6_addr32[3]; 950 } 951 #endif 952 else 953 return VERR_NET_ADDRESS_FAMILY_NOT_SUPPORTED; 954 return VINF_SUCCESS; 955 } 956 return rtTcpError(); 957 } 958 959 912 960 RTR3DECL(int) RTTcpClientConnect(const char *pszAddress, uint32_t uPort, PRTSOCKET pSock) 913 961 {
Note:
See TracChangeset
for help on using the changeset viewer.