apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Helfer" <peter.helfer.j...@gmail.com>
Subject Extending apr_sockaddr_t
Date Mon, 03 Nov 2008 05:40:53 GMT
Hi all
If I want to introduce a new kind of addresses in apr, what is there to take
care of ?
Assume, I would introduce a 64bit address instead of the traditional IPv4.
Besides putting it in the union, I would also have to change the salen (to
the complete length of the struct) and the ipaddr_len to the length of my
address type - correct ?
In addition to that the inet_ntop would have to be chosen correctly. Now
where I'm wondering is about the rest - how to adopt the existing code into
using a different addressing scheme.

If I can open the functionality by calling the traditional socket just with
a different family, how would I have to change the code ?

Regards, Peter

The referenced struct:

struct apr_sockaddr_t {
    apr_pool_t *pool;
    char *hostname;
    char *servname;
    apr_port_t port;
    apr_int32_t family;
    /** How big is the sockaddr we're using? */
    apr_socklen_t salen;
    /** How big is the ip address structure we're using? */
    int ipaddr_len;
    /** How big should the address buffer be?  16 for v4 or 46 for v6
     *  used in inet_ntop... */
    int addr_str_len;
    /** This points to the IP address structure within the appropriate
     *  sockaddr structure.  */
    void *ipaddr_ptr;
    /** If multiple addresses were found by apr_sockaddr_info_get(), this
     *  points to a representation of the next address. */
    apr_sockaddr_t *next;
    /** Union of either IPv4 or IPv6 sockaddr. */
    union {
        /** IPv4 sockaddr structure */
        struct sockaddr_in sin;
        /** IPv6 sockaddr structure */
        struct sockaddr_in6 sin6;
        /** Placeholder to ensure that the size of this union is not
         * dependent on whether APR_HAVE_IPV6 is defined. */
        struct sockaddr_storage sas;
    } sa;

View raw message