static int prism2mib_flag(struct mibrec *mib, int isget, struct wlandevice *wlandev, struct hfa384x *hw, struct p80211msg_dot11req_mibset *msg, void *data) { int result; u32 *uint32 = data; u8 bytebuf[MIB_TMP_MAXLEN]; u16 *wordbuf = (u16 *)bytebuf; u32 flags; result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf); if (result == 0) { flags = *wordbuf; if (isget) { *uint32 = (flags & mib->parm2) ? P80211ENUM_truth_true : P80211ENUM_truth_false; } else { if ((*uint32) == P80211ENUM_truth_true) flags |= mib->parm2; else flags &= ~mib->parm2; *wordbuf = flags; result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf); } } return result; }
static int prism2mib_uint32(struct mibrec *mib, int isget, struct wlandevice *wlandev, struct hfa384x *hw, struct p80211msg_dot11req_mibset *msg, void *data) { int result; u32 *uint32 = data; u8 bytebuf[MIB_TMP_MAXLEN]; u16 *wordbuf = (u16 *)bytebuf; if (isget) { result = hfa384x_drvr_getconfig16(hw, mib->parm1, wordbuf); *uint32 = *wordbuf; } else { *wordbuf = *uint32; result = hfa384x_drvr_setconfig16(hw, mib->parm1, *wordbuf); } return result; }
static int prism2sta_getcardinfo(wlandevice_t *wlandev) { int result = 0; hfa384x_t *hw = (hfa384x_t *) wlandev->priv; u16 temp; u8 snum[HFA384x_RID_NICSERIALNUMBER_LEN]; char pstr[(HFA384x_RID_NICSERIALNUMBER_LEN * 4) + 1]; result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICIDENTITY, &hw->ident_nic, sizeof(hfa384x_compident_t)); if (result) { printk(KERN_ERR "Failed to retrieve NICIDENTITY\n"); goto failed; } hw->ident_nic.id = le16_to_cpu(hw->ident_nic.id); hw->ident_nic.variant = le16_to_cpu(hw->ident_nic.variant); hw->ident_nic.major = le16_to_cpu(hw->ident_nic.major); hw->ident_nic.minor = le16_to_cpu(hw->ident_nic.minor); printk(KERN_INFO "ident: nic h/w: id=0x%02x %d.%d.%d\n", hw->ident_nic.id, hw->ident_nic.major, hw->ident_nic.minor, hw->ident_nic.variant); result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRIIDENTITY, &hw->ident_pri_fw, sizeof(hfa384x_compident_t)); if (result) { printk(KERN_ERR "Failed to retrieve PRIIDENTITY\n"); goto failed; } hw->ident_pri_fw.id = le16_to_cpu(hw->ident_pri_fw.id); hw->ident_pri_fw.variant = le16_to_cpu(hw->ident_pri_fw.variant); hw->ident_pri_fw.major = le16_to_cpu(hw->ident_pri_fw.major); hw->ident_pri_fw.minor = le16_to_cpu(hw->ident_pri_fw.minor); printk(KERN_INFO "ident: pri f/w: id=0x%02x %d.%d.%d\n", hw->ident_pri_fw.id, hw->ident_pri_fw.major, hw->ident_pri_fw.minor, hw->ident_pri_fw.variant); result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STAIDENTITY, &hw->ident_sta_fw, sizeof(hfa384x_compident_t)); if (result) { printk(KERN_ERR "Failed to retrieve STAIDENTITY\n"); goto failed; } if (hw->ident_nic.id < 0x8000) { printk(KERN_ERR "FATAL: Card is not an Intersil Prism2/2.5/3\n"); result = -1; goto failed; } hw->ident_sta_fw.id = le16_to_cpu(hw->ident_sta_fw.id); hw->ident_sta_fw.variant = le16_to_cpu(hw->ident_sta_fw.variant); hw->ident_sta_fw.major = le16_to_cpu(hw->ident_sta_fw.major); hw->ident_sta_fw.minor = le16_to_cpu(hw->ident_sta_fw.minor); hw->mm_mods = hw->ident_sta_fw.variant & (BIT(14) | BIT(15)); hw->ident_sta_fw.variant &= ~((u16) (BIT(14) | BIT(15))); if (hw->ident_sta_fw.id == 0x1f) { printk(KERN_INFO "ident: sta f/w: id=0x%02x %d.%d.%d\n", hw->ident_sta_fw.id, hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant); } else { printk(KERN_INFO "ident: ap f/w: id=0x%02x %d.%d.%d\n", hw->ident_sta_fw.id, hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant); printk(KERN_ERR "Unsupported Tertiary AP firmeare loaded!\n"); goto failed; } result = hfa384x_drvr_getconfig(hw, HFA384x_RID_MFISUPRANGE, &hw->cap_sup_mfi, sizeof(hfa384x_caplevel_t)); if (result) { printk(KERN_ERR "Failed to retrieve MFISUPRANGE\n"); goto failed; } hw->cap_sup_mfi.role = le16_to_cpu(hw->cap_sup_mfi.role); hw->cap_sup_mfi.id = le16_to_cpu(hw->cap_sup_mfi.id); hw->cap_sup_mfi.variant = le16_to_cpu(hw->cap_sup_mfi.variant); hw->cap_sup_mfi.bottom = le16_to_cpu(hw->cap_sup_mfi.bottom); hw->cap_sup_mfi.top = le16_to_cpu(hw->cap_sup_mfi.top); printk(KERN_INFO "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_mfi.role, hw->cap_sup_mfi.id, hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom, hw->cap_sup_mfi.top); result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CFISUPRANGE, &hw->cap_sup_cfi, sizeof(hfa384x_caplevel_t)); if (result) { printk(KERN_ERR "Failed to retrieve CFISUPRANGE\n"); goto failed; } hw->cap_sup_cfi.role = le16_to_cpu(hw->cap_sup_cfi.role); hw->cap_sup_cfi.id = le16_to_cpu(hw->cap_sup_cfi.id); hw->cap_sup_cfi.variant = le16_to_cpu(hw->cap_sup_cfi.variant); hw->cap_sup_cfi.bottom = le16_to_cpu(hw->cap_sup_cfi.bottom); hw->cap_sup_cfi.top = le16_to_cpu(hw->cap_sup_cfi.top); printk(KERN_INFO "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_cfi.role, hw->cap_sup_cfi.id, hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom, hw->cap_sup_cfi.top); result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRISUPRANGE, &hw->cap_sup_pri, sizeof(hfa384x_caplevel_t)); if (result) { printk(KERN_ERR "Failed to retrieve PRISUPRANGE\n"); goto failed; } hw->cap_sup_pri.role = le16_to_cpu(hw->cap_sup_pri.role); hw->cap_sup_pri.id = le16_to_cpu(hw->cap_sup_pri.id); hw->cap_sup_pri.variant = le16_to_cpu(hw->cap_sup_pri.variant); hw->cap_sup_pri.bottom = le16_to_cpu(hw->cap_sup_pri.bottom); hw->cap_sup_pri.top = le16_to_cpu(hw->cap_sup_pri.top); printk(KERN_INFO "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_pri.role, hw->cap_sup_pri.id, hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom, hw->cap_sup_pri.top); result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STASUPRANGE, &hw->cap_sup_sta, sizeof(hfa384x_caplevel_t)); if (result) { printk(KERN_ERR "Failed to retrieve STASUPRANGE\n"); goto failed; } hw->cap_sup_sta.role = le16_to_cpu(hw->cap_sup_sta.role); hw->cap_sup_sta.id = le16_to_cpu(hw->cap_sup_sta.id); hw->cap_sup_sta.variant = le16_to_cpu(hw->cap_sup_sta.variant); hw->cap_sup_sta.bottom = le16_to_cpu(hw->cap_sup_sta.bottom); hw->cap_sup_sta.top = le16_to_cpu(hw->cap_sup_sta.top); if (hw->cap_sup_sta.id == 0x04) { printk(KERN_INFO "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_sta.role, hw->cap_sup_sta.id, hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom, hw->cap_sup_sta.top); } else { printk(KERN_INFO "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_sta.role, hw->cap_sup_sta.id, hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom, hw->cap_sup_sta.top); } result = hfa384x_drvr_getconfig(hw, HFA384x_RID_PRI_CFIACTRANGES, &hw->cap_act_pri_cfi, sizeof(hfa384x_caplevel_t)); if (result) { printk(KERN_ERR "Failed to retrieve PRI_CFIACTRANGES\n"); goto failed; } hw->cap_act_pri_cfi.role = le16_to_cpu(hw->cap_act_pri_cfi.role); hw->cap_act_pri_cfi.id = le16_to_cpu(hw->cap_act_pri_cfi.id); hw->cap_act_pri_cfi.variant = le16_to_cpu(hw->cap_act_pri_cfi.variant); hw->cap_act_pri_cfi.bottom = le16_to_cpu(hw->cap_act_pri_cfi.bottom); hw->cap_act_pri_cfi.top = le16_to_cpu(hw->cap_act_pri_cfi.top); printk(KERN_INFO "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id, hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom, hw->cap_act_pri_cfi.top); result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_CFIACTRANGES, &hw->cap_act_sta_cfi, sizeof(hfa384x_caplevel_t)); if (result) { printk(KERN_ERR "Failed to retrieve STA_CFIACTRANGES\n"); goto failed; } hw->cap_act_sta_cfi.role = le16_to_cpu(hw->cap_act_sta_cfi.role); hw->cap_act_sta_cfi.id = le16_to_cpu(hw->cap_act_sta_cfi.id); hw->cap_act_sta_cfi.variant = le16_to_cpu(hw->cap_act_sta_cfi.variant); hw->cap_act_sta_cfi.bottom = le16_to_cpu(hw->cap_act_sta_cfi.bottom); hw->cap_act_sta_cfi.top = le16_to_cpu(hw->cap_act_sta_cfi.top); printk(KERN_INFO "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id, hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom, hw->cap_act_sta_cfi.top); result = hfa384x_drvr_getconfig(hw, HFA384x_RID_STA_MFIACTRANGES, &hw->cap_act_sta_mfi, sizeof(hfa384x_caplevel_t)); if (result) { printk(KERN_ERR "Failed to retrieve STA_MFIACTRANGES\n"); goto failed; } hw->cap_act_sta_mfi.role = le16_to_cpu(hw->cap_act_sta_mfi.role); hw->cap_act_sta_mfi.id = le16_to_cpu(hw->cap_act_sta_mfi.id); hw->cap_act_sta_mfi.variant = le16_to_cpu(hw->cap_act_sta_mfi.variant); hw->cap_act_sta_mfi.bottom = le16_to_cpu(hw->cap_act_sta_mfi.bottom); hw->cap_act_sta_mfi.top = le16_to_cpu(hw->cap_act_sta_mfi.top); printk(KERN_INFO "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id, hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom, hw->cap_act_sta_mfi.top); result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER, snum, HFA384x_RID_NICSERIALNUMBER_LEN); if (!result) { wlan_mkprintstr(snum, HFA384x_RID_NICSERIALNUMBER_LEN, pstr, sizeof(pstr)); printk(KERN_INFO "Prism2 card SN: %s\n", pstr); } else { printk(KERN_ERR "Failed to retrieve Prism2 Card SN\n"); goto failed; } result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR, wlandev->netdev->dev_addr, ETH_ALEN); if (result != 0) { printk(KERN_ERR "Failed to retrieve mac address\n"); goto failed; } wlandev->nsdcaps |= P80211_NSDCAP_SHORT_PREAMBLE; hfa384x_drvr_getconfig16(hw, HFA384x_RID_PRIVACYOPTIMP, &temp); if (temp) wlandev->nsdcaps |= P80211_NSDCAP_HARDWAREWEP; hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFDBMADJUST, &temp); hw->dbmadjust = temp; if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant) < HFA384x_FIRMWARE_VERSION(1, 5, 5)) { wlandev->nsdcaps |= P80211_NSDCAP_NOSCAN; } goto done; failed: printk(KERN_ERR "Failed, result=%d\n", result); done: return result; }
/*---------------------------------------------------------------- * prism2mgmt_scan * * Initiate a scan for BSSs. * * This function corresponds to MLME-scan.request and part of * MLME-scan.confirm. As far as I can tell in the standard, there * are no restrictions on when a scan.request may be issued. We have * to handle in whatever state the driver/MAC happen to be. * * Arguments: * wlandev wlan device structure * msgp ptr to msg buffer * * Returns: * 0 success and done * <0 success, but we're waiting for something to finish. * >0 an error occurred while handling the message. * Side effects: * * Call context: * process thread (usually) * interrupt *---------------------------------------------------------------- */ int prism2mgmt_scan(struct wlandevice *wlandev, void *msgp) { int result = 0; struct hfa384x *hw = wlandev->priv; struct p80211msg_dot11req_scan *msg = msgp; u16 roamingmode, word; int i, timeout; int istmpenable = 0; struct hfa384x_host_scan_request_data scanreq; /* gatekeeper check */ if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant) < HFA384x_FIRMWARE_VERSION(1, 3, 2)) { netdev_err(wlandev->netdev, "HostScan not supported with current firmware (<1.3.2).\n"); result = 1; msg->resultcode.data = P80211ENUM_resultcode_not_supported; goto exit; } memset(&scanreq, 0, sizeof(scanreq)); /* save current roaming mode */ result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFROAMINGMODE, &roamingmode); if (result) { netdev_err(wlandev->netdev, "getconfig(ROAMMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } /* drop into mode 3 for the scan */ result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); if (result) { netdev_err(wlandev->netdev, "setconfig(ROAMINGMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } /* active or passive? */ if (HFA384x_FIRMWARE_VERSION(hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant) > HFA384x_FIRMWARE_VERSION(1, 5, 0)) { if (msg->scantype.data != P80211ENUM_scantype_active) word = msg->maxchanneltime.data; else word = 0; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL, word); if (result) { netdev_warn(wlandev->netdev, "Passive scan not supported with current firmware. (<1.5.1)\n"); } } /* set up the txrate to be 2MBPS. Should be fastest basicrate... */ word = HFA384x_RATEBIT_2; scanreq.tx_rate = cpu_to_le16(word); /* set up the channel list */ word = 0; for (i = 0; i < msg->channellist.data.len; i++) { u8 channel = msg->channellist.data.data[i]; if (channel > 14) continue; /* channel 1 is BIT 0 ... channel 14 is BIT 13 */ word |= (1 << (channel - 1)); } scanreq.channel_list = cpu_to_le16(word); /* set up the ssid, if present. */ scanreq.ssid.len = cpu_to_le16(msg->ssid.data.len); memcpy(scanreq.ssid.data, msg->ssid.data.data, msg->ssid.data.len); /* Enable the MAC port if it's not already enabled */ result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word); if (result) { netdev_err(wlandev->netdev, "getconfig(PORTSTATUS) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } if (word == HFA384x_PORTSTATUS_DISABLED) { __le16 wordbuf[17]; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); if (result) { netdev_err(wlandev->netdev, "setconfig(ROAMINGMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } /* Construct a bogus SSID and assign it to OwnSSID and * DesiredSSID */ wordbuf[0] = cpu_to_le16(WLAN_SSID_MAXLEN); get_random_bytes(&wordbuf[1], WLAN_SSID_MAXLEN); result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFOWNSSID, wordbuf, HFA384x_RID_CNFOWNSSID_LEN); if (result) { netdev_err(wlandev->netdev, "Failed to set OwnSSID.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID, wordbuf, HFA384x_RID_CNFDESIREDSSID_LEN); if (result) { netdev_err(wlandev->netdev, "Failed to set DesiredSSID.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } /* bsstype */ result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, HFA384x_PORTTYPE_IBSS); if (result) { netdev_err(wlandev->netdev, "Failed to set CNFPORTTYPE.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } /* ibss options */ result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CREATEIBSS, HFA384x_CREATEIBSS_JOINCREATEIBSS); if (result) { netdev_err(wlandev->netdev, "Failed to set CREATEIBSS.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } result = hfa384x_drvr_enable(hw, 0); if (result) { netdev_err(wlandev->netdev, "drvr_enable(0) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } istmpenable = 1; } /* Figure out our timeout first Kus, then HZ */ timeout = msg->channellist.data.len * msg->maxchanneltime.data; timeout = (timeout * HZ) / 1000; /* Issue the scan request */ hw->scanflag = 0; result = hfa384x_drvr_setconfig(hw, HFA384x_RID_HOSTSCAN, &scanreq, sizeof(scanreq)); if (result) { netdev_err(wlandev->netdev, "setconfig(SCANREQUEST) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } /* sleep until info frame arrives */ wait_event_interruptible_timeout(hw->cmdq, hw->scanflag, timeout); msg->numbss.status = P80211ENUM_msgitem_status_data_ok; if (hw->scanflag == -1) hw->scanflag = 0; msg->numbss.data = hw->scanflag; hw->scanflag = 0; /* Disable port if we temporarily enabled it. */ if (istmpenable) { result = hfa384x_drvr_disable(hw, 0); if (result) { netdev_err(wlandev->netdev, "drvr_disable(0) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } } /* restore original roaming mode */ result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, roamingmode); if (result) { netdev_err(wlandev->netdev, "setconfig(ROAMMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } result = 0; msg->resultcode.data = P80211ENUM_resultcode_success; exit: msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; return result; }
/*---------------------------------------------------------------- * prism2mgmt_wlansniff * * Start or stop sniffing. * * Arguments: * wlandev wlan device structure * msgp ptr to msg buffer * * Returns: * 0 success and done * <0 success, but we're waiting for something to finish. * >0 an error occurred while handling the message. * Side effects: * * Call context: * process thread (usually) * interrupt *---------------------------------------------------------------- */ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) { int result = 0; struct p80211msg_lnxreq_wlansniff *msg = msgp; struct hfa384x *hw = wlandev->priv; u16 word; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; switch (msg->enable.data) { case P80211ENUM_truth_false: /* Confirm that we're in monitor mode */ if (wlandev->netdev->type == ARPHRD_ETHER) { msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters; return 0; } /* Disable monitor mode */ result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE); if (result) { netdev_dbg(wlandev->netdev, "failed to disable monitor mode, result=%d\n", result); goto failed; } /* Disable port 0 */ result = hfa384x_drvr_disable(hw, 0); if (result) { netdev_dbg (wlandev->netdev, "failed to disable port 0 after sniffing, result=%d\n", result); goto failed; } /* Clear the driver state */ wlandev->netdev->type = ARPHRD_ETHER; /* Restore the wepflags */ result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, hw->presniff_wepflags); if (result) { netdev_dbg (wlandev->netdev, "failed to restore wepflags=0x%04x, result=%d\n", hw->presniff_wepflags, result); goto failed; } /* Set the port to its prior type and enable (if necessary) */ if (hw->presniff_port_type != 0) { word = hw->presniff_port_type; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, word); if (result) { netdev_dbg (wlandev->netdev, "failed to restore porttype, result=%d\n", result); goto failed; } /* Enable the port */ result = hfa384x_drvr_enable(hw, 0); if (result) { netdev_dbg(wlandev->netdev, "failed to enable port to presniff setting, result=%d\n", result); goto failed; } } else { result = hfa384x_drvr_disable(hw, 0); } netdev_info(wlandev->netdev, "monitor mode disabled\n"); msg->resultcode.data = P80211ENUM_resultcode_success; return 0; case P80211ENUM_truth_true: /* Disable the port (if enabled), only check Port 0 */ if (hw->port_enabled[0]) { if (wlandev->netdev->type == ARPHRD_ETHER) { /* Save macport 0 state */ result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFPORTTYPE, &(hw->presniff_port_type)); if (result) { netdev_dbg (wlandev->netdev, "failed to read porttype, result=%d\n", result); goto failed; } /* Save the wepflags state */ result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_CNFWEPFLAGS, &(hw->presniff_wepflags)); if (result) { netdev_dbg (wlandev->netdev, "failed to read wepflags, result=%d\n", result); goto failed; } hfa384x_drvr_stop(hw); result = hfa384x_drvr_start(hw); if (result) { netdev_dbg(wlandev->netdev, "failed to restart the card for sniffing, result=%d\n", result); goto failed; } } else { /* Disable the port */ result = hfa384x_drvr_disable(hw, 0); if (result) { netdev_dbg(wlandev->netdev, "failed to enable port for sniffing, result=%d\n", result); goto failed; } } } else { hw->presniff_port_type = 0; } /* Set the channel we wish to sniff */ word = msg->channel.data; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word); hw->sniff_channel = word; if (result) { netdev_dbg(wlandev->netdev, "failed to set channel %d, result=%d\n", word, result); goto failed; } /* Now if we're already sniffing, we can skip the rest */ if (wlandev->netdev->type != ARPHRD_ETHER) { /* Set the port type to pIbss */ word = HFA384x_PORTTYPE_PSUEDOIBSS; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPORTTYPE, word); if (result) { netdev_dbg (wlandev->netdev, "failed to set porttype %d, result=%d\n", word, result); goto failed; } if ((msg->keepwepflags.status == P80211ENUM_msgitem_status_data_ok) && (msg->keepwepflags.data != P80211ENUM_truth_true)) { /* Set the wepflags for no decryption */ word = HFA384x_WEPFLAGS_DISABLE_TXCRYPT | HFA384x_WEPFLAGS_DISABLE_RXCRYPT; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFWEPFLAGS, word); } if (result) { netdev_dbg (wlandev->netdev, "failed to set wepflags=0x%04x, result=%d\n", word, result); goto failed; } } /* Do we want to strip the FCS in monitor mode? */ if ((msg->stripfcs.status == P80211ENUM_msgitem_status_data_ok) && (msg->stripfcs.data == P80211ENUM_truth_true)) { hw->sniff_fcs = 0; } else { hw->sniff_fcs = 1; } /* Do we want to truncate the packets? */ if (msg->packet_trunc.status == P80211ENUM_msgitem_status_data_ok) { hw->sniff_truncate = msg->packet_trunc.data; } else { hw->sniff_truncate = 0; } /* Enable the port */ result = hfa384x_drvr_enable(hw, 0); if (result) { netdev_dbg (wlandev->netdev, "failed to enable port for sniffing, result=%d\n", result); goto failed; } /* Enable monitor mode */ result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE); if (result) { netdev_dbg(wlandev->netdev, "failed to enable monitor mode, result=%d\n", result); goto failed; } if (wlandev->netdev->type == ARPHRD_ETHER) netdev_info(wlandev->netdev, "monitor mode enabled\n"); /* Set the driver state */ /* Do we want the prism2 header? */ if ((msg->prismheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->prismheader.data == P80211ENUM_truth_true)) { hw->sniffhdr = 0; wlandev->netdev->type = ARPHRD_IEEE80211_PRISM; } else if ((msg->wlanheader.status == P80211ENUM_msgitem_status_data_ok) && (msg->wlanheader.data == P80211ENUM_truth_true)) { hw->sniffhdr = 1; wlandev->netdev->type = ARPHRD_IEEE80211_PRISM; } else { wlandev->netdev->type = ARPHRD_IEEE80211; } msg->resultcode.data = P80211ENUM_resultcode_success; return 0; default: msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters; return 0; } failed: msg->resultcode.data = P80211ENUM_resultcode_refused; return 0; }