static int p80211wext_giwname(netdevice_t *dev, struct iw_request_info *info, char *name, char *extra) { struct iw_param rate; int result; int err = 0; result = p80211wext_giwrate(dev, NULL, &rate, NULL); if (result) { err = -EFAULT; goto exit; } switch (rate.value) { case 1000000: case 2000000: strcpy(name, "IEEE 802.11-DS"); break; case 5500000: case 11000000: strcpy(name, "IEEE 802.11-b"); break; } exit: return err; }
/* wireless extensions' ioctls */ int p80211wext_support_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) { wlandevice_t *wlandev = (wlandevice_t*)dev->priv; #if WIRELESS_EXT < 13 struct iwreq *iwr = (struct iwreq*)ifr; #endif p80211item_uint32_t mibitem; int err = 0; DBFENTER; mibitem.status = P80211ENUM_msgitem_status_data_ok; if ( wlandev->msdstate != WLAN_MSD_RUNNING ) { err = -ENODEV; goto exit; } WLAN_LOG_DEBUG(1, "Received wireless extension ioctl #%d.\n", cmd); switch (cmd) { #if WIRELESS_EXT < 13 case SIOCSIWNAME: /* unused */ err = (-EOPNOTSUPP); break; case SIOCGIWNAME: /* get name == wireless protocol */ err = p80211wext_giwname(dev, NULL, (char *) &iwr->u, NULL); break; case SIOCSIWNWID: case SIOCGIWNWID: err = (-EOPNOTSUPP); break; case SIOCSIWFREQ: /* set channel */ err = (-EOPNOTSUPP); break; #if 0 if ( (iwf->e == 0) && (iwf->m <= 1000) ) { /* input is a channel number */ chan = iwf->m; } else { /* input is a frequency - search the table */ for (i = 0; i < (6 - iwf->e); i++) mult *= 10; for (i = 0; i < NUM_CHANNELS; i++) if (iwf->m == (prism2wext_channel_freq[i] * mult)) chan = i+1; } /* check for valid channels */ if ((!intval) || (intval > NUM_CHANNELS)) return (-EFAULT); #endif case SIOCGIWFREQ: /* get channel */ err = p80211wext_giwfreq(dev, NULL, &(iwr->u.freq), NULL); break; case SIOCSIWRANGE: case SIOCSIWPRIV: case SIOCSIWAP: /* set access point MAC addresses (BSSID) */ err = (-EOPNOTSUPP); break; case SIOCGIWAP: /* get access point MAC addresses (BSSID) */ err = p80211wext_giwap(dev, NULL, &(iwr->u.ap_addr), NULL); break; #if WIRELESS_EXT > 8 case SIOCSIWMODE: /* set operation mode */ case SIOCSIWESSID: /* set SSID (network name) */ case SIOCSIWRATE: /* set default bit rate (bps) */ err = (-EOPNOTSUPP); break; case SIOCGIWMODE: /* get operation mode */ err = p80211wext_giwmode(dev, NULL, &iwr->u.mode, NULL); break; case SIOCGIWNICKN: /* get node name/nickname */ case SIOCGIWESSID: /* get SSID */ if(iwr->u.essid.pointer) { char ssid[IW_ESSID_MAX_SIZE+1]; memset(ssid, 0, sizeof(ssid)); err = p80211wext_giwessid(dev, NULL, &iwr->u.essid, ssid); if(copy_to_user(iwr->u.essid.pointer, ssid, sizeof(ssid))) err = (-EFAULT); } break; case SIOCGIWRATE: err = p80211wext_giwrate(dev, NULL, &iwr->u.bitrate, NULL); break; case SIOCGIWRTS: err = p80211wext_giwrts(dev, NULL, &iwr->u.rts, NULL); break; case SIOCGIWFRAG: err = p80211wext_giwfrag(dev, NULL, &iwr->u.rts, NULL); break; case SIOCGIWENCODE: if (!capable(CAP_NET_ADMIN)) err = -EPERM; else if (iwr->u.encoding.pointer) { char keybuf[MAX_KEYLEN]; err = p80211wext_giwencode(dev, NULL, &iwr->u.encoding, keybuf); if (copy_to_user(iwr->u.encoding.pointer, keybuf, iwr->u.encoding.length)) err = -EFAULT; } break; case SIOCGIWAPLIST: case SIOCSIWRTS: case SIOCSIWFRAG: case SIOCSIWSENS: case SIOCGIWSENS: case SIOCSIWNICKN: /* set node name/nickname */ case SIOCSIWENCODE: /* set encoding token & mode */ case SIOCSIWSPY: case SIOCGIWSPY: case SIOCSIWPOWER: case SIOCGIWPOWER: case SIOCGIWPRIV: err = (-EOPNOTSUPP); break; case SIOCGIWRANGE: if(iwr->u.data.pointer != NULL) { struct iw_range range; err = p80211wext_giwrange(dev, NULL, &iwr->u.data, (char *) &range); /* Push that up to the caller */ if (copy_to_user(iwr->u.data.pointer, &range, sizeof(range))) err = -EFAULT; } break; #endif /* WIRELESS_EXT > 8 */ #if WIRELESS_EXT > 9 case SIOCSIWTXPOW: err = (-EOPNOTSUPP); break; case SIOCGIWTXPOW: err = p80211wext_giwtxpow(dev, NULL, &iwr->u.txpower, NULL); break; #endif /* WIRELESS_EXT > 9 */ #if WIRELESS_EXT > 10 case SIOCSIWRETRY: err = (-EOPNOTSUPP); break; case SIOCGIWRETRY: err = p80211wext_giwretry(dev, NULL, &iwr->u.retry, NULL); break; #endif /* WIRELESS_EXT > 10 */ #endif /* WIRELESS_EXT <= 12 */ default: err = (-EOPNOTSUPP); break; } exit: DBFEXIT; return (err); }