summaryrefslogtreecommitdiff
path: root/ACE/ace/Sock_Connect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ace/Sock_Connect.cpp')
-rw-r--r--ACE/ace/Sock_Connect.cpp424
1 files changed, 17 insertions, 407 deletions
diff --git a/ACE/ace/Sock_Connect.cpp b/ACE/ace/Sock_Connect.cpp
index 6f19185c439..37e8ea1a339 100644
--- a/ACE/ace/Sock_Connect.cpp
+++ b/ACE/ace/Sock_Connect.cpp
@@ -7,11 +7,6 @@
#include "ace/OS_Memory.h"
#include "ace/OS_NS_stdio.h"
#include "ace/ACE.h"
-
-#if defined (sparc)
-# include "ace/OS_NS_fcntl.h"
-#endif // sparc
-
#include "ace/OS_NS_stdlib.h"
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_sys_socket.h"
@@ -22,9 +17,6 @@
#if defined (ACE_HAS_IPV6)
# include "ace/Guard_T.h"
# include "ace/Recursive_Thread_Mutex.h"
-# if defined (_AIX)
-# include /**/ <netinet/in6_var.h>
-# endif /* _AIX */
#endif /* ACE_HAS_IPV6 */
#if defined (ACE_HAS_GETIFADDRS)
@@ -38,15 +30,6 @@ const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_IN
const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
#endif /* ACE_VXWORKS <= 0x670 && __RTP__ && ACE_HAS_IPV6 */
-#if defined (ACE_HAS_WINCE)
-#include /**/ <iphlpapi.h>
-# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && (_WIN32_WCE < 0x600) && defined (ACE_HAS_IPV6)
-# include /**/ <ws2tcpip.h>
-const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
-const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
-# endif
-#endif // ACE_HAS_WINCE
-
#if defined (ACE_WIN32) && defined (ACE_HAS_PHARLAP)
# include "ace/OS_NS_stdio.h"
#endif
@@ -58,18 +41,6 @@ const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
# if defined (SIOCGLIFCONF)
# define SIOCGIFCONF_CMD SIOCGLIFCONF
-# if defined (__hpux)
-# define IFREQ if_laddrreq
-# define IFCONF if_laddrconf
-# define IFC_REQ iflc_req
-# define IFC_LEN iflc_len
-# define IFC_BUF iflc_buf
-# define IFR_ADDR iflr_addr
-# define IFR_NAME iflr_name
-# define IFR_FLAGS iflr_flags
-# undef SETFAMILY
-# define SA_FAMILY sa_family
-# else
# define IFREQ lifreq
# define IFCONF lifconf
# define IFC_REQ lifc_req
@@ -82,7 +53,6 @@ const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
# define IFC_FAMILY lifc_family
# define IFC_FLAGS lifc_flags
# define SA_FAMILY ss_family
-# endif
# else
# define SIOCGIFCONF_CMD SIOCGIFCONF
# define IFREQ ifreq
@@ -227,7 +197,7 @@ ACE::get_bcast_addr (ACE_UINT32 &bcast_addr,
sizeof ip_addr.sin_addr);
}
-#if !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (__Lynx__)
+#if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (__Lynx__)
for (int n = ifc.ifc_len / sizeof (struct ifreq) ; n > 0;
n--, ifr++)
#else
@@ -240,7 +210,7 @@ ACE::get_bcast_addr (ACE_UINT32 &bcast_addr,
ifr = (struct ifreq *)
((caddr_t) &ifr->ifr_addr + ifr->ifr_addr.sa_len)) :
(nbytes -= sizeof (struct ifreq), ifr++)))
-#endif /* !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (__Lynx__) */
+#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (__Lynx__) */
{
struct sockaddr_in if_addr;
@@ -468,105 +438,7 @@ static int
get_ip_interfaces_win32 (size_t &count,
ACE_INET_Addr *&addrs)
{
-# if defined (ACE_HAS_WINCE) && defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
- // moved the ACE_HAS_WINCE impl ahaid of ACE_HAS_WINSOCK2 because
- // WINCE in fact has winsock2, but doesn't properly support the
- // WSAIoctl for obtaining IPv6 address info.
- PIP_ADAPTER_ADDRESSES AdapterAddresses = 0;
- ULONG OutBufferLength = 0;
- ULONG RetVal = 0;
- unsigned char *octet_buffer = 0;
-
- RetVal =
- GetAdaptersAddresses(AF_UNSPEC,
- 0,
- 0,
- AdapterAddresses,
- &OutBufferLength);
-
- if (RetVal != ERROR_BUFFER_OVERFLOW)
- {
- return -1;
- }
-
- ACE_NEW_RETURN (octet_buffer, unsigned char[OutBufferLength],-1);
- AdapterAddresses = (IP_ADAPTER_ADDRESSES *)octet_buffer;
-
- RetVal =
- GetAdaptersAddresses(AF_UNSPEC,
- 0,
- 0,
- AdapterAddresses,
- &OutBufferLength);
-
- if (RetVal != NO_ERROR)
- {
- delete [] octet_buffer;
- return -1;
- }
-
- // If successful, output some information from the data we received
- PIP_ADAPTER_ADDRESSES AdapterList = AdapterAddresses;
- while (AdapterList)
- {
- if (AdapterList->OperStatus == IfOperStatusUp)
- {
- if (AdapterList->IfIndex != 0)
- ++count;
- if (AdapterList->Ipv6IfIndex != 0)
- ++count;
- }
- AdapterList = AdapterList->Next;
- }
-
- AdapterList = AdapterAddresses;
-
- ACE_NEW_RETURN (addrs, ACE_INET_Addr[count],-1);
- count = 0;
- for (AdapterList = AdapterAddresses;
- AdapterList != 0;
- AdapterList = AdapterList->Next)
- {
- if (AdapterList->OperStatus != IfOperStatusUp)
- continue;
-
- IP_ADAPTER_UNICAST_ADDRESS *uni = 0;
- if (AdapterList->IfIndex != 0)
- for (uni = AdapterList->FirstUnicastAddress;
- uni != 0;
- uni = uni->Next)
- {
- SOCKET_ADDRESS *sa_addr = &uni->Address;
- if (sa_addr->lpSockaddr->sa_family == AF_INET)
- {
- sockaddr_in *sin = (sockaddr_in*)sa_addr->lpSockaddr;
- addrs[count].set(sin,sa_addr->iSockaddrLength);
- ++count;
- break;
- }
- }
- if (AdapterList->Ipv6IfIndex != 0)
- {
- for (uni = AdapterList->FirstUnicastAddress;
- uni != 0;
- uni = uni->Next)
- {
- SOCKET_ADDRESS *sa_addr = &uni->Address;
- if (sa_addr->lpSockaddr->sa_family == AF_INET6)
- {
- sockaddr_in *sin = (sockaddr_in*)sa_addr->lpSockaddr;
- addrs[count].set(sin,sa_addr->iSockaddrLength);
- ++count;
- break;
- }
- }
- }
- }
-
- delete [] octet_buffer;
- return 0;
-
-# elif defined (ACE_HAS_PHARLAP)
+# if defined (ACE_HAS_PHARLAP)
// PharLap ETS has its own kernel routines to rummage through the device
// configs and extract the interface info, but only for Pharlap RT.
# if !defined (ACE_HAS_PHARLAP_RT)
@@ -766,7 +638,7 @@ get_ip_interfaces_win32 (size_t &count,
return 0;
-# endif /* ACE_HAS_WINCE */
+# endif /* ACE_HAS_PHARLAP */
}
#elif defined (ACE_HAS_GETIFADDRS)
@@ -845,258 +717,7 @@ get_ip_interfaces_getifaddrs (size_t &count,
return 0;
}
-#elif defined (__hpux)
-static int
-get_ip_interfaces_hpux (size_t &count,
- ACE_INET_Addr *&addrs)
-{
- size_t num_ifs = 0;
- size_t num_ifs_found = 0;
-
- // Call specific routine as necessary.
- ACE_HANDLE handle = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
- ACE_HANDLE handle_ipv6 = ACE_INVALID_HANDLE;
-
- if (handle == ACE_INVALID_HANDLE)
- ACELIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("ACE::get_ip_interfaces:open")),
- -1);
-
- int result = 0;
- int tmp_how_many = 0;
-
- result = ACE_OS::ioctl (handle,
- SIOCGIFNUM,
- (caddr_t) &tmp_how_many);
- if (result != -1)
- num_ifs = (size_t)tmp_how_many;
-
-# if defined (ACE_HAS_IPV6)
- tmp_how_many = 0;
- handle_ipv6 = ACE_OS::socket (PF_INET6, SOCK_DGRAM, 0);
- result = ACE_OS::ioctl (handle_ipv6,
- SIOCGLIFNUM,
- (caddr_t) &tmp_how_many);
- if (result != -1)
- num_ifs += (size_t)tmp_how_many;
-# endif
-
- if (num_ifs == 0)
- {
- ACE_OS::close (handle);
- ACE_OS::close (handle_ipv6);
- return -1;
- }
-
- // ioctl likes to have an extra IFREQ structure to mark the end of
- // what it returned, so increase the num_ifs by one.
- ++num_ifs;
-
- //HPUX requires two passes, First for IPv4, then for IPv6
-
- struct ifreq *ifs = 0;
- ACE_NEW_RETURN (ifs,
- struct ifreq[num_ifs],
- -1);
- ACE_OS::memset (ifs, 0, num_ifs * sizeof (struct ifreq));
-
- ACE_Auto_Array_Ptr<struct ifreq> p_ifs (ifs);
-
- if (p_ifs.get() == 0)
- {
- ACE_OS::close (handle);
- ACE_OS::close (handle_ipv6);
- errno = ENOMEM;
- return -1;
- }
-
- struct ifconf ifcfg;
- ACE_OS::memset (&ifcfg, 0, sizeof (struct ifconf));
-
- ifcfg.ifc_req = p_ifs.get ();
- ifcfg.ifc_len = num_ifs * sizeof (struct ifreq);
-
- if (ACE_OS::ioctl (handle,
- SIOCGIFCONF,
- (char *) &ifcfg) == -1)
- {
- ACE_OS::close (handle);
- ACELIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("ACE::get_ip_interfaces:")
- ACE_TEXT ("ioctl - SIOCGIFCONF failed")),
- -1);
- }
-
- ACE_OS::close (handle);
-
- // Now create and initialize output array.
-
- ACE_NEW_RETURN (addrs,
- ACE_INET_Addr[num_ifs],
- -1); // caller must free
-
- struct ifreq *pcur = p_ifs.get ();
- num_ifs_found = ifcfg.ifc_len / sizeof (struct ifreq); // get the number of returned ifs
-
- for (size_t i = 0;
- i < num_ifs_found;
- i++)
- {
- struct sockaddr_in *addr =
- reinterpret_cast<sockaddr_in *> (&pcur->ifr_addr);
- if (addr->sin_addr.s_addr != 0)
- {
- addrs[count].set ((u_short) 0,
- addr->sin_addr.s_addr,
- 0);
- ++count;
- }
- ++pcur;
- }
-
-# if defined (ACE_HAS_IPV6)
-
- if (handle_ipv6 != ACE_INVALID_HANDLE)
- {
- struct if_laddrreq *lifs = 0;
- ACE_NEW_RETURN (lifs,
- struct if_laddrreq[num_ifs],
- -1);
- ACE_OS::memset (lifs, 0, num_ifs * sizeof (struct if_laddrreq));
-
- ACE_Auto_Array_Ptr<struct if_laddrreq> p_lifs (lifs);
-
- if (p_lifs.get() == 0)
- {
- ACE_OS::close (handle);
- ACE_OS::close (handle_ipv6);
- errno = ENOMEM;
- return -1;
- }
-
- struct if_laddrconf lifcfg;
- ACE_OS::memset (&lifcfg, 0, sizeof (struct if_laddrconf));
-
- lifcfg.iflc_req = p_lifs.get ();
- lifcfg.iflc_len = num_ifs * sizeof (struct if_laddrreq);
-
- if (ACE_OS::ioctl (handle_ipv6,
- SIOCGLIFCONF,
- (char *) &lifcfg) == -1)
- {
- ACE_OS::close (handle);
- ACELIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("ACE::get_ip_interfaces:")
- ACE_TEXT ("ioctl - SIOCGLIFCONF failed")),
- -1);
- }
-
- ACE_OS::close (handle_ipv6);
-
- struct if_laddrreq *plcur = p_lifs.get ();
- num_ifs_found = lifcfg.iflc_len / sizeof (struct if_laddrreq);
-
- for (size_t i = 0;
- i < num_ifs_found;
- i++)
- {
- struct sockaddr_in *addr =
- reinterpret_cast<sockaddr_in *> (&plcur->iflr_addr);
- if (!IN6_IS_ADDR_UNSPECIFIED(&reinterpret_cast<sockaddr_in6 *>(addr)->sin6_addr))
- {
- addrs[count].set(addr, sizeof(struct sockaddr_in6));
- ++count;
- }
- ++plcur;
- }
- }
-# endif /* ACE_HAS_IPV6 */
- return 0;
-}
-#elif defined (_AIX)
-static int
-get_ip_interfaces_aix (size_t &count,
- ACE_INET_Addr *&addrs)
-{
- ACE_HANDLE handle = ACE::get_handle();
- size_t num_ifs = 0;
- struct ifconf ifc;
-
- if (handle == ACE_INVALID_HANDLE)
- ACELIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("ACE::get_ip_interfaces_aix:")),
- -1);
-
- if (ACE_OS::ioctl (handle,
- SIOCGSIZIFCONF,
- (caddr_t)&ifc.ifc_len) == -1)
- {
- ACE_OS::close (handle);
- ACELIB_ERROR_RETURN((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("get ifconf size")),
- -1);
- }
-
- ACE_NEW_RETURN (ifc.ifc_buf,char [ifc.ifc_len], -1);
-
- ACE_Auto_Array_Ptr<char> safe_buf (ifc.ifc_buf);
- ACE_OS::memset (safe_buf.get(), 0, ifc.ifc_len);
-
- if (ACE_OS::ioctl(handle, SIOCGIFCONF, (caddr_t)&ifc) == -1)
- {
- ACE_OS::close (handle);
- ACELIB_ERROR_RETURN((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("get ifconf")),
- -1);
- }
-
- ACE_OS::close (handle);
-
- char *buf_start = safe_buf.get();
- char *buf_end = buf_start + ifc.ifc_len;
-
- num_ifs = 0;
- for (char *ptr = buf_start; ptr < buf_end; )
- {
- struct ifreq *req = reinterpret_cast<struct ifreq *>(ptr);
- ptr += IFNAMSIZ;
- ptr += req->ifr_addr.sa_len;
- if (req->ifr_addr.sa_family == AF_INET
-# if defined (ACE_HAS_IPV6)
- || req->ifr_addr.sa_family == AF_INET6
-# endif
- )
- ++num_ifs;
- }
- ACE_NEW_RETURN (addrs,ACE_INET_Addr[num_ifs], -1);
-
- for (char * ptr = buf_start; ptr < buf_end; )
- {
- struct ifreq *req = reinterpret_cast<struct ifreq *>(ptr);
- // skip the interface name
- ptr += IFNAMSIZ;
- if (req->ifr_addr.sa_family == AF_INET
-# if defined (ACE_HAS_IPV6)
- || req->ifr_addr.sa_family == AF_INET6
-# endif
- )
- {
- sockaddr_in *addr = (sockaddr_in*)&req->ifr_addr;
- addrs[count++].set(addr, addr->sin_len);
- }
- ptr += req->ifr_addr.sa_len;
- }
-
- return 0;
-}
-
-#endif // ACE_WIN32 || ACE_HAS_GETIFADDRS || __hpux || _AIX
+#endif // ACE_WIN32 || ACE_HAS_GETIFADDRS
// return an array of all configured IP interfaces on this host, count
@@ -1115,11 +736,7 @@ ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs)
return get_ip_interfaces_win32 (count, addrs);
#elif defined (ACE_HAS_GETIFADDRS)
return get_ip_interfaces_getifaddrs (count, addrs);
-#elif defined (__hpux)
- return get_ip_interfaces_hpux (count, addrs);
-#elif defined (_AIX)
- return get_ip_interfaces_aix (count, addrs);
-#elif (defined (__unix) || defined (__unix__) || defined (ACE_OPENVMS) || (defined (ACE_VXWORKS) && !defined (ACE_HAS_GETIFADDRS)) || defined (ACE_HAS_RTEMS)) && !defined (ACE_LACKS_NETWORKING)
+#elif (defined (__unix) || defined (__unix__) || (defined (ACE_VXWORKS) && !defined (ACE_HAS_GETIFADDRS))) && !defined (ACE_LACKS_NETWORKING)
// COMMON (SVR4 and BSD) UNIX CODE
// Call specific routine as necessary.
@@ -1231,7 +848,7 @@ ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs)
}
}
-#if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__)
+#if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (__Lynx__)
++pcur;
#else
if (pcur->ifr_addr.sa_len <= sizeof (struct sockaddr))
@@ -1243,7 +860,7 @@ ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs)
pcur = (struct ifreq *)
(pcur->ifr_addr.sa_len + (caddr_t) &pcur->ifr_addr);
}
-#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__) */
+#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (__Lynx__) */
}
# if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_FSCANF)
@@ -1309,7 +926,7 @@ int
ACE::count_interfaces (ACE_HANDLE handle, size_t &how_many)
{
#if defined (SIOCGIFNUM)
-# if defined (SIOCGLIFNUM) && !defined (ACE_LACKS_STRUCT_LIFNUM)
+# if defined (SIOCGLIFNUM)
int cmd = SIOCGLIFNUM;
struct lifnum if_num = {AF_UNSPEC,0,0};
# else
@@ -1322,16 +939,16 @@ ACE::count_interfaces (ACE_HANDLE handle, size_t &how_many)
ACE_TEXT ("ACE::count_interfaces:")
ACE_TEXT ("ioctl - SIOCGLIFNUM failed")),
-1);
-# if defined (SIOCGLIFNUM) && !defined (ACE_LACKS_STRUCT_LIFNUM)
+# if defined (SIOCGLIFNUM)
how_many = if_num.lifn_count;
# else
how_many = if_num;
# endif /* SIOCGLIFNUM */
return 0;
-#elif (defined (__unix) || defined (__unix__) || defined (ACE_OPENVMS) || defined (ACE_HAS_RTEMS) || (defined (ACE_VXWORKS) && !defined (ACE_HAS_GETIFADDRS))) && !defined (ACE_LACKS_NETWORKING)
+#elif (defined (__unix) || defined (__unix__) || (defined (ACE_VXWORKS) && !defined (ACE_HAS_GETIFADDRS))) && !defined (ACE_LACKS_NETWORKING)
// Note: DEC CXX doesn't define "unix". BSD compatible OS: HP UX,
- // AIX, SunOS 4.x perform some ioctls to retrieve ifconf list of
+ // SunOS 4.x perform some ioctls to retrieve ifconf list of
// ifreq structs no SIOCGIFNUM on SunOS 4.x, so use guess and scan
// algorithm
@@ -1395,7 +1012,7 @@ return 0;
break;
++if_count;
-# if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__)
+# if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (__Lynx__)
++p_ifs;
# else
if (p_ifs->ifr_addr.sa_len <= sizeof (struct sockaddr))
@@ -1407,7 +1024,7 @@ return 0;
p_ifs = (struct ifreq *)
(p_ifs->ifr_addr.sa_len + (caddr_t) &p_ifs->ifr_addr);
}
-# endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__) */
+# endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (__Lynx__) */
}
#if defined (ACE_HAS_ALLOC_HOOKS)
@@ -1440,24 +1057,17 @@ return 0;
}
// Routine to return a handle from which ioctl() requests can be made.
-
ACE_HANDLE
ACE::get_handle ()
{
- // Solaris 2.x
ACE_HANDLE handle = ACE_INVALID_HANDLE;
-#if defined (sparc)
- handle = ACE_OS::open ("/dev/udp", O_RDONLY);
-#elif defined (__unix) || defined (__unix__) || defined (_AIX) || defined (__hpux) || (defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600)) || defined (ACE_OPENVMS) || defined (ACE_HAS_RTEMS)
- // Note: DEC CXX doesn't define "unix" BSD compatible OS: HP UX,
- // AIX, SunOS 4.x
-
+#if defined (__unix) || defined (__unix__) || (defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600))
+ // Note: DEC CXX doesn't define "unix" BSD compatible OS: SunOS 4.x
handle = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
-#endif /* sparc */
+#endif /* __unux */
return handle;
}
-
#if defined (ACE_HAS_IPV6)
static int
ip_check (int &ipvn_enabled, int pf)