2002-02-14 Jeffrey Stedfast <fejj@ximian.com>
authorJeffrey Stedfast <fejj@novell.com>
Thu, 14 Feb 2002 01:06:46 +0000 (01:06 -0000)
committerJeffrey Stedfast <fejj@novell.com>
Thu, 14 Feb 2002 01:06:46 +0000 (01:06 -0000)
* socket-io.c: conditionally include sys/filio.h and sys/sockio.h
for FIONBIO, FIONREAD and SIOCATMARK.
(ves_icall_System_Net_Dns_GetHostByAddr_internal): SunOS doesn't
define INADDR_NONE and besides, inet_addr() is deprecated and
should not be used. Use inet_pton() instead - it also has the
added bonus that it can easily handle IPv6 addresses as well.
(inet_pton): Implement using inet_aton() ifndef HAVE_INET_PTON.

svn path=/trunk/mono/; revision=2395

mono/metadata/ChangeLog
mono/metadata/socket-io.c

index 3130f688a31401ae2e37706c81cff0c43ffd938d..09d17c93a145d6649c6d3061615b84beea0c6ef2 100644 (file)
@@ -1,3 +1,12 @@
+2002-02-14  Jeffrey Stedfast  <fejj@ximian.com>
+
+       * socket-io.c: conditionally include sys/filio.h and sys/sockio.h
+       for FIONBIO, FIONREAD and SIOCATMARK.
+       (ves_icall_System_Net_Dns_GetHostByAddr_internal): SunOS doesn't
+       define INADDR_NONE and besides, inet_addr() is deprecated and
+       should not be used. Use inet_pton() instead - it also has the
+       added bonus that it can easily handle IPv6 addresses as well.
+       (inet_pton): Implement using inet_aton() ifndef HAVE_INET_PTON.
 
 Wed Feb 13 23:00:21 CET 2002 Paolo Molaro <lupus@ximian.com>
 
@@ -11,7 +20,8 @@ Wed Feb 13 23:00:21 CET 2002 Paolo Molaro <lupus@ximian.com>
 
 Wed Feb 13 19:20:01 CET 2002 Paolo Molaro <lupus@ximian.com>
 
-       * assembly.cs: better resolver: use it instead of some kludgy code.
+       * assembly.cs: better resolver: use it instead of some kludgy
+       code.
 
 Wed Feb 13 18:25:55 CET 2002 Paolo Molaro <lupus@ximian.com>
 
index 4b7200d401fd36e50661d2d21f684ddf6b32744c..bcc8e103721d8658fbfdd2c866e9ad8a72ebdadb 100644 (file)
 #include <mono/metadata/exception.h>
 #include <mono/metadata/appdomain.h>
 
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>    /* defines FIONBIO and FIONREAD */
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>   /* defines SIOCATMARK */
+#endif
+
 #undef DEBUG
 
 static gint32 convert_family(MonoAddressFamily mono_family)
@@ -1226,24 +1233,40 @@ extern gboolean ves_icall_System_Net_Dns_GetHostByName_internal(MonoString *host
        return(hostent_to_IPHostEntry(he, h_name, h_aliases, h_addr_list));
 }
 
+#ifndef HAVE_INET_PTON
+static int
+inet_pton (int family, const char *address, void *inaddrp)
+{
+       if (family == AF_INET) {
+               struct in_addr inaddr;
+               
+               if (!inet_aton (address, &inaddr))
+                       return 0;
+               
+               memcpy (inaddrp, &inaddr, sizeof (struct in_addr));
+               return 1;
+       }
+       
+       errno = EAFNOSUPPRT;
+       return -1;
+}
+#endif /* !HAVE_INET_PTON */
+
 extern gboolean ves_icall_System_Net_Dns_GetHostByAddr_internal(MonoString *addr, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list)
 {
-       char *address;
-       guint32 inaddr;
+       struct in_addr inaddr;
        struct hostent *he;
+       char *address;
        
-       address=mono_string_to_utf8(addr);
-       inaddr=inet_addr(address);
-       free(address);
-       if(inaddr==INADDR_NONE) {
-               return(FALSE);
+       address = mono_string_to_utf8 (addr);
+       if (inet_pton (AF_INET, address, &inaddr) <= 0) {
+               free (address);
+               return FALSE;
        }
        
-       he=gethostbyaddr(&inaddr, sizeof(inaddr), AF_INET);
-       if(he==NULL) {
-               return(FALSE);
-       }
-
+       if ((he = gethostbyaddr ((char *) &inaddr, sizeof (inaddr), AF_INET)) == NULL)
+               return FALSE;
+       
        return(hostent_to_IPHostEntry(he, h_name, h_aliases, h_addr_list));
 }