📄 cisaironetioctl.c
字号:
if (data == NULL) { status = EINVAL; break; } /* Get the SSID from the status Rid */ if ( cisAironetHwRidStatusGet (pDev, (void *) pStatus) == ERROR ) { status = EINVAL; break; } /* Save the ssid name to the data buffer */ (void) cisAironetBcopy (pDev, (UINT8 *) pStatus->SSID, (UINT8 *) data, pStatus->SSIDlen); *((char *)data + pStatus->SSIDlen) = 0x00; break; } /* Get the connected SSID or network name, i.e. 'WlanNetwork1' */ case EIOCGCONNECTEDSSID: { STATUS_RID_T sts; STATUS_RID_T * pStatus = (STATUS_RID_T *) &sts; /* sanity check */ if (data == NULL) { status = EINVAL; break; } /* Get the current link status from the card. If we */ /* are not connected, return nothing */ linkStatus = cisAironetHwLinkStatusGet(pDev); if (linkStatus != 0x400) /* disconnected state */ { *(char *)data = 0x00; break; } /* Get the SSID from the status Rid */ if ( cisAironetHwRidStatusGet (pDev, (void *) pStatus) == ERROR ) { status = EINVAL; break; } /* Save the ssid name to the data buffer */ (void) cisAironetBcopy (pDev, (UINT8 *) pStatus->SSID, (UINT8 *) data, pStatus->SSIDlen); *((char *)data + pStatus->SSIDlen) = 0x00; break; } /* Set the current network name (SSID) */ case EIOCSSSID: { SSID_RID_T ssid; SSID_RID_T * pSSID = (SSID_RID_T *) &ssid; /* sanity check */ if (data == NULL) { status = EINVAL; break; } /* Get the current SSID list */ if ( cisAironetHwRidSSIDGet (pDev, (void *) pSSID) == ERROR ) { status = EINVAL; break; } /* Clear the buffer */ (void) memset (pSSID, 0, sizeof (SSID_RID_T)); /* save the ssid name to the RID */ (void) cisAironetBcopy (pDev, (UINT8 *) data, (UINT8 *) pSSID->ssids[0].ssid, strlen (data) ); /* Save the length of the name */ pSSID->ssids[0].len = strlen ( (INT8 *) data); /* Disable the mac */ (void) cisAironetHwMacDisable (pDev); /* Save the list to the RID */ if ( cisAironetHwRidSSIDSet (pDev, (void *) pSSID) == ERROR ) { status = EINVAL; break; } /* copy the new station name to the driver */ (void) cisAironetBcopy (pDev, (UINT8 *) data, (UINT8 *) pDev->networkName, strlen ( (INT8 *) data)); *((char *)pDev->networkName + strlen ( (INT8 *) data)) = 0x00; /* Re-enable the mac */ (void) cisAironetHwMacEnable (pDev); /* Start rescanning for the AP with the BSSID */ (void) cisAironetHwScanStart (pDev); break; } /* Get the current BSSID (Mac address of AP) */ case EIOCGCONNECTEDBSSID: { STATUS_RID_T sts; STATUS_RID_T * pStatus = (STATUS_RID_T *) &sts; /* sanity check */ if (data == NULL) { status = EINVAL; break; } /* clear the buffer */ (void) memset (pStatus, 0, sizeof (STATUS_RID_T)); /* Get the SSID Rid */ if ( cisAironetHwRidStatusGet (pDev, (void *) pStatus) == ERROR ) { status = EINVAL; break; } /* Save the ssid name to the data buffer */ (void) cisAironetBcopy ( pDev, (UINT8 *) pStatus->currentBssID, (UINT8 *) data, 6); break; } /* Get the current station name */ case EIOCGSTNNAME: { CFG_RID_T cfg; CFG_RID_T * pCfg = (CFG_RID_T *) &cfg; /* sanity check */ if (data == NULL) { status = EINVAL; break; } /* Get the SSID Rid */ if ( cisAironetHwRidActualConfigGet (pDev, (void *) pCfg) == ERROR ) { status = EINVAL; break; } /* Save the station name to the data buffer */ (void) cisAironetBcopy ( pDev, (UINT8 *) pCfg->nodeName, (UINT8 *) data, strlen ( (char *) pCfg->nodeName) ); *((char *)data + strlen((char *) pCfg->nodeName)) = 0x00; break; } /* Set the station name */ case EIOCSSTNNAME: { CFG_RID_T cfg; CFG_RID_T * pCfg = (CFG_RID_T *) &cfg; /* sanity check */ if (data == NULL) { status = EINVAL; break; } /* disable the MAC */ if ( cisAironetHwMacDisable (pDev) == ERROR ) { status = EINVAL; break; } /* Get the Cfg Rid */ if ( cisAironetHwRidActualConfigGet (pDev, (void *) pCfg) == ERROR ) { status = EINVAL; break; } /* clear the node name member */ (void) memset (pCfg->nodeName, 0, NELEMENTS(pCfg->nodeName)); /* Save the station name to the data buffer */ (void) cisAironetBcopy ( pDev, (UINT8 *) data, (UINT8 *) pCfg->nodeName, strlen ( (INT8 *) data) ); /* Commit the new station name */ if ( cisAironetHwRidConfigSet (pDev, (void *) pCfg) == ERROR ) { status = EINVAL; break; } /* copy the new station name to the driver */ (void) cisAironetBcopy ( pDev, (UINT8 *) data, (UINT8 *) pDev->stationName, strlen ( (INT8 *) data)); *((char *)pDev->stationName + strlen((char *)data)) = 0x00; /* re-enable the MAC */ if ( cisAironetHwMacEnable (pDev) == ERROR ) { status = EINVAL; } break; } /* Get the power management state */ case EIOCGPWRMAN: { /* sanity check */ if (data == NULL) { status = EINVAL; break; } /* retun the current power save mode */ * (UINT16 *) data = (UINT16) pDev->powerSave; break; } /* Set the power managment state */ case EIOCSPWRMAN: { BOOL pmState = (BOOL) data; /* Which state to set the card - ON or OFF */ if (pmState == TRUE) { /* Set the card into PSP (Power Save Protocol) */ if (cisAironetHwPwrModeSet (pDev, ANET_POWERSAVE_PSP) == ERROR) { status = EINVAL; } } else { /* Set the card into CAM (Constant Awake Mode) */ if (cisAironetHwPwrModeSet (pDev, ANET_POWERSAVE_CAM) == ERROR) { status = EINVAL; } } break; } /* Turn promiscious mode on or off */ case EIOCSPROMISC: { BOOL promState = (BOOL) data; /* Set the card mode */ if (promState) { /* promiscious mode enabled */ if ( cisAironetHwModeSet (pDev, ANET_PROMISC) == ERROR) { status = EINVAL; } } else { /* promiscious mode disabled */ if ( cisAironetHwModeSet (pDev, (UINT16) ~ANET_PROMISC) == ERROR) { status = EINVAL; } } break; } /* Get Communications Quality */ case EIOCGCOMMQUAL: { /* Get the status Rid */ STATUS_RID_T stat; STATUS_RID_T * pStatus = (STATUS_RID_T *) &stat; /* sanity check */ if (data == NULL) { status = EINVAL; break; } linkStatus = cisAironetHwLinkStatusGet(pDev); if (linkStatus != 0x400) /* disconnected state */ { * (UINT16 *) data = 0; /* report 0 sig strength */ break; } else { /* Get the card status Rid */ if ( cisAironetHwRidStatusGet (pDev, (void *) pStatus) == ERROR ) { status = EINVAL; printf("cisAironetHwIoctlExt: rid status get EINVAL\n"); break; } /* Save the current card signal strength */ * (UINT16 *) data = pStatus->sigQuality; break; } } /* Return the card type */ case EIOCGCARDTYPE: { /* sanity check */ if (data == NULL) { status = EINVAL; break; } /* Return the card type */ * (UINT16 *) data = (UINT16) WLAN_CARDTYPE_CISCO; break; } /* Return the wep status */ case EIOCGWEPAVAIL: { /* sanity check */ if (data == NULL) { status = EINVAL; break; } /* yes, this card does support wep */ * (UINT16 *) data = (UINT16)TRUE; break; } /* return the current card wep state - enabled or not enabled */ case EIOCGWEPSTATUS: { /* sanity check */ if (data == NULL) { status = EINVAL; break; } /* set the card wep state */ * (UINT16 *) data = (UINT16)pDev->wepEnable; break; } /* Enable or disable wep */ case EIOCSWEP: { BOOL wepEnable = FALSE; CFG_RID_T cfg; CFG_RID_T * pCfg = (CFG_RID_T *) &cfg; /* Get the desired wep state */ wepEnable = (BOOL) data; /* Get the Cfg Rid */ if ( cisAironetHwRidActualConfigGet (pDev, (void *) pCfg) == ERROR ) { status = EINVAL; break; } /* set Wep on true else disable */ if (wepEnable == TRUE) { /* Enable Wep */ cfg.authType |= ANET_WEP_ENABLE; } else { cfg.authType &= ~ANET_WEP_ENABLE; } /* disable the MAC */ if ( cisAironetHwMacDisable (pDev) == ERROR ) { status = EINVAL; break; } /* Save the config rid */ (void) cisAironetHwRidConfigSet (pDev, (void *) pCfg); /* Re-enable the mac */ if ( cisAironetHwMacEnable (pDev) == ERROR ) { status = EINVAL; break; } /* Save the current wep state */ pDev->wepEnable = wepEnable; break; } /* Set a wep key */ case EIOCSWEPKEY0: case EIOCSWEPKEY1: case EIOCSWEPKEY2: case EIOCSWEPKEY3: {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -