summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2002-01-07 23:17:28 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2002-01-07 23:17:28 +0000
commit1998f47f0aacd377371a6bd759ebd0d570a6aa1b (patch)
tree7b4762f9a5e6c6fea7ff8ac09258d4af095a8504
parent53be6b41abb0891005ca93ae0c0cd433b4cfdee2 (diff)
downloadATCD-1998f47f0aacd377371a6bd759ebd0d570a6aa1b.tar.gz
ChangeLogTag:Mon Jan 7 15:16:10 2002 Ossama Othman <ossama@uci.edu>
-rw-r--r--ChangeLog37
-rw-r--r--ChangeLogs/ChangeLog-02a37
-rw-r--r--ChangeLogs/ChangeLog-03a37
-rw-r--r--ace/OS.cpp20
-rw-r--r--ace/OS.h9
-rw-r--r--ace/OS.i4
-rw-r--r--ace/README2
-rw-r--r--ace/config-win32-common.h1
8 files changed, 133 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 64be6087271..56e0b737e2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+Mon Jan 7 15:16:10 2002 Ossama Othman <ossama@uci.edu>
+
+ * ace/OS.h (INADDR_NONE):
+
+ If the platform does not define this constant, then define it.
+
+ * ace/OS.cpp (inet_aton):
+
+ For some reason we were emulating inet_aton() on all platforms
+ using the now deprecated inet_addr() function. Use the native
+ inet_aton() function unless ACE_LACKS_INET_ATON is defined.
+
+ Instead of performing a memcpy() of the IPv4 32-bit address into
+ the in_addr data structure, simply assign it to the s_addr field
+ of that data structure. It's not clear why we didn't do this in
+ the first place.
+
+ (inet_ntoa):
+
+ Fixed PSoS emulation of this method. The result is supposed to
+ be stored in a statically allocated string, not a dynamically
+ allocated one. Fixes a memory leak. Note that this change
+ makes the implementation non-reentrant. However, inet_ntoa()
+ was not designed to be reentrant to begin with.
+
+ * ace/OS.i (inet_addr):
+
+ On error, inet_addr() is supposed to return INADDR_NONE.
+
+ The return value should be a 32 bit unsigned integer, not a
+ signed one.
+
+ * ace/config-win32-common.h:
+
+ MS Windows does not support the inet_aton() function. Define
+ ACE_LACKS_INET_ATON.
+
Mon Jan 7 12:20:26 2002 Ossama Othman <ossama@uci.edu>
* bin/auto_run_tests.lst:
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 64be6087271..56e0b737e2f 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,40 @@
+Mon Jan 7 15:16:10 2002 Ossama Othman <ossama@uci.edu>
+
+ * ace/OS.h (INADDR_NONE):
+
+ If the platform does not define this constant, then define it.
+
+ * ace/OS.cpp (inet_aton):
+
+ For some reason we were emulating inet_aton() on all platforms
+ using the now deprecated inet_addr() function. Use the native
+ inet_aton() function unless ACE_LACKS_INET_ATON is defined.
+
+ Instead of performing a memcpy() of the IPv4 32-bit address into
+ the in_addr data structure, simply assign it to the s_addr field
+ of that data structure. It's not clear why we didn't do this in
+ the first place.
+
+ (inet_ntoa):
+
+ Fixed PSoS emulation of this method. The result is supposed to
+ be stored in a statically allocated string, not a dynamically
+ allocated one. Fixes a memory leak. Note that this change
+ makes the implementation non-reentrant. However, inet_ntoa()
+ was not designed to be reentrant to begin with.
+
+ * ace/OS.i (inet_addr):
+
+ On error, inet_addr() is supposed to return INADDR_NONE.
+
+ The return value should be a 32 bit unsigned integer, not a
+ signed one.
+
+ * ace/config-win32-common.h:
+
+ MS Windows does not support the inet_aton() function. Define
+ ACE_LACKS_INET_ATON.
+
Mon Jan 7 12:20:26 2002 Ossama Othman <ossama@uci.edu>
* bin/auto_run_tests.lst:
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 64be6087271..56e0b737e2f 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,40 @@
+Mon Jan 7 15:16:10 2002 Ossama Othman <ossama@uci.edu>
+
+ * ace/OS.h (INADDR_NONE):
+
+ If the platform does not define this constant, then define it.
+
+ * ace/OS.cpp (inet_aton):
+
+ For some reason we were emulating inet_aton() on all platforms
+ using the now deprecated inet_addr() function. Use the native
+ inet_aton() function unless ACE_LACKS_INET_ATON is defined.
+
+ Instead of performing a memcpy() of the IPv4 32-bit address into
+ the in_addr data structure, simply assign it to the s_addr field
+ of that data structure. It's not clear why we didn't do this in
+ the first place.
+
+ (inet_ntoa):
+
+ Fixed PSoS emulation of this method. The result is supposed to
+ be stored in a statically allocated string, not a dynamically
+ allocated one. Fixes a memory leak. Note that this change
+ makes the implementation non-reentrant. However, inet_ntoa()
+ was not designed to be reentrant to begin with.
+
+ * ace/OS.i (inet_addr):
+
+ On error, inet_addr() is supposed to return INADDR_NONE.
+
+ The return value should be a 32 bit unsigned integer, not a
+ signed one.
+
+ * ace/config-win32-common.h:
+
+ MS Windows does not support the inet_aton() function. Define
+ ACE_LACKS_INET_ATON.
+
Mon Jan 7 12:20:26 2002 Ossama Othman <ossama@uci.edu>
* bin/auto_run_tests.lst:
diff --git a/ace/OS.cpp b/ace/OS.cpp
index 8357b927d2a..d5fcc4525d4 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -5147,8 +5147,8 @@ ACE_OS::inet_ntoa (const struct in_addr addr)
{
ACE_OS_TRACE ("ACE_OS::inet_ntoa");
- char *addrstr = new char[17];
- unsigned long ipaddr = ntohl(addr.s_addr);
+ static char addrstr[INET_ADDRSTRLEN + 1] = { 0 };
+ ACE_UINT32 ipaddr = ntohl (addr.s_addr);
//printf("Socket address %X, IP address %X.\n",addr.s_addr,ipaddr);
sprintf(addrstr, "%d.%d.%d.%d",
((ipaddr & 0xff000000) >> 24) & 0x000000ff,
@@ -5162,9 +5162,10 @@ ACE_OS::inet_ntoa (const struct in_addr addr)
int
ACE_OS::inet_aton (const char *host_name, struct in_addr *addr)
{
+#if defined (ACE_LACKS_INET_ATON)
ACE_UINT32 ip_addr = ACE_OS::inet_addr (host_name);
- if (ip_addr == (ACE_UINT32) htonl ((ACE_UINT32) ~0)
+ if (ip_addr == INADDR_NONE
// Broadcast addresses are weird...
&& ACE_OS::strcmp (host_name, "255.255.255.255") != 0)
return 0;
@@ -5172,15 +5173,14 @@ ACE_OS::inet_aton (const char *host_name, struct in_addr *addr)
return 0;
else
{
-#if !defined(_UNICOS)
- ACE_OS::memcpy ((void *) addr, (void *) &ip_addr, sizeof ip_addr);
-#else /* ! _UNICOS */
- // on UNICOS, perform assignment to bitfield, since doing the above
- // actually puts the address outside of the 32-bit bitfield
- addr->s_addr = ip_addr;
-#endif /* ! _UNICOS */
+ addr->s_addr = ip_addr; // Network byte ordered
return 1;
}
+#else
+ // inet_aton() returns 0 upon failure, not -1 since -1 is a valid
+ // address (255.255.255.255).
+ ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0);
+#endif /* ACE_LACKS_INET_ATON */
}
struct tm *
diff --git a/ace/OS.h b/ace/OS.h
index 81f18b017a4..7407e30364f 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -3907,9 +3907,14 @@ typedef fd_set ACE_FD_SET_TYPE;
// Define INET loopback address constant if it hasn't been defined
// Dotted Decimal 127.0.0.1 == Hexidecimal 0x7f000001
# if !defined (INADDR_LOOPBACK)
-# define INADDR_LOOPBACK 0x7f000001
+# define INADDR_LOOPBACK ((ACE_UINT32) 0x7f000001)
# endif /* INADDR_LOOPBACK */
+// The INADDR_NONE address is generally 255.255.255.255.
+# if !defined (INADDR_NONE)
+# define INADDR_NONE ((ACE_UINT32) 0xffffffff)
+# endif /* INADDR_NONE */
+
// Define INET string length constants if they haven't been defined
//
// for IPv4 dotted-decimal
@@ -5792,7 +5797,7 @@ public:
int optname,
char *optval,
int *optlen);
- static long inet_addr (const char *name);
+ static unsigned long inet_addr (const char *name);
static char *inet_ntoa (const struct in_addr addr);
static int inet_aton (const char *strptr,
struct in_addr *addr);
diff --git a/ace/OS.i b/ace/OS.i
index 2f74164e493..a8137e9cc12 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -6567,7 +6567,7 @@ ACE_OS::getservbyname_r (const char *svc,
#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
}
-ACE_INLINE long
+ACE_INLINE unsigned long
ACE_OS::inet_addr (const char *name)
{
ACE_OS_TRACE ("ACE_OS::inet_addr");
@@ -6603,7 +6603,7 @@ ACE_OS::inet_addr (const char *name)
}
}
}
- return valid ? (long) htonl (ret) : -1L;
+ return valid ? htonl (ret) : INADDR_NONE;
#elif defined (ACE_HAS_NONCONST_GETBY)
return ::inet_addr ((char *) name);
#else
diff --git a/ace/README b/ace/README
index a1a489a5dcd..38bbf17ca8b 100644
--- a/ace/README
+++ b/ace/README
@@ -709,6 +709,8 @@ ACE_LACKS_GETPGID Platform lacks getpgid() call
ACE_LACKS_GETSERVBYNAME Platforms lacks
getservbyname() (e.g., VxWorks
and Chorus).
+ACE_LACKS_INET_ATON Platform lacks the inet_aton()
+ function.
ACE_LACKS_IOSTREAMS_TOTALLY Iostreams are not supported
adequately on the given platform.
ACE_LACKS_IOSTREAM_FX iostream header does not
diff --git a/ace/config-win32-common.h b/ace/config-win32-common.h
index 93f55fc4e7f..d3d58dd84cd 100644
--- a/ace/config-win32-common.h
+++ b/ace/config-win32-common.h
@@ -212,6 +212,7 @@
#define ACE_LACKS_SEEKDIR
#define ACE_LACKS_REWINDDIR
#define ACE_LACKS_READDIR_R
+#define ACE_LACKS_INET_ATON
#define ACE_HAS_VSWPRINTF
#define ACE_HAS_VFWPRINTF