📄 cisaironetend.c
字号:
1,2,3,4,5,6)); return (ERROR); } /* Compensate for the offset we added to long-align the IP hdr */ pWlanDev->stackVars.pMBlk->mBlkHdr.mData = (char *) &pData[IP_HDR_OFFSET]; pWlanDev->stackVars.pMBlk->mBlkHdr.mLen = datalen; pWlanDev->stackVars.pMBlk->mBlkHdr.mFlags |= M_PKTHDR; pWlanDev->stackVars.pMBlk->mBlkPktHdr.len = datalen; /* Update mib-II interface */ END_ERR_ADD (&pWlanDev->endObj, MIB2_IN_UCAST, +1); END_RCV_RTN_CALL(&pWlanDev->endObj, pWlanDev->stackVars.pMBlk); return (OK); }/**************************************************************************** cisAironetEndSend - END function to send a packet across the interface** This is the callback routine that the MUX calls to send a packet. It is* passed a pointer to an MBLK.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndSend ( CARD_CTRL_T * pWlanDev, /* Device handle for this card */ M_BLK_ID pMblk /* MBLK containing the packet to be sent */ ) { if ( semTake (pWlanDev->txComplete, sysClkRateGet () * 3) == ERROR ) { /* We have timed out so return error */ return (ERROR); } /* Take the END semaphore */ END_TX_SEM_TAKE (&pWlanDev->endObj, WAIT_FOREVER); /* write the 802.3 packet (header and payload) */ pWlanDev->stackVars.status = cisAironetHwEthernetPktPut ( pWlanDev, netMblkToBufCopy (pMblk, (char *) &pWlanDev->enetPkt.header.dstAddr, NULL) ); /* * Check to see if we are supposed to use a different WEP key for unicast * and broadcast packets. If so, check if this is a broadcast packet and * swap to a different key slot if so (the default key is kept at the * unicast key) */ if (pWlanDev->broadcastKey != pWlanDev->defaultKey) { INT32 newKey = pWlanDev->broadcastKey; /* Check if this is a broadcast packet */ if ( (pWlanDev->enetPkt.header.dstAddr[0] & 0x01) == 0x01) { /* Save the default key */ cisAironetEndIoctl ((END_OBJ *)pWlanDev, EIOCSWEPDEFAULTKEY, (caddr_t) newKey); } } /* release the resource */ END_TX_SEM_GIVE(&pWlanDev->endObj); /* Free up the mblock */ (void) netMblkClChainFree(pMblk); if (pWlanDev->stackVars.status == ERROR) { return (END_ERR_BLOCK); } /* return - status OK */ return (OK); }/**************************************************************************** cisAironetEndMCastAdd - Adds an address to the multicast list** Adds a multicast address to the END multicast table and writes the new * multicast table to the card.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndMCastAdd ( END_OBJ * pDrvCtrl, UINT8 * pAddress ) { INT32 retVal = 0; INT32 noMCast = 0; UINT8 addrs[WLAN_MAX_MULTICAST][WLAN_ENET_ADDR_LEN]; MULTI_TABLE pMCTable; char pAddr[WLAN_ENET_ADDR_LEN]; if ( (pDrvCtrl == NULL) || (pAddress == NULL) ) { goto error; } /* Do a copy to swap the data on BE systems */ cisAironetBcopy ( (CARD_CTRL_T *) pDrvCtrl, (const UINT8 *) pAddress, (UINT8 *) pAddr, WLAN_ENET_ADDR_LEN); retVal = etherMultiAdd (&pDrvCtrl->multiList, pAddr); if (retVal == ENETRESET) { pDrvCtrl->nMulti++; if (pDrvCtrl->nMulti > WLAN_MAX_MULTICAST) { pDrvCtrl->nMulti--; (void) etherMultiDel (&pDrvCtrl->multiList, (char *) pAddress); goto error; } else { pMCTable.pTable = (char *)addrs; pMCTable.len = WLAN_MAX_MULTICAST * WLAN_ENET_ADDR_LEN; if (etherMultiGet (&pDrvCtrl->multiList, &pMCTable) == ERROR) { ANET_LOG(DEBUG_ERROR, ("cisAironetEndMCastAdd: Error in etherMultiGet\n", 1,2,3,4,5,6)); goto error; } /* Get the number of multicast adresses in the table */ noMCast = END_MULTI_LST_CNT(pDrvCtrl); /* Extract the Multicast addresses */ memcpy(addrs, &pMCTable.pTable[0], (int) pMCTable.len); } return (OK); } error: return (ERROR); }/**************************************************************************** cisAironetEndMCastDel - Remove a multicast address from the multicast * table** Removes a multicast address from the END table and informs the card to* no longer listen for that address.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndMCastDel ( END_OBJ * pDrvCtrl, UINT8 * pAddress ) { UINT8 addrs[WLAN_MAX_MULTICAST][WLAN_ENET_ADDR_LEN]; MULTI_TABLE pMCTable; CARD_CTRL_T * pDev = (CARD_CTRL_T *)pDrvCtrl; INT32 noMCast = 0; STATUS status = ERROR; INT32 retVal = 0; char pAddr[WLAN_ENET_ADDR_LEN]; /* Sanity check */ if (pDrvCtrl == NULL) { return (ERROR); } (void) cisAironetBcopy ( (CARD_CTRL_T *) pDrvCtrl, (const UINT8 *) pAddress, (UINT8 *) pAddr, WLAN_ENET_ADDR_LEN); retVal = etherMultiDel (&pDev->endObj.multiList, (INT8 *) pAddr); if (retVal == ENETRESET) { /* Get the number of multicast adresses in the table */ noMCast = END_MULTI_LST_CNT(&pDev->endObj); /* Extract the Multicast addresses */ (void) memcpy(addrs, &pMCTable.pTable[0], (INT32) pMCTable.len); status = OK; pDrvCtrl->nMulti--; } /* return - status */ return (status); }/**************************************************************************** cisAironetEndMCastGet - Retrieves the multicast table** Returns the END multicast table. This table should correspond to the * table on the card, but the table from the card can also be read from RID* WLAN_RID_MCAST_LIST if a discrepancy is suspected.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndMCastGet ( END_OBJ * pDrvCtrl, MULTI_TABLE * pTable ) { CARD_CTRL_T * pDev = (CARD_CTRL_T *) pDrvCtrl; return (etherMultiGet (&pDev->endObj.multiList, pTable)); }/**************************************************************************** cisAironetEndFlags - Reads the END flags and configures the device * accordingly** The END flags are read from the END object, and the presence or absence* is acted on. The flags that are implemented are:* IFF_PROMISC : Promiscuous mode on/off (all packets, even those * addressed to another station are received) * IFF_MULTICAST : Multicast mode on/off (not supported directly in the* flags register - group addresses are added or removed* via IOCTL calls).* * RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS cisAironetEndFlags ( CARD_CTRL_T * pDev /* Device structure */ ) { INT32 flags = 0; STATUS status = OK; flags = END_FLAGS_GET(&pDev->endObj); if ((flags & IFF_PROMISC) != 0) { ANET_DEBUG(DEBUG_INFO, ("cisAironetEndFlags: Promiscuous mode enabled\n")); status = cisAironetHwModeSet (pDev, ANET_PROMISC); } else { ANET_DEBUG(DEBUG_INFO, ("cisAironetEndFlags: Promiscuous mode disabled\n")); status = cisAironetHwModeSet (pDev, (UINT16) ~ANET_PROMISC); } /* return - status */ return (status); }/**************************************************************************** cisAironetEndDevGet - Returns the pointer to the specified device structure** This function returns a pointer to the device control structure for the* specified device.** RETURNS: Pointer to the device structure or NULL on error** ERRNO: N/A** NOMANUAL*/CARD_CTRL_T * cisAironetEndDevGet ( INT32 unitnum /* Device unit number */ ) { CARD_CTRL_T * pDev; /* Search the list of instances of this driver,to see if a device with this unit num already exists */ for (pDev = pAnetHead; (pDev != NULL); pDev = pDev->pNext) { if (pDev->unitNum == unitnum) { ANET_DEBUG(DEBUG_INFO, ("cisAironetEndDevGet: Found device %d\n", unitnum)); return (pDev); } } ANET_DEBUG(DEBUG_INFO, ("cisAironetEndDevGet: Could NOT find device %d\n", unitnum)); return (NULL); }/**************************************************************************** cisAironetEndReset - resets the cisAironetEnd card.* * Performs reset and card initializtion.* * RETURNS : OK or ERROR if a NULL pointer is passed in or the card init * command fails.** ERRNO : N/A** SEE ALSO:* Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetEndReset ( CARD_CTRL_T * pWlanDev /* Pointer to device handle */ ) { /* Disable interrupts */ (void) cisAironetHwIntDisableAll (pWlanDev); /* Ack any pending interrupts */ (void) cisAironetHwIntAckAll (pWlanDev); /* reset the firmware on the card */ (void) cisAironetHwCardReset (pWlanDev); /* Re-configure the card */ if ( cisAironetHwInit(pWlanDev) == ERROR ) { ANET_DEBUG(DEBUG_ERROR, ("wlanReset: Error resetting card, " "cannot recover\n")); return (ERROR); } else /* Well, there was an error but we recovered */ { ANET_DEBUG(DEBUG_ERROR, ("wlanReset: Error resetting card, " "recovery successful!\n")); } /* Re-enable interrupts */ (void) cisAironetHwIntEnable (pWlanDev); /* return - status */ return (OK); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -