Bug 19898 - [gibber] GibberAddress union
Summary: [gibber] GibberAddress union
Status: RESOLVED INVALID
Alias: None
Product: Wocky
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: All All
: medium enhancement
Assignee: Telepathy bugs list
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-02 03:42 UTC by Simon McVittie
Modified: 2010-06-11 07:31 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Simon McVittie 2009-02-02 03:42:24 UTC
When you use sockaddr_foo for addresses, there are usually lots of type casts obscuring the code, and it's easy to forget that a struct sockaddr isn't big enough for a Unix socket path (you need a struct sockaddr_storage for that).

Consider adding a GibberAddress struct or union which contains one of each sockaddr struct, including sockaddr_storage:

typedef union {
    struct sockaddr generic;
    struct sockaddr_storage storage;
    struct sockaddr_inet ipv4;
    struct sockaddr_inet6 ipv6;
    struct sockaddr_unix un;
} GibberSockAddr;

Gabble has a union similar to this one internally, although the necessity to #ifdef various bits of the union for different OSs (no Unix sockets on Windows) may mean we can't have the union appear directly in an ABI-stable header file.

libnice has a NiceAddress type which could be worth investigating for this, although that one is unlikely to support Unix sockets. I believe Avahi has a similar thing too.
Comment 1 Dafydd Harries 2009-09-24 08:53:28 UTC
GIO has GSocketFamily and GSocketAddress now. Perhaps these meet your needs?

Comment 2 Simon McVittie 2010-06-11 07:31:56 UTC
(In reply to comment #1)
> GIO has GSocketFamily and GSocketAddress now. Perhaps these meet your needs?

Yeah, I think we should just port to GIO over time. Resolving as INVALID.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.