2 #include "ace/OS_NS_arpa_inet.h"
4 #if !defined (ACE_HAS_INLINED_OSCALLS)
5 # include "ace/OS_NS_arpa_inet.inl"
6 #endif /* ACE_HAS_INLINED_OSCALLS */
8 #include "ace/Basic_Types.h"
12 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 ACE_OS::inet_aton (const char *host_name
, struct in_addr
*addr
)
17 #if defined (ACE_LACKS_INET_ATON)
18 # if defined (ACE_WIN32)
19 // Windows Server 2003 changed the behavior of a zero-length input
20 // string to inet_addr(). It used to return 0 (INADDR_ANY) but now
21 // returns -1 (INADDR_NONE). It will return INADDR_ANY for a 1-space
22 // string, though, as do previous versions of Windows.
23 if (host_name
== 0 || host_name
[0] == '\0')
25 # endif /* ACE_WIN32 */
27 # if defined (ACE_LACKS_INET_ADDR)
32 for (const char *dot
; *host_name
; host_name
= *dot
? dot
+ 1 : dot
, ++part
)
36 dot
= ACE_OS::strchr (host_name
, '.');
38 dot
= host_name
+ ACE_OS::strlen (host_name
);
40 const unsigned long n
= std::strtoul (host_name
, &last
, 0);
47 # if ACE_SIZEOF_LONG > 4
51 ip
= static_cast<ACE_UINT32
> (n
);
71 addr
->s_addr
= ACE_HTONL (ip
);
74 unsigned long ip_addr
= ACE_OS::inet_addr (host_name
);
76 if (ip_addr
== INADDR_NONE
77 // Broadcast addresses are weird...
78 && ACE_OS::strcmp (host_name
, "255.255.255.255") != 0)
84 addr
->s_addr
= ip_addr
; // Network byte ordered
87 # endif // ACE_LACKS_INET_ADDR
88 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x700)
89 // inet_aton() returns OK (0) on success and ERROR (-1) on failure.
90 // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026
93 ACE_OSCALL (::inet_aton (const_cast <char*>(host_name
), addr
), int, result
);
94 return (result
== ERROR
) ? 0 : 1;
96 // inet_aton() returns 0 upon failure, not -1 since -1 is a valid
97 // address (255.255.255.255).
98 return ::inet_aton (host_name
, addr
);
99 #endif /* ACE_LACKS_INET_ATON */
102 ACE_END_VERSIONED_NAMESPACE_DECL