mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- Fix receiving of loopback packets.
- Fix recursive spinlock acquire in NBQueuePacket. - Don't pend connect requests if they're satisfied during the call. - Basic implementation of listen. svn path=/trunk/; revision=12039
This commit is contained in:
parent
3e1fe0ceaa
commit
33c558065f
7 changed files with 52 additions and 20 deletions
|
@ -39,11 +39,15 @@ VOID LoopTransmit(
|
|||
IPPacket.NdisPacket = NdisPacket;
|
||||
IPPacket.HeaderSize = 0;
|
||||
GetDataPtr( NdisPacket, 0, (PCHAR *)&IPPacket.Header, &IPPacket.TotalSize );
|
||||
IPPacket.Header += Offset;
|
||||
IPPacket.ContigSize = IPPacket.TotalSize;
|
||||
IPPacket.Position = Offset;
|
||||
|
||||
TI_DbgPrint(MAX_TRACE,
|
||||
("Doing receive (complete: %x, context %x, packet %x)\n",
|
||||
PC(NdisPacket)->DLComplete, Context, NdisPacket));
|
||||
IPReceive(Context, &IPPacket);
|
||||
DisplayIPPacket(&IPPacket);
|
||||
TI_DbgPrint(MAX_TRACE,
|
||||
("Finished receive (complete: %x, context %x, packet %x)\n",
|
||||
PC(NdisPacket)->DLComplete, Context, NdisPacket));
|
||||
|
|
|
@ -30,8 +30,9 @@ VOID NBSendPackets( PNEIGHBOR_CACHE_ENTRY NCE ) {
|
|||
PNEIGHBOR_PACKET Packet;
|
||||
|
||||
/* Send any waiting packets */
|
||||
if( !IsListEmpty( &NCE->PacketQueue ) ) {
|
||||
PacketEntry = RemoveHeadList( &NCE->PacketQueue );
|
||||
PacketEntry = ExInterlockedRemoveHeadList(&NCE->PacketQueue,
|
||||
&NCE->Table->Lock);
|
||||
if( PacketEntry != NULL ) {
|
||||
Packet = CONTAINING_RECORD( PacketEntry, NEIGHBOR_PACKET, Next );
|
||||
|
||||
TI_DbgPrint
|
||||
|
@ -57,8 +58,9 @@ VOID NBFlushPacketQueue( PNEIGHBOR_CACHE_ENTRY NCE,
|
|||
PLIST_ENTRY PacketEntry;
|
||||
PNEIGHBOR_PACKET Packet;
|
||||
|
||||
while( !IsListEmpty( &NCE->PacketQueue ) ) {
|
||||
PacketEntry = RemoveHeadList( &NCE->PacketQueue );
|
||||
PacketEntry = ExInterlockedRemoveHeadList(&NCE->PacketQueue,
|
||||
&NCE->Table->Lock);
|
||||
while( PacketEntry != NULL ) {
|
||||
Packet = CONTAINING_RECORD
|
||||
( PacketEntry, NEIGHBOR_PACKET, Next );
|
||||
|
||||
|
@ -78,6 +80,8 @@ VOID NBFlushPacketQueue( PNEIGHBOR_CACHE_ENTRY NCE,
|
|||
}
|
||||
|
||||
PoolFreeBuffer( Packet );
|
||||
PacketEntry = ExInterlockedRemoveHeadList(&NCE->PacketQueue,
|
||||
&NCE->Table->Lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,11 +452,11 @@ BOOLEAN NBQueuePacket(
|
|||
Packet->Packet = NdisPacket;
|
||||
InsertTailList( &NCE->PacketQueue, &Packet->Next );
|
||||
|
||||
TcpipReleaseSpinLock(Lock, OldIrql);
|
||||
|
||||
if( NCE->State & NUD_CONNECTED )
|
||||
NBSendPackets( NCE );
|
||||
|
||||
TcpipReleaseSpinLock(Lock, OldIrql);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -395,7 +395,7 @@ VOID ProcessFragment(
|
|||
/* If this is the first fragment, save the IP header */
|
||||
if (FragFirst == 0) {
|
||||
TI_DbgPrint(DEBUG_IP, ("First fragment found. Header buffer is at (0x%X). "
|
||||
"Header size is (%d).\n", IPDR->IPv4Header, IPPacket->HeaderSize));
|
||||
"Header size is (%d).\n", &IPDR->IPv4Header, IPPacket->HeaderSize));
|
||||
|
||||
RtlCopyMemory(&IPDR->IPv4Header, IPPacket->Header, IPPacket->HeaderSize);
|
||||
IPDR->HeaderSize = IPPacket->HeaderSize;
|
||||
|
|
|
@ -427,7 +427,7 @@ NTSTATUS TCPConnect
|
|||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
if( Status == OSK_EINPROGRESS || Status == STATUS_SUCCESS )
|
||||
if( Status == OSK_EINPROGRESS )
|
||||
return STATUS_PENDING;
|
||||
else
|
||||
return Status;
|
||||
|
@ -496,26 +496,41 @@ NTSTATUS TCPListen
|
|||
UINT Backlog,
|
||||
PTCP_COMPLETION_ROUTINE Complete,
|
||||
PVOID Context) {
|
||||
NTSTATUS Status;
|
||||
NTSTATUS Status;
|
||||
SOCKADDR_IN AddressToBind;
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("TCPListen started\n"));
|
||||
TI_DbgPrint(DEBUG_TCP,("TCPListen started\n"));
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n",
|
||||
Connection->SocketContext));
|
||||
TI_DbgPrint(DEBUG_TCP,("Connection->SocketContext %x\n",
|
||||
Connection->SocketContext));
|
||||
|
||||
ASSERT(Connection);
|
||||
ASSERT_KM_POINTER(Connection->SocketContext);
|
||||
ASSERT(Connection);
|
||||
ASSERT_KM_POINTER(Connection->SocketContext);
|
||||
ASSERT_KM_POINTER(Connection->AddressFile);
|
||||
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
|
||||
|
||||
Status = TCPTranslateError( OskitTCPListen( Connection->SocketContext,
|
||||
AddressToBind.sin_family = AF_INET;
|
||||
memcpy( &AddressToBind.sin_addr,
|
||||
&Connection->AddressFile->Address.Address.IPv4Address,
|
||||
sizeof(AddressToBind.sin_addr) );
|
||||
AddressToBind.sin_port = Connection->AddressFile->Port;
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("AddressToBind - %x:%x\n", AddressToBind.sin_addr, AddressToBind.sin_port));
|
||||
|
||||
OskitTCPBind( Connection->SocketContext,
|
||||
Connection,
|
||||
&AddressToBind,
|
||||
sizeof(AddressToBind) );
|
||||
|
||||
Status = TCPTranslateError( OskitTCPListen( Connection->SocketContext,
|
||||
Backlog ) );
|
||||
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
TcpipRecursiveMutexLeave( &TCPLock );
|
||||
|
||||
TI_DbgPrint(DEBUG_TCP,("TCPListen finished %x\n", Status));
|
||||
TI_DbgPrint(DEBUG_TCP,("TCPListen finished %x\n", Status));
|
||||
|
||||
return Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS TCPAccept
|
||||
|
|
|
@ -150,6 +150,7 @@ in_pcbbind(inp, nam)
|
|||
if (lport) {
|
||||
struct inpcb *t;
|
||||
|
||||
#ifndef __REACTOS__
|
||||
/* GROSS */
|
||||
if (ntohs(lport) < IPPORT_RESERVED &&
|
||||
(error = suser(p->p_ucred, &p->p_acflag))) {
|
||||
|
@ -157,6 +158,7 @@ in_pcbbind(inp, nam)
|
|||
("Leaving EACCESS\n"));
|
||||
return (EACCES);
|
||||
}
|
||||
#endif
|
||||
t = in_pcblookup(head, zeroin_addr, 0,
|
||||
sin->sin_addr, lport, wild);
|
||||
if (t && (reuseport & t->inp_socket->so_options) == 0)
|
||||
|
|
|
@ -324,7 +324,13 @@ void OskitTCPReceiveDatagram( OSK_PCHAR Data, OSK_UINT Len,
|
|||
}
|
||||
|
||||
int OskitTCPListen( void *socket, int backlog ) {
|
||||
return solisten( socket, backlog );
|
||||
int error;
|
||||
|
||||
OS_DbgPrint(OSK_MID_TRACE,("Called, socket = %08x\n", socket));
|
||||
error = solisten( socket, backlog );
|
||||
OS_DbgPrint(OSK_MID_TRACE,("Ending: %08x\n", error));
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void OskitTCPSetAddress( void *socket,
|
||||
|
|
|
@ -370,6 +370,7 @@ NDIS_STATUS AllocatePacketWithBufferX( PNDIS_PACKET *NdisPacket,
|
|||
ExFreePool( NewData );
|
||||
UntrackFL( File, Line, Packet );
|
||||
FreeNdisPacket( Packet );
|
||||
return Status;
|
||||
}
|
||||
TrackWithTag(NDIS_BUFFER_TAG, Buffer, File, Line);
|
||||
|
||||
|
|
Loading…
Reference in a new issue