git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/5] struct sockaddr_storage->ss_family is not portable

From
GVGary V. Vaughan <git@mlists.thewrittenword.com>
Date
Apr 25, 2010, 08:36 UTC
Message-ID
<20100312151522.GA11943@thor.il.thewrittenword.com>
In-Reply-To
<alpine.DEB.2.00.1003120922040.29993@cone.home.martin.st>
Hi Martin,
On Fri, Mar 12, 2010 at 09:24:01AM +0200, Martin Storsj? wrote:
Show 22 quoted lines
> On Fri, 12 Mar 2010, Gary V. Vaughan wrote:
> > On Thu, Mar 11, 2010 at 06:40:37PM +0200, Martin Storsj? wrote:
> > > On Thu, 11 Mar 2010, Gary V. Vaughan wrote:
> > > 
> > > > Many of our supported platforms do not have this declaration, for
> > > > example solaris2.6 thru 2.7.  Lack of ss_family implies no IPV6
> > > > support, so we can wrap all the ss_family references in an ifndef
> > > > NO_IPV6, and assume sockaddr_in otherwise.
> > > 
> > > While this probably is ok as such, you can actually do the same without 
> > > accessing the sockaddr_storage->ss_family; just cast it to (const struct 
> > > sockaddr*) and use ->sa_family instead, that should work just as well, as 
> > > far as I know.
> > 
> > At least on aix-5.2 it won't be reliable unless you juggle compiler
> > switches just right [...]
> 
> Yes, but if the sockaddr struct can be arranged in different ways, the 
> other ones (sockaddr_in, sockaddr_storage, sockaddr_in6) must also be 
> defined coherently - you're always supposed to be able to cast an 
> sockaddr_in (or any other of them) to a sockaddr and read the sa_family 
> field. As far as I know, at least.

Ah, good point. And now, having tested that on all our machines it works perfectly, and is much more elegant!

I'll resubmit presently.
Cheers,
-- 
Gary V. Vaughan (gary@thewrittenword.com)
Previous: Martin StorsjöNext: Martin Storsjö
Message 13 of 17 in “struct sockaddr_storage->ss_family is not portable”
  1. 5/5 struct sockaddr_storage->ss_family is not portableGary V. Vaughan, Mar 11, 2010
  2. Martin StorsjöMar 11, 2010
  3. Gary V. VaughanMar 12, 2010
  4. Martin StorsjöMar 12, 2010
  5. daemon.c: avoid accessing ss_family member of struct sockaddr_storageBrandon Casey, Mar 15, 2010
  6. Jeff KingMar 15, 2010
  7. Martin StorsjöMar 15, 2010
  8. Brandon CaseyMar 15, 2010
  9. Gary V. VaughanApr 25, 2010
  10. Martin StorsjöMar 15, 2010
  11. daemon.c: avoid accessing ss_family member of struct sockaddr_storageBrandon Casey, Mar 15, 2010
  12. Martin StorsjöMar 16, 2010
  13. Gary V. VaughanApr 25, 2010
  14. Martin StorsjöApr 25, 2010
  15. Gary V. VaughanApr 26, 2010
  16. Jeff KingMar 11, 2010
  17. Brandon CaseyMar 11, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.