📄 dot11smelib.c
字号:
pDot11->sme->disassocSend = dot11SmeDisassocSend; pDot11->sme->assocReqSend = dot11SmeAssocReqSend; pDot11->sme->assocRspSend = dot11SmeAssocRspSend; pDot11->sme->probeReqSend = dot11SmeProbeReqSend; /* Init some utility functions that also work regardless of what SME type is initialized */ pDot11->sme->bssScanDo = dot11SmeBssScanDo; pDot11->sme->linkStatusGet = dot11SmeLinkStatusGet; pDot11->sme->scanListBuild = dot11SmeScanListBuild; pDot11->sme->linkStatusGet = dot11SmeLinkStatusGet; /* Hook up the IOCTL routines so we can manage this */ pDot11->sme->endIoctl = dot11SmeIoctl; pDot11->sme->smeCommonIoctl = dot11SmeCommonIoctl; pDot11->sme->endMCastAddrGet = dot11SmeMCastAddrGet; pDot11->sme->endMCastAddrAdd = dot11SmeMCastAddrAdd; pDot11->sme->endMCastAddrDel = dot11SmeMCastAddrDel; /* Change the link status appropriately */ for (i=0; i<DOT11_BSS_MAX; i++) { pDot11->sme->bss[i].linkStatus = DOT11_LINK_DOWN; } return OK; }/***************************************************************************** dot11SmeIoctl - Main ICOTL call for the DOT11 Framework ** This routine passes calls to the IOCTL subsystem to the two locations where* IOCTL statements are processed. The first is the SME specific IOCTL, which* is initialized in the SME specific init routine. The second is the SME * agnostic IOCTL routine, dot11SmeCommonIoctl() in this file. That routine* handles all generic IOCTL calls that don't care what dot11Mode the device is* in.** RETURNS: OK, ERROR, or EINVAL if IOCTL not found* * ERRNO: N/A*/LOCAL int dot11SmeIoctl ( END_OBJ* pEnd, /* Pointer to END_OBJ */ unsigned int cmd, /* IOCTL command */ caddr_t data /* Generic data pointer */ ) { DOT11_FW * pDot11; STATUS status = EINVAL; pDot11 = (DOT11_FW *)pEnd; if ((pEnd == NULL) || (pDot11->sme == NULL)) { DOT11_LOG(DOT11_DEBUG_FATAL, DOT11_AREA_SME, ("dot11SmeIoctl: NULL pEnd\n", 0, 0, 0, 0, 0, 0)); return ERROR; } /* First, call the SME specific IOCTL routine to allow the SME specialization routine to override any of the Common IOCTLs if it wishes */ if (pDot11->sme->smeSpecificIoctl != NULL) { status = pDot11->sme->smeSpecificIoctl(pDot11, cmd, data); } /* If the above call did not find the IOCTL (indicated by a return of EINVAL) then call the common IOCTL routine to see if it can find the routine */ if ((pDot11->sme->smeCommonIoctl != NULL) && (status == EINVAL)) { status = pDot11->sme->smeCommonIoctl(pDot11, cmd, data); } return status; }/***************************************************************************** dot11SmeCommonIoctl - The SME agnostic IOCTL routine** This routine is called when the SME specific IOCTL routine failed to handle* a command. It deals with parameters associated with the SME as a whole, * rather than the specific SME modes.** RETURNS: OK, ERROR, EINVAL** ERRNO: N/A*/LOCAL int dot11SmeCommonIoctl ( DOT11_FW * pDot11, /* Ptr to dot11 framework */ unsigned int cmd, /* IOCTL command */ caddr_t data /* Generic data pointer */ ) { END_OBJ * pEnd = (END_OBJ *)pDot11; /* The END_OB is the first item */ int value, oldFlags; /* Temp variable */ STATUS status = OK; /* Return value */ int i; /* generic loop variable */ DOT11_KSL_ENTRY * pKsl; UINT32 oldMode,oldCountry; M2_PHYADDRSET phyAddr; DOT11_BSS * pBss; /* Sanity check not needed, since this is only called from dot11SmeEndIoctl() */ pBss = &pDot11->sme->bss[pDot11->sme->curConfigBss]; switch(cmd) { /******************************************************************** * EIOCSADDR - Set the MAC addr ********************************************************************/ case EIOCSADDR: if (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; } /* The current SME and HDD modes need to be shut down when changing the MAC address to prevent sync issues */ 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; } } DOT11_ADDR_COPY((char *)data, (char *)pDot11->macAddr); DOT11_ADDR_COPY((char *)data, (char *)pDot11->endObj.mib2Tbl.ifPhysAddress.phyAddress); /* Change the value in the M2 interface */ phyAddr.pAddress = (unsigned char *)data; phyAddr.addrLength = DOT11_ADDR_LEN; MIB_VAR_UPDATE(pDot11->endObj.pMib2Tbl, M2_varId_ifPhysAddress, (caddr_t)&phyAddr); /* Notify the hardware of the change */ if (pDot11->hdd->macAddrChange(pDot11, (UINT8 *)data) != OK) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIoctl: EIOCSADDR: Error changing" " MAC address to " DOT11_MAC_ADDR_STR "\n", DOT11_MAC_ADDR((UINT8 *)data))); status = ERROR; } /* Restart the mode with the changed MAC Address */ if (pDot11->dot11Mode != DOT11_MODE_NONE) { dot11SmeIoctlModeStart(pDot11, pDot11->dot11Mode); } else { /* No sense in starting DOT11_MODE_NONE */ status = OK; } break; /******************************************************************** * EIOCGADDR - Get the MAC addr ********************************************************************/ case WIOCGMAC: /* Fall through */ case EIOCGADDR: if (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; } bcopy((char *)(pEnd)->mib2Tbl.ifPhysAddress.phyAddress, (char *)data, (pEnd)->mib2Tbl.ifPhysAddress.addrLength); status = OK; break; /******************************************************************** * EIOCSFLAGS - Set device flags ********************************************************************/ case EIOCSFLAGS: value = (long)data; oldFlags = END_FLAGS_GET(pEnd); /* A negative flag means remove the flag */ if (value < 0) { value --; value = -value; /* Convert from two's complement */ END_FLAGS_CLR (pEnd, value); } else { END_FLAGS_SET (pEnd, value); } /* Check if the IFF_ALLMULTI bit has changed */ if (((oldFlags ^ END_FLAGS_GET(pEnd)) & IFF_ALLMULTI) != 0) { if (((UINT32)data & IFF_ALLMULTI) != 0) { pDot11->hdd->multicastAddressAdd(pDot11, NULL); } else { pDot11->hdd->multicastAddressDel(pDot11, NULL); } } status = OK; break; /******************************************************************** * EIOCGFLAGS - return the current value of device flags ********************************************************************/ case EIOCGFLAGS: /* Retrieve device flags */ if (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; } *(int *)data = END_FLAGS_GET(pEnd); break; /******************************************************************** * EIOCPOLLSTART: Begin polled operation ********************************************************************/ case EIOCPOLLSTART: status = ERROR; break; /******************************************************************** * EIOCPOLLSTOP: Stop polled operation ********************************************************************/ case EIOCPOLLSTOP: status = ERROR; break; /******************************************************************** * EIOCGMIB2: Get SNMPv2 device statistics ********************************************************************/ case EIOCGMIB2: if (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; } bcopy((char *)(&pEnd->mib2Tbl), (char *)data, sizeof(pEnd->mib2Tbl)); break; /******************************************************************** * EIOCGFBUF - returns the minimum first buffer size for chaining ********************************************************************/ case EIOCGFBUF: if (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; } /* the minimum first buffer size is that of the DOT11HEADER and the SNAP HEADER */ *(int *)data = sizeof(DOT11_HEADER) + DOT11_SNAP_HEADER_LEN; status = OK; break; /******************************************************************** * EIOCGHDRLEN: The length of header data, as passed to the stack ********************************************************************/ case EIOCGHDRLEN: if (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; } *(int *)data = 2 * DOT11_ADDR_LEN + sizeof(UINT16); status = OK; break; /******************************************************************** * WIOCSRADIOMODE - Sets the current radio mode ********************************************************************/ case WIOCSRADIOMODE: if ((UINT32)data > DOT11_RADIO_MAX) { DOT11_LOG(DOT11_DEBUG_ERROR, DOT11_AREA_SME, ("dot11SmeIoctl: WIOCSRADIOMODE: Invalid radio " "type \n", 0,0,0,0,0,0)); status = ERROR; break; } pDot11->radioMode = (UINT32)data; /* Build the scan list - we will only scan channels the match the current mode */ if (pDot11->sme->scanListBuild(pDot11) != OK) { status = ERROR;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -