[isf-wifidog] getting wifidog working with olsr and spatial portal

Saul Albert saul at twenteenthcentury.com
Dim 15 Mai 13:51:46 EDT 2005


Hiya,

On Sat, May 14, 2005 at 03:58:28PM -0700, Jo Walsh wrote:
> as well as the gw_id at that stage. I don't want to have to hardcode a 
> gw_id; we can't run a managed network. we'll send a patch soon if you
> would accept it? saul's been doing sterling work learning C.

haha. and failing miserably. Before I go and lobotomise myself with
alcohol, I'll post  the results of my first C experiment.. which in the
end, amounted to stealing some of schuyler's code from NoCatSplash (on
his advice) and trying to adapt it to work with wifidog.

This is the function I grabbed and adapted and tried to munge into
/src/ping_thread.c 

It kind of worked. I sort of got something  that I kind of think might be
an address poniter. Or something. It wasn't a mac address anyway. I think
this might have been because I didn't know how to pass the result of  the
function to the ping() function properly.

Hmm.

if anyone is actually able to read this jibberish - I'd really really
appreciate a patch. I have a feeling I could sink a couple of weeks into
what probably isn't a very big job :)

X

S.



===========================================
char *get_mac_address (const char *dev) {
    int r, s;
    struct ifreq ifr;
    char *dest = calloc( char, 13 );
    char *hwaddr;

    strcpy( ifr.ifr_name, dev );

    s = socket( PF_INET, SOCK_DGRAM, 0 );
    if (s == -1) {
        warning("get_mac_address socket: %m");
        free(dest);
        return NULL;
    }

    r = ioctl( s, SIOCGIFHWADDR, &ifr );
    if (r == -1) {
        warning("SIOCGIFHWADDR: %m");
        free(dest);
        close(s);
        return NULL;
    }

    hwaddr = ifr.ifr_hwaddr.sa_data;
    sprintf( dest, 13, "%02X%02X%02X%02X%02X%02X",
        hwaddr[0] & 0xFF,
        hwaddr[1] & 0xFF,
        hwaddr[2] & 0xFF,
        hwaddr[3] & 0xFF,
        hwaddr[4] & 0xFF,
        hwaddr[5] & 0xFF);

    close(s);
    return dest;
}
==========================================



Plus d'informations sur la liste de diffusion WiFiDog