good,day
 
I am a newbie to madwifi devel list. i try to develop a routine to access connected station mac address list.
 
that is, if i have a wlan adapter connected to ap, i want the routine to display its mac addr.
 
i know "iwlist ath0 peers" show that, but i am learning to do it myself.
 
here's my code, i have error: "ath0 (WE) : Buffer for request 8B17 too small (0<1)"
 
please help. thanks.
victor
===========================
<.....include files...>
 
#define IW_MAX_AP 8
#define SIOCGIWAPLIST 0x8B17
#define IFNAMSIZ 10
 
struct iw_point
{
        caddr_t pointer;
        int length;
        int flags;
};
 
union iwreq_data
{
        char name[IFNAMSIZ];
        struct iw_point data;
};
 
struct iwreq
{
        char ifr_name[IFNAMSIZ];
 
        union iwreq_data u;
};
void main()
{
 int i, n, sock;
  in t ret_val;
char    temp[128];
 char  buffer[(4 + sizeof(struct sockaddr))*IW_MAX_AP];
 struct sockaddr *     hwa;
 struct iwreq          wrq;
 struct ether_addr     *eth;
 
sock = socket(AF_INET, SOCK_DGRAM, 0);
 if (sock < 0)
{
printf("error\n");
return;
}
 
wrq.u.data.pointer = (caddr_t) buffer;
 wrq.u.data.length = IW_MAX_AP;
 wrq.u.data.flags = 0;
 strncpy(wrq.ifr_name, "ath0", IFNAMSIZ);
ret_val = ioctl(sock,SIOCGIWAPLIST, &wrq);
 if (ret_val < 0)
{
printf("error\n");
}
 
 n = wrq.u.data.length;
 hwa = (struct sockaddr *) buffer;
 for (i=0; i<n; i++)
{
eth = (struct ether_addr *)hwa[i].sa_data;
sprintf(temp, "%02X.%02X.%02X.%02X.%02X.%02X",eth->ether_addr_octet[0],
eth->ether_addr_octet[1],
eth->ether_addr_octet[2],
eth->ether_addr_octet[3],
eth->ether_addr_octet[4],
eth->ether_addr_octet[5]);
 
printf("%s\n",temp);
  }
 
close(sock);
 return;
}