📄 dot11smelib.c
字号:
DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIoctl: WIOCSRADIOMODE: Invalid radio " "type \n",0,0,0,0,0,0)); break; } /* Check and see if the channel is in the scanList, which is a list of all channels in the current radio mode */ status = ERROR; for (i=0; i<pDot11->sme->scanList.numChannels; i++) { if (pDot11->sme->scanList.channels[i].channel == pDot11->defaultChannel) { status = OK; break; } } /* If we didn't find the channel, take the lowest channel in the scanList as a default. */ if (status != OK) { pDot11->defaultChannel = pDot11->sme->scanList.channels[0].channel; DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME, ("dot11SmeIoctl: WIOCSRADIOMODE: Channel has been " "changed to %d due to radio mode change. \n" ,pDot11->defaultChannel,0,0,0,0,0)); if (pDot11->dot11Mode != DOT11_MODE_NONE) { if (pDot11->hdd->channelSet(pDot11, pDot11->defaultChannel, pDot11->radioMode) != OK) { DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_INIT, ("dot11SmeIoctl: WIOCSRADIOMODE: Cannot set " "channel %d mode %s\n", pDot11->defaultChannel, (int)dot11ModeStr[pDot11->radioMode], 0,0,0,0)); status = ERROR; break; } } } /* We also need to update the supported rates */ if (pDot11->hdd->suppRatesGet(pDot11, &pDot11->sme->suppRates) != OK) { DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_INIT, ("dot11SmeIoctl: WIOCSRADIOMODE: Cannot init supp " "rates\n", 0,0,0,0,0,0)); status = ERROR; break; } /* Flush the KSL so that we're not using old stations */ (VOID)pDot11->sme->ksl.flush(pDot11); /* Reset the device, if currently in a SME mode */ if ((pDot11->dot11Mode != DOT11_MODE_NONE) && (pDot11->sme->reset != NULL)) { status = pDot11->sme->reset(pDot11); } else { status = OK; } break; /************************************************************** * WIOCSSSID: Sets the current ssid **************************************************************/ case WIOCSSSID: /* We need a pointer in <data>. Make sure it's not NULL */ if ( (char*)data == NULL) { status = ERROR; break; } /* If the current configuration BSS is non-zero, then adjust the SSID belonging to that SSID instead */ if (pDot11->sme->curConfigBss != 0) { strncpy(pBss->currentSsid, (char *)data, DOT11_SSID_LEN); } else { strncpy(pDot11->desiredSsid, (char *)data, DOT11_SSID_LEN); } if ((pDot11->dot11Mode != DOT11_MODE_NONE) && (pDot11->sme->reset != NULL)) { status |= pDot11->sme->reset(pDot11); } break; /************************************************************** * WIOCSCHANNEL - Set channel used **************************************************************/ case WIOCSCHANNEL: status = ERROR; /* Check and see if the channel is in the scanList, which is a list of all channels in the current radio mode */ for (i=0; i<pDot11->sme->scanList.numChannels; i++) { if (pDot11->sme->scanList.channels[i].channel == (int)data) { status = OK; break; } } /* If we didn't find the channel, print an error message */ if (status != OK) { DOT11_LOG(DOT11_DEBUG_INFO, DOT11_AREA_SME, ("dot11SmeIoctl: Regenerating scan list \n", 0,0,0,0,0,0)); /* Build the scan list - we will only scan channels the match the current mode */ if (pDot11->sme->scanListBuild(pDot11) != OK) { status = ERROR; DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIoctl: WIOCSRADIOMODE: Invalid radio " "type \n",0,0,0,0,0,0)); break; } for (i=0; i<pDot11->sme->scanList.numChannels; i++) { if (pDot11->sme->scanList.channels[i].channel == (int)data) { status = OK; break; } } /* If we still didn't find the channel, then it must not exist */ if (status != OK) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIoctl: Channel %d not found \n", (int)data,0,0,0,0,0)); break; } } /* Otherwise set the channel and reset the SME, if applicable */ pDot11->defaultChannel = (UINT32)data; /* We also need to update the supported rates */ if (pDot11->hdd->suppRatesGet(pDot11, &pDot11->sme->suppRates) != OK) { DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_INIT, ("dot11SmeIoctl: Cannot get supp rates\n", 0,0,0,0,0,0)); break; } if ((pDot11->dot11Mode != DOT11_MODE_NONE) && (pDot11->sme->reset != NULL)) { status |= pDot11->sme->reset(pDot11); } break; /************************************************************** * WIOCGLINKSTAT: Returns the current link status **************************************************************/ case WIOCGLINKSTAT: /* We need a pointer in <data>. Make sure it's not NULL */ if ( (char*)data == NULL) { status = ERROR; break; } *(UINT32 *)data = pDot11->sme->linkStatusGet(pDot11, &pDot11->sme->bss[pDot11->sme->curConfigBss] ); status = OK; break; /************************************************************** * WIOCGDESIREDSSID: Returns the desired SSID **************************************************************/ case WIOCGDESIREDSSID: /* We need a pointer in <data>. Make sure it's not NULL */ if ( (char*)data == NULL) { status = ERROR; break; } /* Copy the desired SSID over, making sure to add the NULL terminator */ if (pDot11->desiredSsid == NULL) { *((char *)data) = 0x00; } else { bcopy(pDot11->desiredSsid, (char *)data, min(strlen(pDot11->desiredSsid), DOT11_SSID_LEN) + 1); ((char *)data)[DOT11_SSID_LEN] = 0x00; } status = OK; break; /************************************************************** * WIOCGCONNECTEDSSID: Returns the connected SSID **************************************************************/ case WIOCGCONNECTEDSSID: /* We need a pointer in <data>. Make sure it's not NULL */ if ( (char*)data == NULL) { status = ERROR; break; } /* Copy the desired SSID over, making sure to add the NULL terminator */ if (pBss->currentSsid == NULL) { *((char *)data) = 0x00; } else { bcopy(pBss->currentSsid,(char *)data, min(strlen(pBss->currentSsid), DOT11_SSID_LEN) + 1); ((char *)data)[DOT11_SSID_LEN] = 0x00; } status = OK; break; /******************************************************************** * WIOCGRADIOMODE - ********************************************************************/ case WIOCGRADIOMODE: /* We need a pointer in <data>. Make sure it's not NULL */ if ( (char*)data == NULL) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIoctl: NULL <data> pointer in IOCTL " "0x%04x\n", cmd, 0, 0, 0, 0, 0)); status = ERROR; break; } *(UINT32 *)data = pDot11->radioMode; break; /******************************************************************** * WIOCGDOT11MODE - Returns the current mode of the SME ********************************************************************/ case WIOCGDOT11MODE: /* We need a pointer in <data>. Make sure it's not NULL */ if ( (char*)data == NULL) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIoctl: NULL <data> pointer in IOCTL " "0x%04x\n", cmd, 0, 0, 0, 0, 0)); status = ERROR; break; } *(UINT32 *)data = pDot11->dot11Mode; break; /******************************************************************** * WIOCSDOT11MODE ********************************************************************/ case WIOCSDOT11MODE: /* Check if this is actually a change in mode */ if ((int)data == pDot11->dot11Mode) { /* Do nothing if we're already in this mode */ status = OK; break; } /* Check if the SME is initialized, and if so, deinitialize the old mode */ status = OK; if (pDot11->dot11Mode != DOT11_MODE_NONE) { if ((status = dot11SmeModeStop(pDot11)) != OK) { pDot11->dot11Mode = DOT11_MODE_NONE; status = ERROR; /* Fall through and try to stop the HDD */ } if (((status |= pDot11->hdd->stop(pDot11)) != OK) || (status != OK)) { pDot11->dot11Mode = DOT11_MODE_NONE; status = ERROR; break; } pDot11->dot11Mode = DOT11_MODE_NONE; } pDot11->dot11Mode = (int)data; /* Check if the new mode is supported, and if so, initialize it. If not, return ERROR */ if ((UINT32)data != DOT11_MODE_NONE) { dot11SmeIoctlModeStart(pDot11, pDot11->dot11Mode); } else { /* No sense in starting DOT11_MODE_NONE */ status = OK; } break; /************************************************************** * WIOCGCHANNEL - Get channel used **************************************************************/ case WIOCGCHANNEL: /* We need a pointer in <data>. Make sure it's not NULL */ if ( (char*)data == NULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -