iwspy and mac address

Shweta Bhandare Shweta.Bhandare at colorado.edu
Thu Jun 20 02:36:23 EST 2002


Hi !

	I have this weird problem am just not able to solve. I am sending you this
code.

	char power[35];
	char mac_addr[18]; /* This has the mac address with the :'s */
	sprintf(power,"iwspy eth0 %s",mac_addr);
	system(power);

	int print_spy_info(int	skfd,
       char *	ifname,
 	       char *   MACAddr)
      {
   struct iwreq		wrq;
   char		buffer[(sizeof(struct iw_quality) +
 			sizeof(struct sockaddr)) * IW_MAX_SPY];
   struct sockaddr 	hwa[IW_MAX_SPY];
   struct iw_quality 	qual[IW_MAX_SPY];
   iwrange	range;
   int		has_range = 0;
   int		n;
   int		i;
   int           count, samples=0;
   int RSSI=0;
   /* Collect stats */

     strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
     wrq.u.data.pointer = (caddr_t) buffer;
     wrq.u.data.length = IW_MAX_SPY;
     wrq.u.data.flags = 0;
     if(ioctl(skfd, SIOCGIWSPY, &wrq) < 0) {
       fprintf(stderr, "%-8.8s  Interface doesn't support wireless statistic
 collection\n\n", ifname);
       return;
     }

     /* Number of addresses */
     n = wrq.u.data.length;
     has_range = 1;

     memcpy(hwa, buffer, n * sizeof(struct sockaddr));
     memcpy(qual, buffer + n*sizeof(struct sockaddr),
 	   n*sizeof(struct iw_quality));

     for(i = 0; i < n; i++) {
       if(strcmp(pr_ether(hwa[i].sa_data),MACAddr)==0) {

 		RSSI=qual[i].level;

    return RSSI;
}

Now, the signal strength is always 0 when i use this code snippet.

However, if i use system("iwspy eth0 128.138.198.91"); instead of the mac
address, I get the correct value of
the signal strength.

Can you please help me out?
Thanks,
Shweta






More information about the wireless mailing list