Return-Path: Delivered-To: apmail-new-httpd-archive@apache.org Received: (qmail 44290 invoked by uid 500); 14 Nov 2000 14:59:13 -0000 Mailing-List: contact new-httpd-help@apache.org; run by ezmlm Precedence: bulk Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list new-httpd@apache.org Received: (qmail 44258 invoked from network); 14 Nov 2000 14:59:10 -0000 X-Authentication-Warning: adsl-77-241-65.rdu.bellsouth.net: trawick set sender to trawickj@bellsouth.net using -f Sender: trawick@bellsouth.net To: new-httpd@apache.org Subject: Re: [PATCH] apr_sockaddr_t & friends References: <002901c04ced$0f331520$061aa8c0@godzilla> <02bf01c04e3e$6c8f6690$021aa8c0@godzilla> <030101c04e46$6fdd1150$021aa8c0@godzilla> From: Jeff Trawick Date: 14 Nov 2000 09:55:24 -0500 In-Reply-To: "David Reid"'s message of "Tue, 14 Nov 2000 14:23:15 -0000" Message-ID: Lines: 79 User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N "David Reid" writes: > /** > * Get the character network address of the IP address contained in the > apr_sockaddr_t. > * @param addr The pointer to the returned string. > * @param sa The apr_sockaddr_t structure to use... > * @param p The apr_pool_t to use for memory allocations. > */ > apr_status_t apr_get_nas(char **addr, apr_sockaddr_t *sa, apr_pool_t *p); We may or may not want a pool parameter here, depending on how it should work. If we want it to cache the numeric address string so that apps don't need a separate field, the function would be something like this: if (!sa->addr_str) { /* gotta add this field to apr_sockaddr_t */ sa->addr_str = apr_palloc(sa->pool, sa->addr_str_len); apr_inet_ntop(sa->sin.sin_family, sa->ipaddr_ptr, sa->addr_str, sa->addr_str_len); } *addr = sa->addr_str; > > I'm not sure what you mean... > > I think that makes two of us. Can you outline more of your API in detail? for UDP? something like this: apr_sendto(apr_socket_t *sock, apr_sockaddr_t *sa, apr_size_t *nbytes) { if (!sa) { sa = sock->remote_addr; } do { rc = sendto(sock->fd, &sa->sin, sa->sa_len); } while (rc == -1 && errno == EINTR); /* handle rc, nbytes, timeout here */ } apr_recvfrom(apr_socket_t *sock, apr_sockaddr_t **newsa, apr_size_t *nbytes) { apr_sockaddr_t *sa; if (!**newsa) { use sock->remote_addr; } else { *newsa = apr_palloc(sock->pool, sock->sa_len); use new sa; } do { rc = recvfrom(sock->fd, &sa->sin, &sa->sa_len); } while (rc == -1 && errno == EINTR); /* handle rc, nbytes, timeout here */ } more comments on the set of routines in your current patch: apr_get_socket_inaddr(), apr_get_v4_address(), apr_inaddr_compare(): replace these three routines with apr_get_ipaddr(apr_sockaddr_t *sa, char **ipaddr, apr_size_t *len, apr_int32_t *family); This returns the address of the IP address within the sockaddr_in[6] and tells the caller the length and the family. I'm not sure we need the apr_in_addr_t data type at this point. -- Jeff Trawick | trawick@ibm.net | PGP public key at web site: http://www.geocities.com/SiliconValley/Park/9289/ Born in Roswell... married an alien...