2 #include "ace/OS_NS_string.h"
3 #include "ace/OS_NS_errno.h"
4 #include "ace/OS_NS_stdio.h"
6 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
8 ACE_INLINE unsigned long
9 ACE_OS::inet_addr (const char *name)
11 ACE_OS_TRACE ("ACE_OS::inet_addr");
12 #if defined (ACE_LACKS_INET_ADDR)
13 ACE_UNUSED_ARG (name);
14 ACE_NOTSUP_RETURN (0);
15 #elif defined (ACE_HAS_NONCONST_INET_ADDR)
16 return ::inet_addr (const_cast <char*> (name));
18 return ::inet_addr (name);
19 #endif /* ACE_HAS_NONCONST_INET_ADDR */
23 ACE_OS::inet_ntoa (const struct in_addr addr)
25 ACE_OS_TRACE ("ACE_OS::inet_ntoa");
26 #if defined (ACE_LACKS_INET_NTOA)
27 ACE_UNUSED_ARG (addr);
28 ACE_NOTSUP_RETURN (0);
30 return ::inet_ntoa (addr);
34 ACE_INLINE const char *
35 ACE_OS::inet_ntop (int family, const void *addrptr, char *strptr, size_t len)
37 ACE_OS_TRACE ("ACE_OS::inet_ntop");
39 #if defined ACE_HAS_IPV6 && !defined ACE_LACKS_INET_NTOP
40 # if defined (ACE_HAS_NONCONST_INET_NTOP)
41 return ::inet_ntop (family, const_cast<void *> (addrptr), strptr, len);
43 return ::inet_ntop (family, addrptr, strptr, len);
47 if (family == AF_INET)
49 const u_char *const p = reinterpret_cast<const u_char *> (addrptr);
50 if (ACE_OS::snprintf (strptr, len, "%d.%d.%d.%d", p[0], p[1], p[2], p[3])
51 > static_cast<int> (len))
65 ACE_OS::inet_pton (int family, const char *strptr, void *addrptr)
67 ACE_OS_TRACE ("ACE_OS::inet_pton");
69 #if defined ACE_HAS_IPV6 && !defined ACE_LACKS_INET_PTON
70 return ::inet_pton (family, strptr, addrptr);
72 if (family == AF_INET)
74 if (ACE_OS::inet_aton (strptr, static_cast<in_addr *> (addrptr)))
77 return 0; // Input is not a valid presentation format
85 ACE_END_VERSIONED_NAMESPACE_DECL