Jeff and I talked about this when we added the IPv6 stuff (which included the sockaddr types) and Jeff's feeling was to leave these functions and let people access the details directly. I don't mind either approach...
david ----- Original Message ----- From: "Jon Travis" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Monday, April 30, 2001 6:39 PM Subject: [PATCH] socket family fetching > I need a routine to fetch the socket family. I could just refer > to the information in the sockaddr_t address length, but that is > rather hackish. Anyway, here tis. We should also probably be > moving towards making the sockaddr_t an opaque type, or at least > some of the members. > > > Index: include/apr_network_io.h > =================================================================== > RCS file: /home/cvspublic/apr/include/apr_network_io.h,v > retrieving revision 1.101 > diff -u -u -r1.101 apr_network_io.h > --- include/apr_network_io.h 2001/04/03 01:09:51 1.101 > +++ include/apr_network_io.h 2001/04/30 16:31:30 > @@ -596,6 +596,16 @@ > apr_sockaddr_t *sockaddr); > > /** > + * Return the family in an APR socket address. > + * @param family The family from the socket address. > + * @param sockaddr The socket address to reference. > + * @deffunc apr_status_t apr_sockaddr_family_get(apr_int32_t *family, apr_sockaddr_t *sockaddr) > + */ > +APR_DECLARE(apr_status_t) apr_sockaddr_family_get(apr_int32_t *family, > + apr_sockaddr_t *sockaddr); > + > + > +/** > * Set the IP address in an APR socket address. > * @param sockaddr The socket address to use > * @param addr The IP address to attach to the socket. > Index: network_io/unix/sa_common.c > =================================================================== > RCS file: /home/cvspublic/apr/network_io/unix/sa_common.c,v > retrieving revision 1.32 > diff -u -u -r1.32 sa_common.c > --- network_io/unix/sa_common.c 2001/03/15 21:54:59 1.32 > +++ network_io/unix/sa_common.c 2001/04/30 16:32:07 > @@ -114,6 +114,21 @@ > return APR_SUCCESS; > } > > +APR_DECLARE(apr_status_t) apr_sockaddr_family_get(apr_int32_t *family, > + apr_sockaddr_t *sockaddr) > +{ > + if(sockaddr->salen == sizeof(struct sockaddr_in)) > + *family = APR_INET; > +#if APR_HAVE_IPV6 > + else if(sockaddr->salen == sizeof(struct sockaddr_in6)) > + *family = APR_INET6; > +#endif > + else > + *family = APR_UNSPEC; > + > + return APR_SUCCESS; > +} > + > APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, > apr_sockaddr_t *sockaddr) > {
