On Tue, Jun 17, 2003 at 11:01:27PM -0500, Bruno Wolff III wrote:
> 
> My system does have its own sockaddr_storage definition. I think
> it uses __ss_ as the prefix. Also, after looking at the fallback
> definition in pqcomm.h, I don't see where that defines ss_family
> and hence don't see how that could work.
> I am going to see if adding __ works as suggested by someone else
> who replied.

See if this patch helps.

Don't forget to run autoconf after applying the patch.



Kurt

Index: configure.in
===================================================================
RCS file: /projects/cvsroot/pgsql-server/configure.in,v
retrieving revision 1.266
diff -u -r1.266 configure.in
--- configure.in        18 Jun 2003 16:04:15 -0000      1.266
+++ configure.in        19 Jun 2003 20:56:20 -0000
@@ -778,6 +778,7 @@
 PGAC_UNION_SEMUN
 PGAC_STRUCT_SOCKADDR_UN
 PGAC_STRUCT_SOCKADDR_STORAGE
+PGAC_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
 PGAC_STRUCT_ADDRINFO
 
 AC_CHECK_TYPES([struct cmsgcred, struct fcred, struct sockcred], [], [],
Index: config/c-library.m4
===================================================================
RCS file: /projects/cvsroot/pgsql-server/config/c-library.m4,v
retrieving revision 1.21
diff -u -r1.21 c-library.m4
--- config/c-library.m4 12 Jun 2003 16:05:10 -0000      1.21
+++ config/c-library.m4 19 Jun 2003 20:56:20 -0000
@@ -110,6 +110,19 @@
 #endif
 ])])# PGAC_STRUCT_SOCKADDR_STORAGE
 
+# PGAC_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
+# --------------------------------------
+# This checks if the struct sockaddr has a proper ss_family and not an
+# __ss_family as rfc2553 defined.
+AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE_SS_FAMILY],
+[AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family,
+       struct sockaddr_storage.__ss_family], [], [],
+[#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+])])# PGAC_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
+
 
 # PGAC_STRUCT_ADDRINFO
 # -----------------------
Index: src/include/pg_config.h.in
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/pg_config.h.in,v
retrieving revision 1.53
diff -u -r1.53 pg_config.h.in
--- src/include/pg_config.h.in  15 Jun 2003 04:09:18 -0000      1.53
+++ src/include/pg_config.h.in  19 Jun 2003 20:56:21 -0000
@@ -423,6 +423,12 @@
 /* Define to 1 if the system has the type `struct sockaddr_storage'. */
 #undef HAVE_STRUCT_SOCKADDR_STORAGE
 
+/* Define to 1 if your struct sockaddr_storage has an ss_family member */
+#undef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
+
+/* Define to 1 if your struct sockaddr_storage has an __ss_family member */
+#undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY
+
 /* Define to 1 if the system has the type `struct sockaddr_un'. */
 #undef HAVE_STRUCT_SOCKADDR_UN
 
Index: src/include/libpq/pqcomm.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/libpq/pqcomm.h,v
retrieving revision 1.86
diff -u -r1.86 pqcomm.h
--- src/include/libpq/pqcomm.h  12 Jun 2003 07:36:51 -0000      1.86
+++ src/include/libpq/pqcomm.h  19 Jun 2003 20:56:21 -0000
@@ -43,15 +43,25 @@
 /*
  * Definitions used for sockaddr_storage structure paddings design.
  */
-#define        _SS_PAD1SIZE    (_SS_ALIGNSIZE - sizeof (sa_family_t))
-#define        _SS_PAD2SIZE    (_SS_MAXSIZE - (sizeof (sa_family_t) + \
+/* Some platforms don't have sa_family_t, so we compute it ourselves */
+#define SIZEOF_SOCKADDR_FAMILY                sizeof(((struct sockaddr 
*)0)->sa_family)
+
+#define        _SS_PAD1SIZE    (_SS_ALIGNSIZE - SIZEOF_SOCKADDR_FAMILY)
+#define        _SS_PAD2SIZE    (_SS_MAXSIZE - (SIZEOF_SOCKADDR_FAMILY + \
                                _SS_PAD1SIZE + _SS_ALIGNSIZE))
 
 struct sockaddr_storage {
 #ifdef SALEN
     uint8_t    __ss_len;        /* address length */
 #endif
-    sa_family_t        ss_family;      /* address family */
+
+#if SIZEOF_SOCKADDR_FAMILY == 1
+        uint8_t         ss_family;
+#elif SIZEOF_SOCKADDR_FAMILY == 2
+        uint16_t        ss_family;
+#else
+#error unsupported sa_family size
+#endif
 
     char       __ss_pad1[_SS_PAD1SIZE];
                /* 6 byte pad, this is to make implementation
@@ -65,6 +75,12 @@
                 * _SS_MAXSIZE value minus size of ss_family
                 * __ss_pad1, __ss_align fields is 112 */
 };
+#elif !defined(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)
+# ifdef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY
+#  define ss_family __ss_family
+# else
+#  error struct sockaddr_storage does not provide an ss_family member
+# endif
 #endif
 
 typedef struct {
Index: src/port/getaddrinfo.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/port/getaddrinfo.c,v
retrieving revision 1.8
diff -u -r1.8 getaddrinfo.c
--- src/port/getaddrinfo.c      14 Jun 2003 18:20:33 -0000      1.8
+++ src/port/getaddrinfo.c      19 Jun 2003 20:56:22 -0000
@@ -220,7 +220,6 @@
                char *node, int nodelen,
                char *service, int servicelen, int flags)
 {
-       sa_family_t     family;
        int             ret = -1;
 
        /* Invalid arguments. */
@@ -236,9 +235,8 @@
                return EAI_FAIL;
        }
 
-       family = sa->sa_family;
 #ifdef HAVE_IPV6
-       if (family == AF_INET6)
+       if (sa->sa_family == AF_INET6)
        {
                return  EAI_FAMILY;
        }
@@ -246,13 +244,13 @@
 
        if (service)
        {
-               if (family == AF_INET)
+               if (sa->sa_family == AF_INET)
                {
                        ret = snprintf(service, servicelen, "%d",
                                ntohs(((struct sockaddr_in *)sa)->sin_port));
                }
 #ifdef HAVE_UNIX_SOCKETS
-               else if (family == AF_UNIX)
+               else if (sa->sa_family == AF_UNIX)
                {
                        ret = snprintf(service, servicelen, "%s",
                                ((struct sockaddr_un *)sa)->sun_path);
@@ -266,14 +264,14 @@
 
        if (node)
        {
-               if (family == AF_INET)
+               if (sa->sa_family == AF_INET)
                {
                        char    *p;
                        p = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr);
                        ret = snprintf(node, nodelen, "%s", p);
                }
 #ifdef HAVE_UNIX_SOCKETS
-               else if (family == AF_UNIX)
+               else if (sa->sa_family == AF_UNIX)
                {
                        ret = snprintf(node, nodelen, "%s", "localhost");
                }
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to