阅读:3381回复:26
胡版主请进。
我的这段代码在有线网卡上运行的很正常,为什么移植到无线网卡上就歇菜了?东西太多,请大虾仔细研究,给欧找找毛病。
//bow NDIS_STATUS MPSend( IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags ) { PADAPT pAdapt = (PADAPT)MiniportAdapterContext; NDIS_STATUS Status; PNDIS_PACKET MyPacket; PRSVD Rsvd; PVOID MediaSpecificInfo = NULL; ULONG MediaSpecificInfoSize = 0; // // Other variables // PVOID PktBufferVA; UINT BufferCount; UINT TotalPacketLength; PNDIS_BUFFER CurrentBuffer; UINT CurrentBufferLength; PVOID CurrentBufferVA; PUCHAR TempVA = NULL; PNDIS_BUFFER PktBuffer; NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress; // // Set the attribute of the packet // PNDIS_PACKET_EXTENSION Old, New; // // According to our LBFO design, all sends will be performed on the secondary miniport // However, the must be completed on the primary\'s miniport handle // ASSERT (pAdapt->pSecondaryAdapt); pAdapt = pAdapt->pSecondaryAdapt; if (IsIMDeviceStateOn (pAdapt) == FALSE) { return NDIS_STATUS_FAILURE; } NdisAllocatePacket(&Status, &MyPacket, pAdapt->SendPacketPoolHandle); if(Status != NDIS_STATUS_SUCCESS) { // // Output debug information // DbgPrint(\"\\n* Debug Report @ MPSend: NdisAllocatePacket dose not renturn NDIS_STATUS_SUCCESS\\n\"); DbgPrint(\"and MPSend will return NDIS_STATUS_FAILURE\\n\"); return (NDIS_STATUS_FAILURE); } // // Get information from the packet received from up-protocol // NdisQueryPacket(Packet, NULL, &BufferCount, &CurrentBuffer, &TotalPacketLength); if(!BufferCount) { // // Output debug information // DbgPrint(\"\\n* Debug Report @ MPSend: BufferCount of Packet is 0,\\n\"); DbgPrint(\"and MPSend will return NDIS_STATUS_FAILURE\\n\"); return (NDIS_STATUS_FAILURE); } // // Allocate memory with NdisAllocateMemory // HighestAcceptableAddress.LowPart = -1; HighestAcceptableAddress.HighPart = -1; Status = NdisAllocateMemory(&PktBufferVA, TotalPacketLength, 0, HighestAcceptableAddress); if(Status == NDIS_STATUS_FAILURE) { // // Output debug information // DbgPrint(\"\\n* Debug Report @ MPSend: NdisAllocateMemory returns NDIS_STATUS_FAILURE,\\n\"); DbgPrint(\"and MPSend will return NDIS_STATUS_FAILURE\\n\"); return (NDIS_STATUS_FAILURE); } // // Allocate buffer // NdisAllocateBuffer(&Status, &PktBuffer, pAdapt->SendBufferPool, MemoryVA, TotalPacketLength); if(Status == NDIS_STATUS_FAILURE) { // // Release the memory // NdisFreeMemory(MemoryVA, TotalPacketLength, 0); // // Output debug information // DbgPrint(\"\\n* Debug Report @ MPSend: NdisAllocateBuffer returns NDIS_STATUS_FAILURE,\\n\"); DbgPrint(\"and MPSend will return NDIS_STATUS_FAILURE\\n\"); return (NDIS_STATUS_FAILURE); } // // Copy the packet to the buffer // TempVA = (PUCHAR)MemoryVA; NdisQueryBuffer(CurrentBuffer, &CurrentBufferVA, &CurrentBufferLength); while(CurrentBuffer != NULL) { NdisMoveMemory(TempVA, CurrentBufferVA, CurrentBufferLength); TempVA = (PUCHAR)TempVA + CurrentBufferLength; NdisGetNextBuffer(CurrentBuffer, &CurrentBuffer); if(CurrentBuffer == NULL) break; NdisQueryBuffer(CurrentBuffer, &CurrentBufferVA, &CurrentBufferLength); } // // TODO ... // Rsvd = (PRSVD)(MyPacket->ProtocolReserved); Rsvd->OriginalPkt = Packet; MyPacket->Private.Flags = Flags; // // Chain the buffer to Mypacket // NdisChainBufferAtBack(MyPacket,PktBuffer); NdisSetPacketFlags(MyPacket, NDIS_FLAGS_DONT_LOOPBACK); // // Copy the per packet info into the new packet // This includes ClassificationHandle, etc. // Make sure other stuff is not copied !!! // Old = NDIS_PACKET_EXTENSION_FROM_PACKET(Packet); New = NDIS_PACKET_EXTENSION_FROM_PACKET(MyPacket); New->NdisPacketInfo[TcpIpChecksumPacketInfo] = Old->NdisPacketInfo[TcpIpChecksumPacketInfo]; New->NdisPacketInfo[IpSecPacketInfo] = Old->NdisPacketInfo[IpSecPacketInfo]; New->NdisPacketInfo[TcpLargeSendPacketInfo] = Old->NdisPacketInfo[TcpLargeSendPacketInfo]; New->NdisPacketInfo[ClassificationHandlePacketInfo] = Old->NdisPacketInfo[ClassificationHandlePacketInfo]; New->NdisPacketInfo[Ieee8021pPriority] = Old->NdisPacketInfo[Ieee8021pPriority]; // // Copy the Media specific information // NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(Packet, &MediaSpecificInfo, &MediaSpecificInfoSize); if (MediaSpecificInfo || MediaSpecificInfoSize) { NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, MediaSpecificInfo, MediaSpecificInfoSize); } NdisSend(&Status, pAdapt->BindingHandle, MyPacket); if(Status != NDIS_STATUS_PENDING) { NdisUnchainBufferAtBack(MyPacket,&PktBuffer); NdisFreeBuffer(PktBuffer); NdisFreeMemory(MemoryVA, TotalPacketLength, 0); NdisFreePacket(MyPacket); } return (Status); } VOID PtSendComplete( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status ) /*++ Routine Description: Interesting case: We wish to send all sends down the secondary NIC. But when we indicate to the protocol above, we need to revert back to the original miniport that Protocol wished to use for the Send Arguments: Return Value: --*/ { PADAPT pAdapt =(PADAPT)ProtocolBindingContext; PNDIS_PACKET Pkt; PRSVD Rsvd; PNDIS_BUFFER PacketBuffer; PVOID PacketBufferVA; UINT PacketBufferLength; // // Returning the Send on the Primary, will point to itself if there is no bundle // pAdapt = pAdapt->pPrimaryAdapt; Rsvd =(PRSVD)(Packet->ProtocolReserved); Pkt = Rsvd->OriginalPkt; NdisUnchainBufferAtBack(Packet,&PacketBuffer); NdisQueryBuffer(PacketBuffer, &PacketBufferVA, &PacketBufferLength); NdisFreeBuffer(PacketBuffer); NdisFreeMemory(PacketBufferVA, PacketBufferLength, 0); NdisFreePacket(Packet); NdisMSendComplete(pAdapt->MiniportHandle, Pkt, Status); } |
|
沙发#
发布于:2002-05-22 18:34
最好能具体说说什么问题。总不能让大家替你做代码检查吧
|
|
板凳#
发布于:2002-05-23 10:49
这问题学问好大幼。真的不简单。
|
|
|
地板#
发布于:2002-05-23 11:44
能问一下你的无线卡的牌子吗?
|
|
|
地下室#
发布于:2002-05-23 12:03
网卡是linkasys的
|
|
5楼#
发布于:2002-05-23 13:10
我觉得好像,你得多提供一点信息,才能让大家明白出了什么事。
1。现象,是shutdown吗? 2。你那个牌子网卡的说明书上应该写了它支持的协议,你是不是能把它抄过来? 3。你安装driver的顺序是什么?我指的是无线的driver和imd 4.你用的环境是什么?win2000?+sp2? xp? 5.你的无线网卡的机子上都装了什么协议?有没有试过他们都碍不碍事? 6.你用什么工具看过你的机子上在安装imd前都有哪些driver在运行吗? |
|
|
6楼#
发布于:2002-05-23 13:55
其实我认为这个问题不出在这个函数本身!而是出在INF和PTBINDADAPTER函数,无线网卡是有专门的载体枚举的!你一定没有支持这个枚举!看看你的载体枚举数组[MEDIUM]里面包含了无线广域网的支持没有?INF里面有没加上这个的注册?都加上了你就可以得到包了!和MODEM是一回事,我想你一定是没得到包!好象这个的发送就不可以用单纯的NDISSEND了!应该是用NDISWAN支持的相关函数!另外要注意得是NDISWAN是面向连接的!而LAN是无连接的!
|
|
|
7楼#
发布于:2002-05-23 13:59
我的建议是先检查INF和PTBINGADAPT的载体支持,然后再进一步调试,看看是什么问题!不过我估计问题应该就出在这!马虎性的错误!加上了载体支持后应该可以马上得到包!但是怎么发出去就查查NDISWAN的相关函数吧!我没有具体研究过!
|
|
|
8楼#
发布于:2002-05-23 14:26
有道理,我也觉得这个地方好像有点不对劲。但是,我没有怀疑这个地方有我自己的原因,我曾经用一个干净的passthru(没有改过)编译之后安装在无线网卡上,没有什么问题的。然而,当我在passthru上动了些收脚后,问题就出来了,对有线的好用,对无线的死翘翘
|
|
9楼#
发布于:2002-05-23 14:38
我觉得好像,你得多提供一点信息,才能让大家明白出了什么事。 呵呵,这些问题我一个一个的回答: 1.好像是这样的,然后再启动的时候就会bluescreen,只有到安全模式下卸载passthru才可以恢复系统。 2.这种东东在国外已经不是什么新鲜玩意了,所以说明书很简单,没有什么技术方面的东东。 3.我按装驱动的顺序当然是先安装网卡的nic驱动了,然后再安装passthru。 4.我的环境是2000(讨厌死了,这个项目完了一定干掉它) 5.这个东东好像没有看过。不过我的机器上的两块网卡(有线和无线)通常是有一块被我禁用的 |
|
10楼#
发布于:2002-05-23 14:41
[quote]我觉得好像,你得多提供一点信息,才能让大家明白出了什么事。 呵呵,这些问题我一个一个的回答: 1.好像是这样的,然后再启动的时候就会bluescreen,只有到安全模式下卸载passthru才可以恢复系统。 2.这种东东在国外已经不是什么新鲜玩意了,所以说明书很简单,没有什么技术方面的东东。 3.我按装驱动的顺序当然是先安装网卡的nic驱动了,然后再安装passthru。 4.我的环境是2000(讨厌死了,这个项目完了一定干掉它) 5.这个东东好像没有看过。不过我的机器上的两块网卡(有线和无线)通常是有一块被我禁用的 [/quote] 它支持的协议,你是不是能把它抄过来? |
|
|
11楼#
发布于:2002-05-23 14:48
支持的协议就是802.11,和802.3差不多
|
|
12楼#
发布于:2002-05-23 15:03
有道理,我也觉得这个地方好像有点不对劲。但是,我没有怀疑这个地方有我自己的原因,我曾经用一个干净的passthru(没有改过)编译之后安装在无线网卡上,没有什么问题的。然而,当我在passthru上动了些收脚后,问题就出来了,对有线的好用,对无线的死翘翘 怎么可能???干净的绝对在WWAN上面用不了!看这个! NdisMedium802_3; //01.Ethernet <-----+ Save NdisMedium802_5; //02.Token-Ring | Wan NdisMediumFddi; //03.FDDI | As NdisMediumWan; //04.Wan ----------+ Ethernet NdisMediumLocalTalk //05.Apple LocalTalk NdisMediumDix //06.Convenience, Not a real medium NdisMediumArcnetRaw //07.Arcnet Raw Stream NdisMediumArcnet878_2 //08.Arcnet 878_2 NdisMediumAtm //09.ATM NdisMediumWirelessWan //10.Wireless Wan NdisMediumIrda //11.Irda NdisMediumBpc //12.BPC NdisMediumCoWan //13.Connection-Oriented Wan NdisMedium1394 //14.IEEE 1394 NdisMediumMax 这上面是NDIS所支持的载体枚举,看看Wireless Wan排第几???然后再去看看没修改过的PASSTHRU支持到第几?? NDIS_MEDIUM MediumArray[3] = { NdisMedium802_3, // Ethernet NdisMedium802_5, // Token-ring NdisMediumFddi // Fddi }; 然后我们再看INF部分! HKR, Ndi\\Interfaces, FilterMediaTypes, , \"ethernet, tokenring, fddi\"这里只支持了什么?? 看看这个里面怎么说的!然后再考虑考虑~~没修改过的PASSTHRU是不是可以直接在WAN上面正常工作,还是不响应WAN~~ Network Devices and Protocols: Windows DDK Specifying Binding Interfaces For each network component that it installs, a network INF file must specify the upper and lower binding interfaces for the component by adding the Interfaces key to the Ndi key. The Interfaces key has at least two values: UpperRange A REG_SZ value that defines the interfaces to which the component can bind at its top edge. LowerRange A REG_SZ value that defines the interfaces to which the component can bind at its lower edge. For physical adapters, this interface should always be the network media, such as Ethernet or token ring, to which the adapter connects. Note The DefUpper and DefLower values in Windows 95/98/Me network INF files, however, are not supported for INF files that will be used on Windows 2000 and later versions of the operating system. The following table lists the Microsoft-supplied UpperRange values: Value Description netbios NetBIOS ipx IPX tdi TDI interface to TCP/IP ndis5 NDIS 5.x (ndis2, ndis3, and ndis4 should no longer be used). This value should be specified for any non-ATM network component, such as a non-ATM adapter, that interfaces with NDIS at its upper edge. Ndisatm NDIS 5.x with ATM support. Specified value for any ATM network component, such as an ATM adapter, whose upper edge interfaces with NDIS ndiswan Upper edge for a WAN adapter. When specified, this value causes the operating system to automatically enable the WAN adapter for use with RAS Ndiscowan Upper edge for a WAN adapter over which connection-oriented NDIS runs noupper Upper edge for any component that does not expose an upper edge for binding; such a component typically has a private interface at its upper edge winsock The Windows socket interface ndis5_atalk Upper edge for an NDIS 5.x Net component (adapter) that binds only to an AppleTalk interface at its upper edge ndis5_dlc Upper edge for an NDIS 5.x Net component (adapter) that binds only to a DLC interface at its upper edge ndis5_ip Upper edge for an NDIS 5.x Net component (adapter) that binds only to a TCP/IP interface at its upper edge ndis5_ipx Upper edge for an NDIS 5.x Net component (adapter) that binds only to an IPX interface at its upper edge ndis5_nbf Upper edge for an NDIS 5.x Net component (adapter) that binds only to a NetBEUI interface at its upper edge ndis5_streams Upper edge for an NDIS 5.x Net component (adapter) that binds only to a streams interface at its upper edge The following table lists the Microsoft-supplied LowerRange values: Value Description ethernet Lower edge for an Ethernet adapter atm Lower edge for an ATM adapter tokenring Lower edge for a token ring adapter serial Lower edge for a serial adapter fddi Lower edge for an FDDI adapter baseband Lower edge for a baseband adapter broadband Lower edge for a broadband adapter arcnet Lower edge for an Arcnet adapter isdn Lower edge for an ISDN adapter localtalk Lower edge for a LocalTalk adapter wan Lower edge for a WAN adapter nolower Lower edge for any component that does not expose a lower edge for binding ndis5 NDIS 5.x. (ndis2, ndis3, and ndis4 should no longer be used.) For any network component whose lower edge interfaces through NDIS with non-ATM components Ndisatm Ndis 5.x with ATM support. For any network component whose lower edge interfaces through NDIS with ATM components The UpperRange and LowerRange values specify the types of interfaces ― not the actual components ― to which a component can bind. The binding engine binds a network component to all components that provide the specified interface at the appropriate (upper or lower) edge. For example, a protocol with a LowerRange of ndis5 binds to all components that have an UpperRange of ndis5, such as physical or virtual adapters. If an NDIS 5.x Net component (adapter) works only with one or more specific protocols, then its UpperRange should be assigned one or more protocol-specific values, such as ndis5_atalk, ndis5_dlc, ndis5_ip, ndis5_ipx, ndis5_nbf, or ndis5_streams. Such a net class component should not be assigned an UpperRange value of ndis5, because this would cause that component to bind to all protocols that provide an ndis5 lower edge. An INF-file-writer can define and use vendor-specific UpperRange and LowerRange values for private binding interfaces. For example, if a vendor wants to bind its adapter only to its own proprietary protocol driver, the INF-file-writer could specify XXX for the UpperRange of the adapter and XXX for the LowerRange of the proprietary protocol. The Windows 2000 binding engine will bind all components that have an UpperRange of XXX (in this case, the adapter) with all components that have a LowerRange of XXX (in this case, the proprietary protocol). The following is an example of an add-registry-section that adds UpperRange and LowerRange values for an ATM adapter: [addreg-section] HKR, Ndi\\Interfaces, UpperRange, 0, \"ndisATM\" HKR, Ndi\\Interfaces, LowerRange, 0, \"atm\" Built on Wednesday, October 03, 2001 |
|
|
13楼#
发布于:2002-05-23 15:09
我考~~贴上来根本没法看~~看这个吧
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/network/hh/network/501install_8f3b.asp [/url] |
|
|
14楼#
发布于:2002-05-23 15:14
BOSD的原因是什么??把DUMPBOSD显示的错误信息的LOG文件放上来看看就知道!
|
|
|
15楼#
发布于:2002-05-23 15:15
BOSD的原因是什么??把内存DUMP文件和BOSD显示的错误信息的LOG文件放上来看看就知道!
|
|
|
16楼#
发布于:2002-05-23 15:40
引用: 呵呵,城市并且认真的说,我现在就是用装有passthru(干净的)的无线网卡法的贴子。如果您在北京,我们可以面对面的讨论这问题。还有,我觉得802.11的东东好像用的是802.3的协议差不多,所以我怀疑他用的就是802_3 |
|
17楼#
发布于:2002-05-23 15:41
引用: 呵呵,诚实并且认真的说,我现在就是用装有passthru(干净的)的无线网卡法的贴子。如果您在北京,我们可以面对面的讨论这问题。还有,我觉得802.11的东东好像用的是802.3的协议差不多,所以我怀疑他用的就是802_3 |
|
18楼#
发布于:2002-05-23 15:49
不好意思~~我在海南~~呵呵~~其实我也没有研究过WWAN~~胡老大好象也没搞过~~起码我没听他在白云或这里提过~孤军奋战~~同志辛苦了~~呵呵~~鼓励一下!
|
|
|
19楼#
发布于:2002-05-23 15:49
你的passthru是2000上的还是xp上的?
|
|
|
上一页
下一页