httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Reid" <dr...@jetnet.co.uk>
Subject apr_sockaddr_t
Date Fri, 10 Nov 2000 01:22:30 GMT
Folks,

Next step in APR is to abstract out the sockaddr's.  We don't use the raw
struct in many places, but we need to remove the remaining references.  Big
problem will be http_vhost...

This patch adds a new apr_sockaddr_t type.  It has IPv6 support built into
it as it makes to start adding it now...  It also adds an enumeration of the
socket types we'll know how to create...

Continuing the theme of softly, softly, I'd like to commit this and then
wait to see if anyone ahs any problems (Bill & Bill??).  If the structure
isn't platform safe I'll move it to the networkio.h header files.

Once we're happy with the structure I'd like to start moving it into the
code, but until I get a chance to go through http_vhost it won't be possible
to do too much :(

Ideally I'd like to get this in as I suspect it'll break a fair bit of code
in the short term...

david

Index: include/apr_network_io.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_network_io.h,v
retrieving revision 1.65
diff -u -r1.65 apr_network_io.h
--- include/apr_network_io.h    2000/11/10 00:58:25     1.65
+++ include/apr_network_io.h    2000/11/10 01:16:49
@@ -119,6 +119,12 @@
     APR_REMOTE
 } apr_interface_e;

+/* Enum of the types of socket we can create... */
+typedef enum {
+    APR_TCP_V4,
+    APR_TCP_V6
+} apr_sockettype_e;
+
 /* I guess not everybody uses inet_addr.  This defines apr_inet_addr
  * appropriately.
  */
@@ -136,6 +142,29 @@

 /* use apr_uint16_t just in case some system has a short that isn't 16
bits... */
 typedef apr_uint16_t            apr_port_t;
+
+/* 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;

 #if APR_HAS_SENDFILE
 /* Define flags passed in on apr_sendfile() */



Mime
View raw message