diff options
author | wtc%netscape.com <devnull@localhost> | 2000-06-09 13:44:08 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 2000-06-09 13:44:08 +0000 |
commit | 1f0dc394bc2fea27c8b4cbb68f0f45a1c9022723 (patch) | |
tree | a1537d602e306a48ac9a395c6228370fba79d11a | |
parent | ac13ed792a2b336c31164cdb7549f5d3164c20bf (diff) | |
download | nspr-hg-1f0dc394bc2fea27c8b4cbb68f0f45a1c9022723.tar.gz |
Bugzilla bug #40542: pass the correct size of struct sockaddr_in8 to
native socket functions on Solaris 8 for Intel/x86. r=larryh@netscape.com.
a=pdt. Thanks to dcran@us.ibm.com (Donnie Cranford) for the bug report.
Modified files: _solaris.h, primpl.h
(NSPRPUB_CLIENT_BRANCH)
-rw-r--r-- | pr/include/md/_solaris.h | 18 | ||||
-rw-r--r-- | pr/include/private/primpl.h | 33 |
2 files changed, 51 insertions, 0 deletions
diff --git a/pr/include/md/_solaris.h b/pr/include/md/_solaris.h index 5a16750c..88c5a44e 100644 --- a/pr/include/md/_solaris.h +++ b/pr/include/md/_solaris.h @@ -86,6 +86,24 @@ #define AI_V4MAPPED 0x0001 #define AI_ALL 0x0002 #define AI_ADDRCONFIG 0x0004 +#define _PR_HAVE_MD_SOCKADDR_IN6 +/* isomorphic to struct in6_addr on Solaris 8 */ +struct _md_in6_addr { + union { + PRUint8 _S6_u8[16]; + PRUint32 _S6_u32[4]; + PRUint32 __S6_align; + } _S6_un; +}; +/* isomorphic to struct sockaddr_in6 on Solaris 8 */ +struct _md_sockaddr_in6 { + PRUint16 sin6_family; + PRUint16 sin6_port; + PRUint32 sin6_flowinfo; + struct _md_in6_addr sin6_addr; + PRUint32 sin6_scope_id; + PRUint32 __sin6_src_id; +}; #endif #include "prinrval.h" diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h index a0378650..4b68a2b1 100644 --- a/pr/include/private/primpl.h +++ b/pr/include/private/primpl.h @@ -1280,6 +1280,39 @@ extern PRUintn _PR_NetAddrSize(const PRNetAddr* addr); #define PR_NETADDR_SIZE(_addr) _PR_NetAddrSize(_addr) +#elif defined(_PR_HAVE_MD_SOCKADDR_IN6) + +/* +** Under the following conditions: +** 1. _PR_INET6 is not defined; +** 2. _PR_INET6_PROBE is defined; +** 3. struct sockaddr_in6 has nonstandard fields at the end +** (e.g., on Solaris 8), +** (_addr)->ipv6 is smaller than struct sockaddr_in6, and +** hence we can't pass sizeof((_addr)->ipv6) to socket +** functions such as connect because they would fail with +** EINVAL. +** +** To pass the correct socket address length to socket +** functions, define the macro _PR_HAVE_MD_SOCKADDR_IN6 and +** define struct _md_sockaddr_in6 to be isomorphic to +** struct sockaddr_in6. +*/ + +#if defined(XP_UNIX) +#define PR_NETADDR_SIZE(_addr) \ + ((_addr)->raw.family == PR_AF_INET \ + ? sizeof((_addr)->inet) \ + : ((_addr)->raw.family == PR_AF_INET6 \ + ? sizeof(struct _md_sockaddr_in6) \ + : sizeof((_addr)->local))) +#else +#define PR_NETADDR_SIZE(_addr) \ + ((_addr)->raw.family == PR_AF_INET \ + ? sizeof((_addr)->inet) \ + : sizeof(struct _md_sockaddr_in6) +#endif /* defined(XP_UNIX) */ + #else #if defined(XP_UNIX) |