Joe Orton wrote:
On Tue, Dec 11, 2007 at 05:21:03AM -0600, William Rowe wrote:
Joe Orton wrote:
I'd rather just see a new flag added alongside the existing APR_IPV4_ADDR_* flags to make it explicit that this is a new and very different interface guarantee, APR_IPV6_ADDR_V4MAPPED maybe.
Perhaps, but the flag existed and had no definition, so this really
strikes me as a rational solution.  My 2c.

It's pretty horrid IMO: the existing APR_IPV?_ADDR_OK flags specify different *ordering* for the searches. This overloads a different combination of input parameters to have an unrelated side-effect - forcing use of v4-mapped IPv6 addresses.

That's a fair argument, and I can accept this.  APR_IPV6_V4MAPPED_OK
works for me.

Either the existing flag or a new flag, it doesn't seem like this can
be resolved before 1.3.0.  Does anyone see a way to make the reciprocal
sa-from-ip-and-inet6-family actually work before then?

No. But given that new interfaces are needed can we just give up on hacking the resolver and fix the actual issue, i.e. allow duplication of the sockaddr object?

We disagree that this isn't an issue in and of itself, but I'll tweak to
the 'new flag' as you suggest (and it could affect a broader range of cases
than just family==APR_INET6).

Something like this?

We don't disagree this is also a useful feature (which I hacked into ftp
just last night).  I don't care for _clone, though.  _dup makes more sense
to me, but since it will take an existing *sa, I'm ok with _copy too.
See the end of the message for all apr examples of those three forms.


Index: network_io/unix/sockaddr.c
===================================================================
--- network_io/unix/sockaddr.c  (revision 603185)
+++ network_io/unix/sockaddr.c  (working copy)
@@ -588,6 +588,27 @@
     return find_addresses(sa, hostname, family, port, flags, p);
 }
+APR_DECLARE(apr_sockaddr_t *) apr_sockaddr_clone(const apr_sockaddr_t *old,
+                                                 apr_port_t port,
+                                                 apr_pool_t *p)
+{
+    apr_sockaddr_t *sa = apr_pmemdup(p, old, sizeof *sa);
+
+    sa->pool = p;
+    sa->next = NULL;
+ + if (sa->hostname) {
+        sa->hostname = apr_pstrdup(p, sa->hostname);
+    }
+    if (sa->servname) {
+        sa->servname = apr_pstrdup(p, sa->servname);
+    }
+
+    apr_sockaddr_vars_set(sa, old->family, port);
+
+ return sa; +}
+
 APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname,
                                           apr_sockaddr_t *sockaddr,
                                           apr_int32_t flags)
Index: include/apr_network_io.h
===================================================================
--- include/apr_network_io.h    (revision 603185)
+++ include/apr_network_io.h    (working copy)
@@ -696,6 +696,18 @@
 APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1,
                                     const apr_sockaddr_t *addr2);
+/** Create a duplicate of a socket address structure.
+ * @param old Old socket address structure
+ * @param port Port to use in returned structure
+ * @return Duplicate socket address structure which varies only
+ * by the port specified.
+ * @note Available only in APR version 1.3.0 onwards.
+ */
+APR_DECLARE(apr_sockaddr_t *) apr_sockaddr_clone(const apr_sockaddr_t *old,
+                                                 apr_port_t port,
+                                                 apr_pool_t *p);
+
+
 /**
 * Return the type of the socket.
 * @param sock The socket to query.




$ grep dup * | grep DECLARE
apr_file_io.h:APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file,
apr_file_io.h:APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file,
apr_mmap.h:APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap,
apr_strings.h:APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s);
apr_strings.h:APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, 
apr_size_t n);
apr_strings.h:APR_DECLARE(char *) apr_pstrndup(apr_pool_t *p, const char *s, 
apr_size_t n);
apr_strings.h:APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, 
apr_size_t n);

$ grep copy * | grep DECLARE
apr_file_io.h:APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path,
apr_hash.h:APR_DECLARE(apr_hash_t *) apr_hash_copy(apr_pool_t *pool,
apr_tables.h:APR_DECLARE(apr_array_header_t *) apr_array_copy(apr_pool_t *p,
apr_tables.h:APR_DECLARE(apr_array_header_t *) apr_array_copy_hdr(apr_pool_t *p,
apr_tables.h:APR_DECLARE(apr_table_t *) apr_table_copy(apr_pool_t *p,

$ grep clone * | grep DECLARE
apr_tables.h:APR_DECLARE(apr_table_t *) apr_table_clone(apr_pool_t *p,

Reply via email to