httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Reid" <dr...@jetnet.co.uk>
Subject Re: apr_sockaddr_t
Date Fri, 10 Nov 2000 11:03:45 GMT
The hostname is there as if we pass in a hostname and ask for an
apr_sockaddr_t to be returned we might as well keep the hostname so should
we ask for the hostname for the apr_sockaddr_t we don't have any costly
calls to get it, we can just return it.
The string for the port?  It's there because if we ask for a port by name,
say 'http' or 'telnet' we can again keep that and have the port number as
well.
Why the addr_len?  When we use functions that need to know how long the
string buffer should be we shouldn't be determining at that point of we're
IPv4 or IPv6, we should just be able to grab the length and use it.

Of course we should probably also have a family flag so we can check it...
We can't use the sockaddr structures as we don't know which one we're
looking at without knowing the family!

I realise we don't currently use some of these and the functions to do some
of what I've described don't yet exist, but they will at some point and so
we should plan on making the structure as useful as we can.

In some ways I'd also like to add a set of pointers to the structure.  These
would be pointers to the start of the family, sockaddr structure and port
within wither the sin or sin6 structure.  By setting these when we know if
we're v4 or v6 we can reduce the number of times we have to check, and so
coding becomes much cleaner.

david

----- Original Message -----
From: "Tony Finch" <dot@dotat.at>
To: <new-httpd@apache.org>
Sent: Friday, November 10, 2000 2:50 AM
Subject: Re: apr_sockaddr_t


>
> David Reid <dreid@jetnet.co.uk> wrote:
> >+
> >+/* we're going to roll our own sockaddr type as we want to make sure
> >+ * we have protocol independance for APR...
> >+ *
> >+ * It's defined here as I think it should all be platform safe...
> >+ */
> >+typedef struct {
> >+    apr_pool_t *cont;              /* The pool to use... */
> >+    char *hostname;                /* The hostname */
> >+    char *port_str;                /* String representation of port */
> >+    apr_port_t port;               /* numeric port */
> >+    union {
> >+        struct sockaddr_in sin;    /* IPv4 sockaddr structure */
> >+#if APR_HAVE_IPV6
> >+        struct sockaddr_in6 sin6;  /* IPv6 sockaddr structure */
> >+#endif
> >+    } sa;
> >+    apr_socklen_t sa_len;          /* How big is the sockaddr we're
using?
> >*/
> >+    int addr_len;                  /* How big should the address buffer
be?
> >+                                    * 16 for v4 or 48 for v6
> >+                                    * used in inet_ntop...
> >+                                    */
> >+} apr_sockaddr_t;
>
> That looks absurdly baroque to me. Why is the hostname there? I think
> name <-> address translations should be handled at a higher level than
> sockaddrs. Why duplicate the port?
>
> Tony.
> --
> en oeccget g mtcaa    f.a.n.finch
> v spdlkishrhtewe y    dot@dotat.at
> eatp o v eiti i d.    fanf@covalent.net
>


Mime
View raw message