mirror of
https://github.com/reactos/reactos.git
synced 2025-01-02 12:32:47 +00:00
rawip: Removed the deallocation of the client-supplied mdl. This does not
appear to be part of the definition and is not done in the UDP case. event: I moved the close notify into it's own function so that it can be worked on separately. svn path=/trunk/; revision=9665
This commit is contained in:
parent
6435dec245
commit
f773e32aab
2 changed files with 47 additions and 28 deletions
|
@ -20,7 +20,8 @@ BOOLEAN RawIPInitialized = FALSE;
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS BuildRawIPPacket(
|
NTSTATUS BuildRawIPPacket(
|
||||||
PVOID Context,
|
PIP_PACKET Packet,
|
||||||
|
UINT DataLength,
|
||||||
PIP_ADDRESS LocalAddress,
|
PIP_ADDRESS LocalAddress,
|
||||||
USHORT LocalPort )
|
USHORT LocalPort )
|
||||||
/*
|
/*
|
||||||
|
@ -37,24 +38,19 @@ NTSTATUS BuildRawIPPacket(
|
||||||
PVOID Header;
|
PVOID Header;
|
||||||
NDIS_STATUS NdisStatus;
|
NDIS_STATUS NdisStatus;
|
||||||
PNDIS_BUFFER HeaderBuffer;
|
PNDIS_BUFFER HeaderBuffer;
|
||||||
PDATAGRAM_SEND_REQUEST SendRequest = (PDATAGRAM_SEND_REQUEST)Context;
|
PNDIS_PACKET NdisPacket = Packet->NdisPacket;
|
||||||
PIP_PACKET Packet = &SendRequest->Packet;
|
/* Will be zeroed in packet by IPInitializePacket */
|
||||||
|
|
||||||
/* Prepare packet */
|
/* Prepare packet */
|
||||||
|
|
||||||
/* FIXME: Assumes IPv4 */
|
|
||||||
if (!Packet)
|
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
|
|
||||||
IPInitializePacket(Packet,IP_ADDRESS_V4);
|
IPInitializePacket(Packet,IP_ADDRESS_V4);
|
||||||
Packet->Flags = IP_PACKET_FLAG_RAW; /* Don't touch IP header */
|
Packet->Flags = IP_PACKET_FLAG_RAW; /* Don't touch IP header */
|
||||||
Packet->TotalSize = SendRequest->BufferSize;
|
Packet->TotalSize = DataLength;
|
||||||
|
Packet->NdisPacket = NdisPacket;
|
||||||
|
|
||||||
if (MaxLLHeaderSize != 0) {
|
if (MaxLLHeaderSize != 0) {
|
||||||
Header = ExAllocatePool(NonPagedPool, MaxLLHeaderSize);
|
Header = ExAllocatePool(NonPagedPool, MaxLLHeaderSize);
|
||||||
if (!Header) {
|
if (!Header) {
|
||||||
TI_DbgPrint(MIN_TRACE, ("Cannot allocate memory for packet headers.\n"));
|
TI_DbgPrint(MIN_TRACE, ("Cannot allocate memory for packet headers.\n"));
|
||||||
FreeNdisPacket(Packet->NdisPacket);
|
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,16 +59,17 @@ NTSTATUS BuildRawIPPacket(
|
||||||
|
|
||||||
/* Allocate NDIS buffer for maximum link level header */
|
/* Allocate NDIS buffer for maximum link level header */
|
||||||
NdisAllocateBuffer(&NdisStatus,
|
NdisAllocateBuffer(&NdisStatus,
|
||||||
&HeaderBuffer,
|
&HeaderBuffer,
|
||||||
GlobalBufferPool,
|
GlobalBufferPool,
|
||||||
Header,
|
Header,
|
||||||
MaxLLHeaderSize);
|
MaxLLHeaderSize);
|
||||||
|
|
||||||
if (NdisStatus != NDIS_STATUS_SUCCESS) {
|
if (NdisStatus != NDIS_STATUS_SUCCESS) {
|
||||||
TI_DbgPrint(MIN_TRACE, ("Cannot allocate NDIS buffer for packet headers. NdisStatus = (0x%X)\n", NdisStatus));
|
TI_DbgPrint(MIN_TRACE, ("Cannot allocate NDIS buffer for packet headers. NdisStatus = (0x%X)\n", NdisStatus));
|
||||||
ExFreePool(Header);
|
ExFreePool(Header);
|
||||||
FreeNdisPacket(Packet->NdisPacket);
|
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Chain header at front of packet */
|
/* Chain header at front of packet */
|
||||||
NdisChainBufferAtFront(Packet->NdisPacket, HeaderBuffer);
|
NdisChainBufferAtFront(Packet->NdisPacket, HeaderBuffer);
|
||||||
}
|
}
|
||||||
|
@ -104,23 +101,26 @@ NTSTATUS RawIPSendDatagram(
|
||||||
UINT BufferLen;
|
UINT BufferLen;
|
||||||
PADDRESS_FILE AddrFile =
|
PADDRESS_FILE AddrFile =
|
||||||
(PADDRESS_FILE)Request->Handle.AddressHandle;
|
(PADDRESS_FILE)Request->Handle.AddressHandle;
|
||||||
PDATAGRAM_SEND_REQUEST SendRequest;
|
IP_PACKET Packet;
|
||||||
|
|
||||||
SendRequest = ExAllocatePool( NonPagedPool, sizeof(*SendRequest) );
|
|
||||||
|
|
||||||
NdisQueryBuffer( Buffer, &BufferData, &BufferLen );
|
NdisQueryBuffer( Buffer, &BufferData, &BufferLen );
|
||||||
Status = AllocatePacketWithBuffer( &SendRequest->Packet.NdisPacket,
|
Status = AllocatePacketWithBuffer( &Packet.NdisPacket,
|
||||||
BufferData,
|
BufferData,
|
||||||
BufferLen );
|
BufferLen );
|
||||||
|
|
||||||
if( Status != NDIS_STATUS_SUCCESS ) {
|
TI_DbgPrint(MID_TRACE,("Packet.NdisPacket %x\n", Packet.NdisPacket));
|
||||||
BuildRawIPPacket( SendRequest,
|
|
||||||
(PIP_ADDRESS)&AddrFile->ADE->Address->Address.
|
if( Status == NDIS_STATUS_SUCCESS )
|
||||||
IPv4Address,
|
Status = BuildRawIPPacket( &Packet,
|
||||||
AddrFile->Port );
|
BufferLen,
|
||||||
Status = DGSendDatagram(Request, ConnInfo, &SendRequest->Packet);
|
AddrFile->ADE->Address,
|
||||||
NdisFreeBuffer( Buffer );
|
AddrFile->Port );
|
||||||
}
|
if( Status == NDIS_STATUS_SUCCESS )
|
||||||
|
Status = DGSendDatagram(Request, ConnInfo, &Packet);
|
||||||
|
else
|
||||||
|
FreeNdisPacket( Packet.NdisPacket );
|
||||||
|
|
||||||
|
/* NdisFreeBuffer( Buffer ); */
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,26 @@ void TCPRecvNotify( PCONNECTION_ENDPOINT Connection, UINT Flags ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPCloseNotify( PCONNECTION_ENDPOINT Connection ) {
|
void TCPCloseNotify( PCONNECTION_ENDPOINT Connection ) {
|
||||||
TCPRecvNotify( Connection, 0 );
|
NTSTATUS Status;
|
||||||
|
PTDI_IND_DISCONNECT DisconnectHandler;
|
||||||
|
PVOID HandlerContext;
|
||||||
|
|
||||||
|
DisconnectHandler = Connection->AddressFile->DisconnectHandler;
|
||||||
|
HandlerContext = Connection->AddressFile->DisconnectHandlerContext;
|
||||||
|
|
||||||
|
/* XXX Distinguish TDI_DISCONNECT_RELEASE from TDI_DISCONNECT_ABORT */
|
||||||
|
if( Connection->AddressFile->RegisteredDisconnectHandler )
|
||||||
|
Status = DisconnectHandler( HandlerContext,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
TDI_DISCONNECT_ABORT );
|
||||||
|
else
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *FlagNames[] = { "SEL_CONNECT",
|
char *FlagNames[] = { "SEL_CONNECT",
|
||||||
|
|
Loading…
Reference in a new issue