/* Note : we can't use iw_enum_devices() because we want a different behaviour : 1) Stop at the first valid wireless device 2) Only go through active devices  */
static int scan_devices(int skfd, int format, int wtype)
/* Note : we can't use iw_enum_devices() because we want a different behaviour : 1) Stop at the first valid wireless device 2) Only go through active devices  */
static int scan_devices(int skfd, int format, int wtype)
{
  char		buff[1024];
  struct ifconf ifc;
  struct ifreq *ifr;
  int		i;
  ifc.ifc_len = sizeof(buff);
  ifc.ifc_buf = buff;
  if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
    {
      perror("SIOCGIFCONF");
      return(-1);
    }
  ifr = ifc.ifc_req;
  for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
    {
      if(print_one_device(skfd, format, wtype, ifr->ifr_name) >= 0)
	return 0;
    }
  return(-1);
}