⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intprismbridge.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    have no way of knowing which it came from */    if (bcmp((char *) pPacket + WLAN_SRC_MAC_OFFSET, IPBWiredMACAddr,              WLAN_ENET_ADDR_LEN) == 0)        {        WLAN_DEBUG(DEBUG_INFO, ("Copying packet to wireless side\n"));        /* Make a copy of the MBlk, since we don't want the original         discarded when we pass it up the stack */        pPacketCopy = netMblkChainDup(pWiredEnd->pNetPool, pNetBuffer, 0,                                      M_COPYALL, M_WAIT);        if (pPacketCopy == NULL)            {            WLAN_DEBUG(DEBUG_ERROR, ("intPrismBridgeWiredTxRtn: ERROR copying"                                     " packet to wireless IF\n"));            return FALSE;            }        /* push the packet onto the wireless interface to send out */        if (muxSend(pIPBWirelessCookie, pPacketCopy) != OK)            {            WLAN_DEBUG(DEBUG_INFO, ("intPrismBridgeWiredTxRtn: Error "                                     "- calling wireless muxSend\n"));            /* Don't return, since we'll pass it down the TX stack for the            wired anyways*/            }        }        WLAN_DEBUG(DEBUG_FLOOD, ("intPrismBridgeWiredTxRtn: Sending packet to wir"                            "ed side\n"));    /* Send packet on - it's meant for the wired interface */    return FALSE;    }/******************************************************************************* intPrismBridgeWirelessRcvRtn - receives copy of all traffic on wireless *                                interface** As a result of a muxBind call (intPrismBridgeOn), this routine will be * notified when the wireless interface receives packets, and then it will* send these packets onto the wired interface's send routine** RETURNS: TRUE if the packet was successfully sent onto the wired interface* ERRNO: N/A*/LOCAL BOOL intPrismBridgeWirelessRcvRtn    (    void * pCookie,               /* returned by muxBind() */    long type,                    /* from RFC1700, or user-defined */    M_BLK_ID pNetBuffer,          /* packet with link-level info */    LL_HDR_INFO * pLinkHeader,    /* link-level header info structure */    void * pSpare                 /* defined on a per-protocol basis */    )    {    struct in_addr ipAddr;    char ipAddrString[INET_ADDR_LEN];    UINT8 * pPacket;    UINT16 etherType;    UINT16 dot1xMode = 0;    if (pIPBWiredCookie == NULL)         {        WLAN_DEBUG(DEBUG_ERROR, ("intPrismBridgeWirelessRcvRtn: Error - no"                                 " ref to wired cookie\n"));        return FALSE;        }    else         {        pPacket = (UINT8 *)pNetBuffer->mBlkHdr.mData;        etherType = *(UINT16*)(pPacket + WLAN_ETHERTYPE_OFFSET);        if (etherType == htons(ETHERTYPE_IP))            {            bcopyBytes((char *) pPacket + WLAN_DST_IP_OFFSET, (char *)&ipAddr.s_addr,                   sizeof(UINT32));                       inet_ntoa_b(ipAddr, ipAddrString);            if (strncmp(ipAddrString, IPBWiredIPAddr, INET_ADDR_LEN) == 0)                {                WLAN_DEBUG(DEBUG_FLOOD, ("intPrismBridgeWirelessRcvRtn: Sendin"                                        "g IP packet from wireless to "                                        "bridge IP stack\n"));                END_RCV_RTN_CALL(pWiredEnd, pNetBuffer);                    return TRUE;                }            }              else if (etherType == (htons(ETHERTYPE_ARP)))            {            bcopyBytes((char *) pPacket + WLAN_ARP_TGT_OFFSET, (char *)&ipAddr.s_addr,                       sizeof(UINT32));                       inet_ntoa_b(ipAddr, ipAddrString);            if (strncmp(ipAddrString, IPBWiredIPAddr, INET_ADDR_LEN) == 0)                {                WLAN_DEBUG(DEBUG_FLOOD, ("intPrismBridgeWirelessRcvRtn: Sendin"                                        "g ARP packet from wireless to "                                        "bridge ARP stack\n"));                END_RCV_RTN_CALL(pWiredEnd, pNetBuffer);                    return TRUE;                }            }        /* Pass 802.1x packets up the stack too, if we're in 802.1x mode */        else if (etherType == htons(ONEX_PROTOCOL))            {            /* Determine if handling 802.1X's EAPOL packets */            muxIoctl(pIPBWirelessCookie, EIOCG802DOT1XMODE,                     (caddr_t)(&dot1xMode));            if(dot1xMode == ONEX_MODE_ENABLED)                {                /* Check to see if it's destined for us */                if (bcmp((char *) pPacket + WLAN_DST_MAC_OFFSET, IPBWirelessMACAddr,                          WLAN_ENET_ADDR_LEN) == 0)                    {                    WLAN_DEBUG(DEBUG_FLOOD, ("intPrismBridgeWirelessRcvRtn: "                                            "Not SNARFing EAPOL\n"));                    return(FALSE);                    }                }            }        WLAN_DEBUG(DEBUG_FLOOD, ("intPrismBridgeWirelessRcvRtn: Sending packet"                                " from wireless to wired\n"));        /* push the packet onto the wireless interface to send out */        if (muxSend(pIPBWiredCookie, pNetBuffer) != OK)            {            WLAN_DEBUG(DEBUG_INFO, ("intPrismBridgeWirelessRcvRtn: Error "                                     "- calling wired muxSend\n"));            }        }    /* Packet has been consumed (sent to wired i/f) do not send up stack*/    return TRUE;    }	 /******************************************************************************* intPrismBridgeWiredRcvRtn - receives copy of all traffic on the wired *                                   interface** As a result of a muxBind call (intPrismBridgeOn), this routine will be * notified when the wired interface receives packets, and then it will* send these packets onto the wireless interface's send routine** RETURNS: TRUE if the packet was successfully sent to the wireless interface* ERRNO: N/A*/LOCAL BOOL intPrismBridgeWiredRcvRtn    (    void * pCookie,                 /* returned by muxBind() */    long type,                      /* from RFC1700, or user-defined */    M_BLK_ID pNetBuffer,            /* packet with link-level info */    LL_HDR_INFO * pLinkHeader,      /* link-level header info structure */    void * pSpare                   /* defined on a per-protocol basis */    )    {    struct in_addr ipAddr;    char ipAddrString[INET_ADDR_LEN];    UINT8 * pPacket;    UINT16 etherType;    if (pIPBWirelessCookie == NULL)         {        WLAN_DEBUG(DEBUG_ERROR, ("intPrismBridgeWiredRcvRtn: Error - no"                                 " ref to wireless cookie\n"));        return FALSE;        }    else         {        pPacket = (UINT8 *)pNetBuffer->mBlkHdr.mData;        etherType = *(UINT16*)(pPacket + WLAN_ETHERTYPE_OFFSET);        if (etherType == htons(ETHERTYPE_IP))            {            bcopyBytes((char *) pPacket + WLAN_DST_IP_OFFSET, (char *)&ipAddr.s_addr,                   sizeof(UINT32));                       inet_ntoa_b(ipAddr, ipAddrString);            if (strncmp(ipAddrString, IPBWiredIPAddr, INET_ADDR_LEN) == 0)                {                WLAN_DEBUG(DEBUG_FLOOD, ("intPrismBridgeWiredRcvRtn: Sending "                                        "IP packet from wired to "                                        "bridge IP stack\n"));                return FALSE;                }            }              /* Check IP packets going to the stack */        if (etherType == (htons(ETHERTYPE_ARP)))            {            bcopyBytes((char *) pPacket + WLAN_ARP_TGT_OFFSET, (char *)&ipAddr.s_addr,                  sizeof(UINT32));                       inet_ntoa_b(ipAddr, ipAddrString);            if (strncmp(ipAddrString, IPBWiredIPAddr, INET_ADDR_LEN) == 0)                {                WLAN_DEBUG(DEBUG_FLOOD, ("intPrismBridgeWiredRcvRtn: Sending "                                        "ARP packet from wired to "                                        "bridge ARP stack\n"));                return FALSE;                }            }        WLAN_DEBUG(DEBUG_FLOOD, ("intPrismBridgeWiredRcvRtn: Sending packet to"                                " wireless I/F\n"));        /* push the packet onto the wireless interface to send out */        if (muxSend(pIPBWirelessCookie, pNetBuffer) != OK)            {            WLAN_DEBUG(DEBUG_INFO, ("intPrismBridgeWiredRcvRtn: Error "                                     "- calling wireless muxSend\n"));            }        }        /* Packet has been consumed (sent to wireless i/f) do not send up stack*/    return TRUE;    }	 /****************************************************************************** intPrismBridgeErrorRtn - handle error in bridging ** This routine is required as a parameter to muxBind. ** RETURNS: N/A* ERRNO: N/A*/LOCAL void intPrismBridgeErrorRtn    (     END_OBJ * pEnd,  /* returned by muxBind() */    END_ERR * pError, /* holds error info */    void * pSpare) /* defined on a per protocol basis */    {    return;    }/****************************************************************************** intPrismBridgeRestartRtn - called to restart the stack** This routine is required as a parameter to muxBind. ** RETURNS: ERROR* ERRNO: N/A*/LOCAL STATUS intPrismBridgeRestartRtn    (     void * pCookie, /* returned by muxBind */    void * pSpare /* defined on a per  protocol basis */    )    {    return ERROR;    }/****************************************************************************** intPrismBridgeShutdownRtn - called to shutdown the stack** This routine is required as a parameter to muxBind. ** RETURNS: ERROR* ERRNO: N/A*/   LOCAL STATUS intPrismBridgeShutdownRtn    (    void * pCookie, /* returned by muxBind() */    void * pSpare    ) /* defined on a per protocol basis */    {    return ERROR;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -