I think I have finally figured out how to do my noise measurements I talked about on the dev list some time ago. However, now I am having trouble compiling my program. Could someone help me come up a command to do this or help out with a makefile?

Here is an example of what I would like to see (as far as usage goes) plus the relevant code:

$show-noise ath0
Channel: 1     2     3    4   ...
             -95  -94  -80  -96 ...

/* show-noise.c - written by Justin Hadella 11/18/2008 */

#include <stdio.h>
#include <string.h>

#include <linux/netdevice.h>    /* struct net_device, dev_get_by_name()            */
#include "../ath/if_athvar.h"    /* struct ath_softc, ath_hal_get_channel_noise()    */
#include "../hal/ah.h"        /* struct ath_hal, struct HAL_CHANNEL            */

/* Note: device "ath0" uses channels 1-11    (2.4 GHz radio)        */    
/*       device "ath1" uses channels 3-6    (900 MHz radio)        */

int main(int argc, char **argv)
{
    struct net_device *dev;
    struct ath_softc *sc;
    struct ath_hal *ah;
    struct HAL_CHANNEL channel;
    int i;
    int noise[11];
    /*  stock data for testing the print capability */
    /*
    int noise[11] = { -96, -95, -96, -84, -95, -96, -95, -95, -94, -92, -95 };
    */

    /* initialize device */
    /*
    
    /* get pointer to device from device name (ie "ath0") */    
    dev = dev_get_by_name(argv[1]);    

    /* code like this used throughout madwifi to get the ah structure */
    sc = dev->priv;
    ah = sc->sc_ah;

    i = ath_hal_get_channel_noise(ah, &channel);
    printf("%d\n", i);
    
    /* get noise values for each channel */
    for (i = 0; i <= 10; i++)
    {
        channel.channel = i + 1;
        noise[i] = ath_hal_get_channel_noise(ah, &channel);
    }        

    /* print out what was measured */
    printf("Channel: ");
    for (i = 0; i <= 10; i++)
    {
        printf("%5d ", i + 1);
    }
    printf("\n  Noise: ");

    for (i = 0; i <= 10; i++)
    {
        printf("%5d ", noise[i]);
    }
    printf("dBm\n");
    
    return 0;
}

I am having trouble getting this to compile. The errors I am seeing have to do with various things in if_athvar.h and ah.h files. However, I have no trouble compiling madwifi itself. So I don't know what to do. 

I do not know if I have to go the whole device driver type route, or if this simple program would do.