📄 intprismwdsend.c
字号:
/* Now that memory for the MUX is initialized, complete END init*/ END_OBJ_READY(&pIntPrWdsDev->endObj, IFF_NOTRAILERS | IFF_BROADCAST | IFF_MULTICAST | IFF_UP | IFF_RUNNING); WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSLoad: Completed successfully\n")); /* Return the address of the control structure we've just allocated and initialized */ return (END_OBJ *)(&pIntPrWdsDev->endObj); }/****************************************************************************** intPrismWDSParse - Parses the initString and fills in the device structure** This function parses the init string, which is colon delimited. ** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS intPrismWDSParse ( INTPRWDS_DEV * pIntPrWdsDev, /* Pointer to device structure */ char *initString /* Initialization string to parse */ ) { char* tok; char* holder = NULL; int i; /* Unit number. */ tok = strtok_r (initString, ":", &holder); if (tok == NULL) return ERROR; pIntPrWdsDev->macPort = 1 + atoi(tok); /* pWlanDev of associated AP */ tok = strtok_r (NULL, ":", &holder); if (tok == NULL) return ERROR; pIntPrWdsDev->pWlanDev = (WLAN_DEV *) strtoul (tok, NULL, 16); /* MAC address of destination link */ for (i=0; i<WLAN_ENET_ADDR_LEN; i++) { tok = strtok_r (NULL, ":", &holder); if (tok == NULL) return ERROR; pIntPrWdsDev->dstMacAddr[i] = strtoul (tok, NULL, 16); } WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSParse: macPort = %d\n", pIntPrWdsDev->macPort)); WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSParse: pWlanDev = 0x%08x\n", (UINT32)pIntPrWdsDev->pWlanDev)); WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSParse: dstMac = " MAC_ADDR_STRING "\n", MAC_ADDR(pIntPrWdsDev->dstMacAddr))); return OK; }/***************************************************************************** intPrismWDSStart - MUX routine to start card operation** Called via muxDevStart(), this function initializes the MAC port for the * WDS link and sets it to the MAC address of the other AP.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS intPrismWDSStart ( END_OBJ* pDrvCtrl /* Pointer to END object structure */ ) { INTPRWDS_DEV * pIntPrWdsDev = (INTPRWDS_DEV *)pDrvCtrl; LTV_RECORD ltv; WLAN_DEBUG(DEBUG_INFO,("intPrismWDSStart: Start of routine\n")); /* Enable the desired mac port */ intPrismCommand(pIntPrWdsDev->pWlanDev, WLAN_CMD_ENABLE | (pIntPrWdsDev->macPort << 8), 0,0,0); /* Enalbe the specified MAC link */ ltv.type = 0xfc10 + pIntPrWdsDev->macPort; ltv.length = 4; bcopy((const char *)pIntPrWdsDev->dstMacAddr, (char *)ltv.data, WLAN_ENET_ADDR_LEN); intPrismLTVWrite(pIntPrWdsDev->pWlanDev, <v); /* Reset the specified MAC port. Note that the intPrismReset() routine will only reset MAC port 0 */ intPrismCommand(pIntPrWdsDev->pWlanDev, WLAN_CMD_DISABLE | (pIntPrWdsDev->macPort << 8), 0,0,0); intPrismCommand(pIntPrWdsDev->pWlanDev, WLAN_CMD_ENABLE | (pIntPrWdsDev->macPort << 8), 0,0,0); WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSStart: Completed successfully\n")); return OK; }/***************************************************************************** intPrismWDSStop - MUX Routine to stop card operation** This function, called via muxDevStop(), disables system and card interrupts.* The card is still enabled, but without interrupts ceases to function.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS intPrismWDSStop ( END_OBJ* pDrvCtrl /* Pointer to device handle */ ) { INTPRWDS_DEV * pIntPrWdsDev = (INTPRWDS_DEV *)pDrvCtrl; LTV_RECORD ltv; WLAN_DEBUG(DEBUG_INFO,("intPrismWDSStart: Start of routine\n")); /* Delete the specified MAC link */ ltv.type = 0xfc10 + pIntPrWdsDev->macPort; ltv.length = 4; bzero((char *)ltv.data, WLAN_ENET_ADDR_LEN); intPrismLTVWrite(pIntPrWdsDev->pWlanDev, <v); /* Disable the MAC Port */ intPrismCommand(pIntPrWdsDev->pWlanDev, WLAN_CMD_DISABLE | (pIntPrWdsDev->macPort << 8), 0,0,0); return OK; }/***************************************************************************** NOMANUAL* intPrismWDSIoctl - MUX Ioctl routine for the WLAN WDS Driver** This supplemental IOCTL routine is attached to the main wireless driver* during intPrismWdsEndLoad() and is called to process the WDS IOCTL routines* as documented in the file description.** RETURNS: OK, EINVAL if cmd not found, or ERROR** ERRNO: N/A*/int intPrismWDSIoctl ( END_OBJ* pDrvCtrl, /* Device handle for this card */ unsigned int cmd, /* IOCTL command */ caddr_t data /* Generic data pointer */ ) { STATUS status = OK; INTPRWDS_DEV * pIntPrWdsDev; pIntPrWdsDev = (INTPRWDS_DEV *)pDrvCtrl; WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSIoctl: cmd = 0x%x data=0x%x\n", cmd, (UINT32)data)); switch ( cmd ) { case EIOCGWDSTXRATE: switch ((int)data) { case WLAN_1_MBIT: pIntPrWdsDev->txRate = 1 * INTERSIL_1_MBIT; status = OK; break; case WLAN_2_MBIT: pIntPrWdsDev->txRate = 2 * INTERSIL_1_MBIT; status = OK; break; case WLAN_5_MBIT: pIntPrWdsDev->txRate = 11 * INTERSIL_1_MBIT / 2; status = OK; break; case WLAN_11_MBIT: pIntPrWdsDev->txRate = 11 * INTERSIL_1_MBIT; status = OK; break; default: status = ERROR; break; } break; case EIOCSWDSTXRATE: if (data == NULL) { status = ERROR; } *(UINT16*)data = pIntPrWdsDev->txRate; break; default : /* Call the IOCTL extension from the station driver, see if there's any commands we couldn't handle that it can . . . */ status = intPrismIoctl((END_OBJ *)pIntPrWdsDev->pWlanDev, cmd, data); break; } return status; }/***************************************************************************** intPrismWDSUnload - Unloads this instance of the WLAN driver** This routine de-links the driver from the linked list of WDS drivers* and de-allocates the memory for the device object.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS intPrismWDSUnload ( END_OBJ* pDrvCtrl /* Pointer to device handle */ ) { INTPRWDS_DEV * pIntPrWdsDev, *pBug; WLAN_DEV * pWlanDev; pIntPrWdsDev = (INTPRWDS_DEV *)pDrvCtrl; pWlanDev = pIntPrWdsDev->pWlanDev; /* Find the entry in the LL corresponding to this driver */ pBug = pWlanDev->pWds; /* We're the first in the list */ if (pBug == pIntPrWdsDev) { pWlanDev->pWds = pIntPrWdsDev->pNext; } else /* Search for our entry */ { while(pBug->pNext != pIntPrWdsDev) { if (pBug->pNext == NULL) { WLAN_DEBUG(DEBUG_ERROR, ("intPrWDSUnload: Fatal error: driver" " not found in LL\n")); return ERROR; } pBug = pBug->pNext; } /* Remove this entry from the list */ pBug->pNext = pIntPrWdsDev->pNext; } free(pIntPrWdsDev); return OK; }/****************************************************************************** intPrismWDSReceive - Task-level routine that receives packets from the card** This routine is called by the AP's ISR when it detects a WDS packet. It* must determine if the WDS packet belongs to this link or not. If not, pass* it on to the next WDS link driver, or drop it if there are no more. Note* that packets must be passed in as complete 802.11 packets, with the frame* header intact, but the SNAP header stipped (as the Host-AP always does)** RETURNS: OK or ERROR on error** ERRNO: N/A*/LOCAL STATUS intPrismWDSReceive ( END_OBJ *pEnd, /* Pointer to device control structure */ RX_PACKET *pRxPacket, /* Pointer to cluster in netPool */ int datalen ) { WLAN_RX_FRAME * pRxFrame; INTPRWDS_DEV * pIntPrWdsDev; WLAN_DEV * pWlanDev; M_BLK_ID pMBlk; CL_BLK_ID pClBlk; pIntPrWdsDev = (INTPRWDS_DEV *)pEnd; pWlanDev = pIntPrWdsDev->pWlanDev; pRxFrame = (WLAN_RX_FRAME *)pRxPacket->pData; WLAN_DEBUG(DEBUG_INFO, ("intPrismWDSReceive: Running!\n")); #if (_BYTE_ORDER == _BIG_ENDIAN) if ((pRxFrame->addr2[0] != pIntPrWdsDev->dstMacAddr[1]) || (pRxFrame->addr2[1] != pIntPrWdsDev->dstMacAddr[0]) || (pRxFrame->addr2[2] != pIntPrWdsDev->dstMacAddr[3]) || (pRxFrame->addr2[3] != pIntPrWdsDev->dstMacAddr[2]) || (pRxFrame->addr2[4] != pIntPrWdsDev->dstMacAddr[5]) || (pRxFrame->addr2[5] != pIntPrWdsDev->dstMacAddr[4]) )#else if (bcmp((char *) pRxFrame->addr2, (char *) pIntPrWdsDev->dstMacAddr, WLAN_ENET_ADDR_LEN) != 0) #endif { if (pIntPrWdsDev->pNext != NULL) { WLAN_DEBUG(DEBUG_ERROR, ("intPrismWDSReceive: Cannot find MAC" MAC_ADDR_STRING " trying next driver\n", MAC_ADDR(pRxFrame->addr2))); /* Pass it to the next WDS driver */ return intPrismWDSReceive((END_OBJ *)pIntPrWdsDev->pNext,pRxPacket, datalen); } else { /* Drop the packet */ WLAN_DEBUG(DEBUG_ERROR, ("intPrismWDSReceive: Cannot find MAC" MAC_ADDR_STRING "\n", MAC_ADDR(pRxFrame->addr2))); netClFree (pWlanDev->endObj.pNetPool, (UCHAR *)pRxPacket); return ERROR; } } /* Receive the packet as in a normal END driver */ if((pClBlk = netClBlkGet (pWlanDev->endObj.pNetPool, M_DONTWAIT)) == NULL) { netClFree (pWlanDev->endObj.pNetPool, (UCHAR *)pRxPacket); WLAN_DEBUG(DEBUG_ERROR, ("intPrismWDSReceive: Error alloc ClBlk\n")); return ERROR; } if((pMBlk = mBlkGet (pWlanDev->endObj.pNetPool, M_DONTWAIT, MT_DATA)) == NULL) { netClBlkFree (pWlanDev->endObj.pNetPool, pClBlk); netClFree (pWlanDev->endObj.pNetPool, (UCHAR *)pRxPacket); WLAN_DEBUG(DEBUG_ERROR, ("intPrismWDSReceive: Error getting MBlk\n")); return ERROR; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -