ofalk / libdnet

libdnet provides a simplified, portable interface to several low-level networking routines.
Other
153 stars 60 forks source link

route_get fails on ipv6 / freebsd #20

Closed GoogleCodeExporter closed 2 years ago

GoogleCodeExporter commented 9 years ago
This is on FreeBSD 7.1
/*
 * function: find_default_route_entry input: none output: addr (libdnet)
 * structure with the default route address
 */
struct addr    *
find_default_route_entry()
{
        route_t        *r = NULL;
        struct route_entry *e = NULL;
        int             i = 0;

        if ((e = malloc(sizeof(struct route_entry))) == NULL)
                crapout("malloc: failed to allocate route_entry for find_default_route");

        memset((void *) e, 0, sizeof(struct route_entry));
        if ((i = addr_pton("::", &((*e).route_dst))) < 0)
                crapout("dnet: Failed to addr_pton");

        if ((r = route_open()) == NULL)
                crapout("dnet: Failed to route_open");

        if ((i = route_get(r, e)) < 0)
                crapout("dnet: Failed to route_get");

        route_close(r);

        dprintf("default gateway addr: %s\n", addr_ntoa(&((*e).route_gw)));

        return &((*e).route_gw);

}

Expected output: interface for default route on IPv6.
dnet 1.12
FreeBSD 7.1

Original issue reported on code.google.com by jfesler on 23 Mar 2011 at 10:01

ofalk commented 4 years ago

I know, I know, this is pretty old.... Today I merged ipv6 support in the devel branch. Can you check it out and let me know if it works for you or is this issue anyway dead?