diff --git a/reactos/drivers/net/tcpip/transport/rawip/rawip.c b/reactos/drivers/net/tcpip/transport/rawip/rawip.c index d4181cdae0a..cdb75f61f96 100644 --- a/reactos/drivers/net/tcpip/transport/rawip/rawip.c +++ b/reactos/drivers/net/tcpip/transport/rawip/rawip.c @@ -20,7 +20,8 @@ BOOLEAN RawIPInitialized = FALSE; NTSTATUS BuildRawIPPacket( - PVOID Context, + PIP_PACKET Packet, + UINT DataLength, PIP_ADDRESS LocalAddress, USHORT LocalPort ) /* @@ -37,24 +38,19 @@ NTSTATUS BuildRawIPPacket( PVOID Header; NDIS_STATUS NdisStatus; PNDIS_BUFFER HeaderBuffer; - PDATAGRAM_SEND_REQUEST SendRequest = (PDATAGRAM_SEND_REQUEST)Context; - PIP_PACKET Packet = &SendRequest->Packet; + PNDIS_PACKET NdisPacket = Packet->NdisPacket; + /* Will be zeroed in packet by IPInitializePacket */ /* Prepare packet */ - - /* FIXME: Assumes IPv4 */ - if (!Packet) - return STATUS_INSUFFICIENT_RESOURCES; - IPInitializePacket(Packet,IP_ADDRESS_V4); Packet->Flags = IP_PACKET_FLAG_RAW; /* Don't touch IP header */ - Packet->TotalSize = SendRequest->BufferSize; + Packet->TotalSize = DataLength; + Packet->NdisPacket = NdisPacket; if (MaxLLHeaderSize != 0) { Header = ExAllocatePool(NonPagedPool, MaxLLHeaderSize); if (!Header) { TI_DbgPrint(MIN_TRACE, ("Cannot allocate memory for packet headers.\n")); - FreeNdisPacket(Packet->NdisPacket); return STATUS_INSUFFICIENT_RESOURCES; } @@ -63,16 +59,17 @@ NTSTATUS BuildRawIPPacket( /* Allocate NDIS buffer for maximum link level header */ NdisAllocateBuffer(&NdisStatus, - &HeaderBuffer, - GlobalBufferPool, - Header, - MaxLLHeaderSize); + &HeaderBuffer, + GlobalBufferPool, + Header, + MaxLLHeaderSize); + if (NdisStatus != NDIS_STATUS_SUCCESS) { TI_DbgPrint(MIN_TRACE, ("Cannot allocate NDIS buffer for packet headers. NdisStatus = (0x%X)\n", NdisStatus)); ExFreePool(Header); - FreeNdisPacket(Packet->NdisPacket); return STATUS_INSUFFICIENT_RESOURCES; } + /* Chain header at front of packet */ NdisChainBufferAtFront(Packet->NdisPacket, HeaderBuffer); } @@ -104,23 +101,26 @@ NTSTATUS RawIPSendDatagram( UINT BufferLen; PADDRESS_FILE AddrFile = (PADDRESS_FILE)Request->Handle.AddressHandle; - PDATAGRAM_SEND_REQUEST SendRequest; - - SendRequest = ExAllocatePool( NonPagedPool, sizeof(*SendRequest) ); + IP_PACKET Packet; NdisQueryBuffer( Buffer, &BufferData, &BufferLen ); - Status = AllocatePacketWithBuffer( &SendRequest->Packet.NdisPacket, + Status = AllocatePacketWithBuffer( &Packet.NdisPacket, BufferData, BufferLen ); - if( Status != NDIS_STATUS_SUCCESS ) { - BuildRawIPPacket( SendRequest, - (PIP_ADDRESS)&AddrFile->ADE->Address->Address. - IPv4Address, - AddrFile->Port ); - Status = DGSendDatagram(Request, ConnInfo, &SendRequest->Packet); - NdisFreeBuffer( Buffer ); - } + TI_DbgPrint(MID_TRACE,("Packet.NdisPacket %x\n", Packet.NdisPacket)); + + if( Status == NDIS_STATUS_SUCCESS ) + Status = BuildRawIPPacket( &Packet, + BufferLen, + AddrFile->ADE->Address, + AddrFile->Port ); + if( Status == NDIS_STATUS_SUCCESS ) + Status = DGSendDatagram(Request, ConnInfo, &Packet); + else + FreeNdisPacket( Packet.NdisPacket ); + + /* NdisFreeBuffer( Buffer ); */ return Status; } diff --git a/reactos/drivers/net/tcpip/transport/tcp/event.c b/reactos/drivers/net/tcpip/transport/tcp/event.c index 865f01589b4..4f74debad59 100644 --- a/reactos/drivers/net/tcpip/transport/tcp/event.c +++ b/reactos/drivers/net/tcpip/transport/tcp/event.c @@ -101,7 +101,26 @@ void TCPRecvNotify( PCONNECTION_ENDPOINT Connection, UINT Flags ) { } 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",