diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-13 19:27:16 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-11-13 19:27:16 +0000 |
commit | 39906de55a3c6d6074295fd801c8e1e49043102a (patch) | |
tree | 18cd1ba1beacdf460232fc54d87e9955e087bac1 /ace/OS.cpp | |
parent | ef117950f22f55e6365ab49703d3446cf4cae338 (diff) | |
download | ATCD-39906de55a3c6d6074295fd801c8e1e49043102a.tar.gz |
(gethostbyaddr): added VxWorks support
Diffstat (limited to 'ace/OS.cpp')
-rw-r--r-- | ace/OS.cpp | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/ace/OS.cpp b/ace/OS.cpp index 62f29da8857..8433ed75bdb 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -335,11 +335,12 @@ ACE_OS::uname (struct utsname *name) #endif /* ACE_WIN32 || VXWORKS */ +#if defined (VXWORKS) struct hostent * ACE_OS::gethostbyname (const char *name) { // ACE_TRACE ("ACE_OS::gethostbyname"); -#if defined (VXWORKS) + // not thread safe! static hostent ret; static int first_addr; @@ -360,13 +361,43 @@ ACE_OS::gethostbyname (const char *name) ret.h_addr_list = hostaddr; return &ret; -#elif defined (ACE_HAS_NONCONST_GETBY) - ACE_SOCKCALL_RETURN (::gethostbyname ((char *) name), struct hostent *, 0); -#else - ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0); -#endif /* ACE_HAS_NONCONST_GETBY */ } +struct hostent * +ACE_OS::gethostbyaddr (const char *addr, int length, int type) +{ + // ACE_TRACE ("ACE_OS::gethostbyaddr"); + + if (length != 4 || type != AF_INET) + { + errno = EINVAL; + return 0; + } + + // not thread safe! + static hostent ret; + static char name [MAXNAMELEN + 1]; + static char *hostaddr[2]; + + if (::hostGetByAddr (htonl (*(unsigned long int *) addr), name) != 0) + { + // errno will have been set to S_hostLib_UNKNOWN_HOST + return 0; + } + + // might not be official: just echo input arg. + hostaddr[0] = (char *) addr; + hostaddr[1] = 0; + + ret.h_name = name; + ret.h_addrtype = AF_INET; + ret.h_length = 4; // VxWorks 5.2/3 doesn't define IP_ADDR_LEN; + ret.h_addr_list = hostaddr; + + return &ret; +} +#endif /* VXWORKS */ + void ACE_OS::ace_flock_t::dump (void) const { |