📄 intprismhostap.c
字号:
" Intersil Prism 2 / 2.5 / 3 chipsets\n")); return ERROR; } pWlanDev->cardStatus = WLAN_STATUS_DOWN; /* Allocate and initialize the host Ap structure for our station */ if ((pWlanHostAp = (WLAN_HOST_AP * )calloc (1, sizeof(WLAN_HOST_AP)) ) == NULL) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismHostAp: Error allocating host ap " "structure")); return ERROR; } /* NULL out the known STA list */ for (i=0; i<WLAN_HOST_AP_NUM_HASH; i++) pWlanHostAp->pWlanSta[i] = NULL; /* The BSSID is the MAC address of the intPrism card used for the ap */ bcopy ((char *) pWlanDev->MACAddr, (char *) pWlanHostAp->bssid, WLAN_ENET_ADDR_LEN); /* Ensure we have a valid SSID and channel*/ if ((ssid == NULL) || (ssid[0] == 0x00)) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismHostAp: Cannot create BSS - " "NULL SSID\n")); free(pWlanHostAp); pWlanHostAp = NULL; return ERROR; } /* Verify that the selected channel is valid in the set region */ sysWlanCfgParamGet(WLAN_REGION, (INT32)®ion); if (( (1 << (channel-1)) & region) == 0) { WLAN_DEBUG(DEBUG_ERROR, ("intPrismHostAp: Channel %d is not " "allowed in this regulatory region\n", (INT32)channel)); free(pWlanHostAp); pWlanHostAp = NULL; return ERROR; } pWlanHostAp->hostEncrypt = TRUE; pWlanHostAp->hostDecrypt = FALSE; pWlanHostAp->bcastRate = 2 * INTERSIL_1_MBIT; pWlanHostAp->channel = channel; pWlanHostAp->lastAID = 0; pWlanHostAp->wepEnable = FALSE; pWlanHostAp->authTime = WLAN_HOST_AP_AUTH_TIME; pWlanHostAp->activeTime = WLAN_HOST_AP_ACTIVE_TIME; pWlanDev->txBlocked = FALSE; pWlanHostAp->authType = WLAN_AUTHENTICATION_ANY; pWlanHostAp->numPM = 0; pWlanHostAp->pDev = pWlanDev; /* Fill these guys in later, in intPrismHostApBridgeOn() */ pWlanHostAp->pWiredCookie = NULL; pWlanHostAp->pWirelessCookie = NULL; /* Add in our own IOCTL routine ! */ pWlanHostAp->pIoctl = pWlanDev->pIoctl; pWlanDev->pIoctl = (FUNCPTR)intPrismHostApIoctl; /* NULL out access control list */ pWlanHostAp->pWlanAC = NULL; strncpy(pWlanHostAp->ssid, ssid, WLAN_BSS_NAME_MAX); /* Since strncpy does not null-terminate if strlen(source) >= max_num we'll just null-terminate it to be sure */ pWlanHostAp->ssid[ min(WLAN_BSS_NAME_MAX, strlen(ssid))] = 0x00; /* OK. We need to hijack the ISR, and put our own routine in place and add out own send routines and stuff. Wlan stop will disable the card and disable the interrupt, but we need to disconnect on our own, since we don't want to de-allocate the driver*/ intPrismStop ((END_OBJ *)pWlanDev); WLAN_INT_DISCONNECT(pWlanDev->iVec, (INT32)(FUNCPTR)intPrismInt, (int)pWlanDev, &result); /* start the INFO fid read task - it will block while it waits on a semaphore given by the ISR whenever an INFO event is detected. NOTE: this scheme may result in INFO events being missed, but the cost of moving the logic outside the ISR is deemed necessary in order to speed up the ISR */ semInfoFidRead = semBCreate(SEM_Q_FIFO, SEM_EMPTY); if (semInfoFidRead == NULL) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismHostAp: could not create INFO Fid " "Release semaphore\n")); return ERROR; } if ( (tInfoFidRead = taskSpawn("tInfoFidRead", infoFidReadPriority, 0, 1024, (FUNCPTR) intPrismHostApInfoFidRead, 0,0,0,0,0,0,0,0,0,0)) == ERROR) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismHostAp: could not spawn task tInfoFidRead\n")); return ERROR; } /* Now we attach our own ISR, and change the END table to put in our own functions */ pWlanDev->endObj.pFuncTable = &intPrismHostApFuncTable; /* Check and control the length of the description string. */ if (strlen(pDescription) > sizeof(pWlanDev->endObj.devObject.description)) pDescription[sizeof(pWlanDev->endObj.devObject.description - 1)] = 0x00; strcpy (pWlanDev->endObj.devObject.description, pDescription); WLAN_INT_CONNECT(pWlanDev->iVec, (INT32)(FUNCPTR)intPrismHostApInt, (int)pWlanDev,&result); /* Now we're ready to begin putting the card into Host-based AP mode.*/ pWlanDev->cardMode = WLAN_CARDMODE_HOST_AP; /* Make sure that promiscuous mode is not enabled */ intPrismRIDWordWrite(pWlanDev, WLAN_RID_PROMISC, 0); /* Set card into "host ap mode". Takes effect next time card is enabled*/ intPrismRIDWordWrite(pWlanDev, WLAN_RID_PORT_TYPE, WLAN_PORT_HOST_AP); /* Set the channel and SSID. We should really verify the channel using a channelList, but that can come later */ intPrismRIDWordWrite(pWlanDev, WLAN_RID_OWN_CHANNEL, channel); intPrismRIDStringWrite(pWlanDev, WLAN_RID_OWN_SSID, ssid); intPrismRIDStringWrite(pWlanDev, WLAN_RID_STATION_NAME, "Wind River Systems Host AP"); sysWlanCfgParamGet(WLAN_BRATES_ENABLE, (INT32)&brate); if (brate == WLAN_BRATES_ENABLED) { sysWlanCfgParamGet(WLAN_BRATES, (INT32)&brate); intPrismRIDWordWrite(pWlanDev, INTERSIL_RID_BASIC_RATES, brate); } /* WEP Setup: Re-set up WEP, since configuration settings were lost when setting up HAP */ /* Get the encryption mode */ (void) sysWlanCfgParamGet (WLAN_WEP_TYPE, (INT32) &wepType); (void) sysWlanCfgParamGet (WLAN_WEP_ENABLE, (INT32) &wepEnable); /* Check to see if we need to enable security. In some environments this may be necessary to boot */ if (wepEnable == TRUE) { status = OK; if (wepType == WLAN_WEP_TYPE_64) { for (i=0; i< WLAN_WEP_NUM_KEYS; i++) { sysWlanCfgParamGet(WLAN_WEP_KEY0_64 + i, (INT32)wepKey); intPrismIoctl((END_OBJ *)pWlanDev, EIOCSWEPKEY0 + i, (caddr_t)wepKey); } } else if (wepType == WLAN_WEP_TYPE_128) { sysWlanCfgParamGet(WLAN_WEP_KEY0_128, (INT32)wepKey); intPrismIoctl((END_OBJ *)pWlanDev, EIOCSWEPKEY0, (caddr_t)wepKey); } else { WLAN_DEBUG(DEBUG_ERROR, ("intPrismHostAp: Bad wep type\n")); status = ERROR; } /* Get the default wep key number */ (void) sysWlanCfgParamGet (WLAN_WEP_KEY_NUMBER, (INT32) &wepKeyNumber); status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCSWEPDEFAULTKEY, (caddr_t)(INT32)wepKeyNumber); status |= intPrismIoctl((END_OBJ *)pWlanDev, EIOCSWEP, (caddr_t)1); if (status != OK) { WLAN_DEBUG(DEBUG_ERROR, ("intPrismHostAp: Error - Security cannot " "be enabled\n")); return ERROR; } else { WLAN_DEBUG(DEBUG_ERROR, ("intPrismHostAp: Security Enabled!!!\n")); } } pWlanDev->pRxTail = NULL; pWlanDev->pRxHead = NULL; /* The watchdog and the keepalive thread are fixes for SPR 89388, where the card firmware freezes occasionally */ pWlanHostAp->txSemWd= wdCreate(); taskSpawn("tWlanTXGuard", 51, 0, 3000, (FUNCPTR)intPrismKeepTxAlive, (int)pWlanDev,0,0,0,0,0,0,0,0,0); /* Call thge start routine manually, since this isn't a normal END device initialization */ intPrismHostApStart((END_OBJ *)pWlanDev); /* The basic bridge is only started when the "wiredIf" field is non-null*/ if ((wiredIf != NULL) && (wiredIf[0] != 0x00)) { /* Start the primitive bridging unit */ intPrismBridgeOn(wirelessIf, wirelessIfnum, wiredIf, wiredIfnum ); } WLAN_DEBUG(DEBUG_FATAL, ("Host based access point enabled. SSID = %s," " channel = %d\n", ssid, channel)); return OK; }/***************************************************************************** intPrismHostApStaShow - Show routine for known station list** Prints out a list of all known stations, their last transmit speed, the * authentication and association status of the STA, their Association ID if* applicable (0 if not), and their power management status.* * RETURNS: OK or ERROR** ERRNO: N/A*/STATUS intPrismHostApStaShow() { WLAN_STA *pBug; int i; printf("Total number of hosts using Power Management = %d\n", pWlanHostAp->numPM); printf("List of hosts known to Access Point %s (BSSID " MAC_ADDR_STRING ")\n", pWlanHostAp->ssid, pWlanHostAp->bssid[0], pWlanHostAp->bssid[1],pWlanHostAp->bssid[2],pWlanHostAp->bssid[3], pWlanHostAp->bssid[4],pWlanHostAp->bssid[5]); for (i=0; i<WLAN_HOST_AP_NUM_HASH; i++) { pBug = pWlanHostAp->pWlanSta[i]; while (pBug != NULL) { printf(" " MAC_ADDR_STRING "\n", MAC_ADDR(pBug->MACAddr)); printf(" %s %s\n", (pBug->authStatus==TRUE)?"Authenticated":"Not Auth", (pBug->assocStatus==TRUE)?"Associated":"Not Assoc"); printf(" Rate : %d Mb/s\n", pBug->lastTxRate / 10); /* Only print AID if associated */ if (pBug->assocStatus == TRUE) { printf(" AID : %d\n", pBug->assocId & WLAN_HOST_AP_AID_MASK); } if (wdGetTimeLeft(pBug->timeoutWd) != 0) { printf(" Time to removal: %ds\n", wdGetTimeLeft(pBug->timeoutWd) / sysClkRateGet() ); } if (pBug->pmEnabled) { printf(" Power Management Enabled\n"); } pBug = pBug->pNext; } } return OK; }/***************************************************************************** intPrismHostApACShow - Displays stations in the access control list** This show routine displays a list of all stations in the access control* list. If the list is empty, then all stations are permitted to authenticate.* Stations can be added and removed through the IOCTL calls EIOCASTA, EIOCDSTA* * RETURNS: N/A** ERRNO: N/A*/void intPrismHostApACShow() { WLAN_AC * pBug; printf("intPrismHostAp Access Control List\n"); if (pWlanHostAp->pWlanAC == NULL) { printf(" All stations allowed\n"); } for (pBug = pWlanHostAp->pWlanAC; pBug != NULL; pBug = pBug->pNext) { printf(" "MAC_ADDR_STRING " allowed\n", MAC_ADDR(pBug->MACAddr)); } return; }/***************************************************************************** intPrismHostApStart - Starts host-based AP mode** The start routine enables the interrupts required to function as a host-* based AP.* * RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS intPrismHostApStart
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -