OS_NS_arpa_inet.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // OS_NS_arpa_inet.cpp,v 1.8 2006/05/16 13:01:02 jwillemsen Exp
00003 
00004 #include "ace/OS_NS_arpa_inet.h"
00005 
00006 ACE_RCSID(ace, OS_NS_arpa_inet, "OS_NS_arpa_inet.cpp,v 1.8 2006/05/16 13:01:02 jwillemsen Exp")
00007 
00008 #if !defined (ACE_HAS_INLINED_OSCALLS)
00009 # include "ace/OS_NS_arpa_inet.inl"
00010 #endif /* ACE_HAS_INLINED_OS_CALLS */
00011 
00012 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00013 
00014 int
00015 ACE_OS::inet_aton (const char *host_name, struct in_addr *addr)
00016 {
00017 #if defined (ACE_LACKS_INET_ATON)
00018 #  if defined (ACE_WIN32)
00019   // Windows Server 2003 changed the behavior of a zero-length input
00020   // string to inet_addr(). It used to return 0 (INADDR_ANY) but now
00021   // returns -1 (INADDR_NONE). It will return INADDR_ANY for a 1-space
00022   // string, though, as do previous versions of Windows.
00023   if (host_name == 0 || host_name[0] == '\0')
00024     host_name = " ";
00025 #  endif /* ACE_WIN32 */
00026   unsigned long ip_addr = ACE_OS::inet_addr (host_name);
00027 
00028   if (ip_addr == INADDR_NONE
00029       // Broadcast addresses are weird...
00030       && ACE_OS::strcmp (host_name, "255.255.255.255") != 0)
00031     return 0;
00032   else if (addr == 0)
00033     return 0;
00034   else
00035     {
00036       addr->s_addr = ip_addr;  // Network byte ordered
00037       return 1;
00038     }
00039 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x620)
00040   // inet_aton() returns OK (0) on success and ERROR (-1) on failure.
00041   // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026
00042   ::errnoSet(0);
00043   int result = ERROR;
00044   ACE_OSCALL (::inet_aton (const_cast <char*>(host_name), addr), int, ERROR, result);
00045   return (result == ERROR) ? 0 : 1;
00046 #else
00047   // inet_aton() returns 0 upon failure, not -1 since -1 is a valid
00048   // address (255.255.255.255).
00049   ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0);
00050 #endif  /* ACE_LACKS_INET_ATON */
00051 }
00052 
00053 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:57 2006 for ACE by doxygen 1.3.6