fumo2003
驱动牛犊
驱动牛犊
  • 注册日期2003-11-03
  • 最后登录2004-01-12
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1163回复:1

中间层发送问题:

楼主#
更多 发布于:2003-11-19 09:18
 我在中间层发送,自己从一块buffer构建一个Packet,然后用NDISSend发送,但,每次在NDISSend执行时都会有0x000000d1的错误,
为什么?
请高手指教,代码如下:

long TransferBuffer(
IN  NDIS_HANDLE ProtocolBindingContext,
IN  PVOID pBuffer,
IN UINT PacketSize
)
{
int i ;
PNDIS_PACKET Packet;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PADAPT pAdapt =(PADAPT)ProtocolBindingContext;

PNDIS_BUFFER pNdisBuffer;

PETHHDR pEthHdr = (PETHHDR)pBuffer;
PIPHDR  pIPHdr  = (PIPHDR)(&((char *)pBuffer)[sizeof(ETHHDR)]);
PUDPHDR pUdpHdr = (PUDPHDR)(&((char*)pIPHdr)[sizeof(IPHDR)]);
PTRANSHDR pTransHdr = (PTRANSHDR)(&((char*)pUdpHdr)[sizeof(UDPHDR)]);

// pAdapt = pAdapt->pSecondaryAdapt;
pIPHdr->sourceIP = pIPHdr->destIP;
pUdpHdr->sourcePort = pUdpHdr->destPort;

(PTRANSIPINFO)(&((char*)pTransHdr)[sizeof(TRANSHDR)+i*sizeof(TRANSIPINFO)]);

pIPHdr->destIP = pIPHdr->sourceIP;
pUdpHdr->destPort = pUdpHdr->sourcePort;

NdisDprAllocatePacket(&Status,&Packet,pAdapt->SendPacketPoolHandle);
if (Status == NDIS_STATUS_SUCCESS)
{
NdisAllocateBuffer(
&Status,
&pNdisBuffer,
pAdapt->SendPacketPoolHandle,
Packet->ProtocolReserved,
PacketSize);

NdisChainBufferAtFront(
Packet,
pNdisBuffer);
NdisMoveMemory(
pNdisBuffer,
pBuffer,
PacketSize);
Packet->Private.TotalLength = PacketSize;
Packet->Private.Flags = 0;
Packet->Private.ValidCounts = 0;
Packet->Private.NdisPacketOobOffset = 0;
Packet->Private.NdisPacketFlags = NDIS_FLAGS_DIRECTED_PACKET;
NdisSend(&Status,pAdapt->SendPacketPoolHandle,Packet);

if(Status != NDIS_STATUS_PENDING)
{
NdisFreePacket(Packet);
NdisFreeMemory(pNdisBuffer, PacketSize, 0);  
}
}
return 0;
}
arthurtu
驱动巨牛
驱动巨牛
  • 注册日期2001-11-08
  • 最后登录2020-12-19
  • 粉丝0
  • 关注0
  • 积分26分
  • 威望161点
  • 贡献值0点
  • 好评度35点
  • 原创分0分
  • 专家分0分
  • 社区居民
沙发#
发布于:2003-11-22 00:29
CSDN的也是你问的吗?

丢了一天的帖子。

1、NdisSend(&Status,pAdapt->SendPacketPoolHandle,Packet);
是pAdapt->BindingHandle

2、NdisAllocateBuffer(
&Status,
&pNdisBuffer,
pAdapt->SendPacketPoolHandle,
Packet->ProtocolReserved,
PacketSize);
如果你是要把pBuffer发送出去的话,改成
NdisAllocateBuffer(
&Status,
&pNdisBuffer,
// pAdapt->SendPacketPoolHandle,改成一个Buffer Pool Handle,而不是Packet Pool Handle
pBuffer,
PacketSize);

3、NdisFreeMemory(pNdisBuffer, PacketSize, 0);
pNdisBuffer是从allocate buffer而来,不是allocate memory!!


在ptsendcomplete还要有处理。
游客

返回顶部