OSSP CVS Repository

ossp - Check-in [2566]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2566
Date: 2002-Oct-11 17:27:39 (local)
2002-Oct-11 15:27:39 (UTC)
User:rse
Branch:
Comment: - fix inet_ntoa(3) usage - fallback to usage of inet_addr(3) if inet_aton(3) does not exists - add casts for arguments to [gs]etsockopt(3) to shut down warnings

(This especially gets OSSP sa running under dead Solaris 2.6...)

Tickets:
Inspections:
Files:
ossp-pkg/sa/sa.ac      1.10 -> 1.11     1 inserted, 1 deleted
ossp-pkg/sa/sa.c      1.58 -> 1.59     19 inserted, 11 deleted
ossp-pkg/sa/sa.h      1.30 -> 1.31     1 inserted, 1 deleted

ossp-pkg/sa/sa.ac 1.10 -> 1.11

--- sa.ac        2002/03/15 10:47:36     1.10
+++ sa.ac        2002/10/11 15:27:39     1.11
@@ -72,7 +72,7 @@
     AC_CHECK_HEADERS(string.h sys/types.h sys/socket.h netdb.h netinet/in.h)
 
     #   check for system functions
-    AC_CHECK_FUNCS(inet_aton inet_pton inet_ntoa inet_ntop snprintf)
+    AC_CHECK_FUNCS(inet_addr inet_aton inet_pton inet_ntoa inet_ntop snprintf)
 
     dnl # check for network/socket size type
     SA_CHECK_TYPEDEF(socklen_t, sys/socket.h)


ossp-pkg/sa/sa.c 1.58 -> 1.59

--- sa.c 2002/03/15 10:47:36     1.58
+++ sa.c 2002/10/11 15:27:39     1.59
@@ -240,10 +240,17 @@
     struct in_addr in_val;
 
     if (family == AF_INET) {
+#if defined(HAVE_INET_ATON)
         /* at least for IPv4 we can rely on the old inet_aton(3)
            and for IPv6 inet_pton(3) would exist anyway */
         if (inet_aton(strptr, &in_val) == 0)
             return 0;
+#elif defined(HAVE_INET_ADDR)
+        /* at least for IPv4 try to rely on the even older inet_addr(3) */
+        memset(&in_val, '\0', sizeof(in_val));
+        if ((in_val.s_addr = inet_addr(strptr)) == ((in_addr_t)-1))
+            return 0;
+#endif
         memcpy(addrptr, &in_val, sizeof(struct in_addr));
         return 1;
     }
@@ -258,14 +265,14 @@
 #ifdef HAVE_INET_NTOP
     return inet_ntop(family, src, dst, size);
 #else
-    struct in_addr in_val;
     char *cp;
     int n;
 
     if (family == AF_INET) {
+#ifdef HAVE_INET_NTOA
         /* at least for IPv4 we can rely on the old inet_ntoa(3)
            and for IPv6 inet_ntop(3) would exist anyway */
-        if ((cp = inet_ntoa(src)) == NULL) 
+        if ((cp = inet_ntoa(*((struct in_addr *)src))) == NULL) 
             return NULL;
         n = strlen(cp);
         if (n > size-1)
@@ -273,6 +280,7 @@
         memcpy(dst, cp, n);
         dst[n] = '\0';
         return dst;
+#endif
     }
     errno = EAFNOSUPPORT;
     return NULL;
@@ -814,8 +822,8 @@
         ucp1 = (const unsigned char *)&(((struct sockaddr_in6 *)saa1->saBuf)->sin6_addr);
         ucp2 = (const unsigned char *)&(((struct sockaddr_in6 *)saa2->saBuf)->sin6_addr);
         nBits = 128;
-#endif
     }
+#endif
     else
         return SA_RC(SA_ERR_INT);
 
@@ -862,14 +870,14 @@
     if (sa->fdSocket != -1) {
         if (SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) {
             if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_RCVTIMEO,
-                           &sa->tvTimeout[SA_TIMEOUT_READ],
-                           sizeof(sa->tvTimeout[SA_TIMEOUT_READ])) < 0)
+                           (const void *)(&sa->tvTimeout[SA_TIMEOUT_READ]),
+                           (socklen_t)(sizeof(sa->tvTimeout[SA_TIMEOUT_READ]))) < 0)
                 return SA_RC(SA_ERR_SYS);
         }
         if (SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) {
             if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_SNDTIMEO,
-                           &sa->tvTimeout[SA_TIMEOUT_WRITE],
-                           sizeof(sa->tvTimeout[SA_TIMEOUT_WRITE])) < 0)
+                           (const void *)(&sa->tvTimeout[SA_TIMEOUT_WRITE]),
+                           (socklen_t)(sizeof(sa->tvTimeout[SA_TIMEOUT_WRITE]))) < 0)
                 return SA_RC(SA_ERR_SYS);
         }
     }
@@ -1150,7 +1158,7 @@
                 break;
             }
             if (setsockopt(sa->fdSocket, IPPROTO_TCP, TCP_NODELAY, 
-                           (void *)&mode, sizeof(mode)) < 0)
+                           (const void *)&mode, (socklen_t)sizeof(mode)) < 0)
                 rv = SA_ERR_SYS;
 #else
             rv = SA_ERR_IMP;
@@ -1165,7 +1173,7 @@
                 break;
             }
             if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_LINGER, 
-                           linger, sizeof(struct linger)) < 0)
+                           (const void *)linger, (socklen_t)sizeof(struct linger)) < 0)
                 rv = SA_ERR_SYS;
 #else
             rv = SA_ERR_IMP;
@@ -1192,7 +1200,7 @@
                 default: flag = 0; break;
             }
             if (setsockopt(sa->fdSocket, SOL_SOCKET, flag, 
-                           (void *)&mode, sizeof(mode)) < 0)
+                           (const void *)&mode, (socklen_t)sizeof(mode)) < 0)
                 rv = SA_ERR_SYS;
             break;
         }
@@ -1349,7 +1357,7 @@
 
         /* fetch pending error */
         len = sizeof(error);
-        if (getsockopt(sa->fdSocket, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
+        if (getsockopt(sa->fdSocket, SOL_SOCKET, SO_ERROR, (void *)&error, &len) < 0)
             error = errno;
 
         done:


ossp-pkg/sa/sa.h 1.30 -> 1.31

--- sa.h 2002/03/15 10:47:36     1.30
+++ sa.h 2002/10/11 15:27:39     1.31
@@ -43,7 +43,7 @@
 
 /* fallback for POSIX socklen_t */
 #if defined(HAVE_CONFIG_H) && !defined(HAVE_SOCKLEN_T)
-#define socklen_t int
+typedef int socklen_t;
 #endif
 
 /* embedding support */

CVSTrac 2.0.1