From: John Hodge Date: Fri, 8 Feb 2013 10:50:20 +0000 (+0800) Subject: Modules/IPStack - TCP minor bugfixes, arp semaphore name X-Git-Tag: rel0.15~589 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=7143c19c04c283251ce32cd3226f04d69428cee3;p=tpg%2Facess2.git Modules/IPStack - TCP minor bugfixes, arp semaphore name --- diff --git a/KernelLand/Modules/IPStack/arp.c b/KernelLand/Modules/IPStack/arp.c index 43c34256..5ca128bf 100644 --- a/KernelLand/Modules/IPStack/arp.c +++ b/KernelLand/Modules/IPStack/arp.c @@ -67,6 +67,7 @@ int ARP_Initialise() #endif Link_RegisterType(0x0806, ARP_int_GetPacket); + Semaphore_Init(&gARP_Cache4Semaphore, 0, 0, "ARP4", "Cache Changes"); return 1; } @@ -171,6 +172,7 @@ tMacAddr ARP_Resolve4(tInterface *Interface, tIPv4 Address) Log_Log("ARP4", "Timeout"); break; } + Log_Debug("ARP4", "Cache change"); Mutex_Acquire( &glARP_Cache4 ); for( i = 0; i < giARP_Cache4Space; i++ ) diff --git a/KernelLand/Modules/IPStack/tcp.c b/KernelLand/Modules/IPStack/tcp.c index f1eee656..28dc2c59 100644 --- a/KernelLand/Modules/IPStack/tcp.c +++ b/KernelLand/Modules/IPStack/tcp.c @@ -350,7 +350,7 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head // Get length of data dataLen = Length - (Header->DataOffset>>4)*4; LOG("dataLen = %i", dataLen); -// Log_Debug("TCP", "State %i, dataLen = %x", Connection->State, dataLen); + Log_Debug("TCP", "State %i, dataLen = %x", Connection->State, dataLen); // // State Machine @@ -368,14 +368,6 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head if( Header->Flags & TCP_FLAG_SYN ) { Connection->NextSequenceRcv ++; - Header->DestPort = Header->SourcePort; - Header->SourcePort = htons(Connection->LocalPort); - Header->AcknowlegementNumber = htonl(Connection->NextSequenceRcv); - Header->SequenceNumber = htonl(Connection->NextSequenceSend); - Header->WindowSize = htons(TCP_WINDOW_SIZE); - Header->Flags = TCP_FLAG_ACK; - Header->DataOffset = (sizeof(tTCPHeader)/4) << 4; - TCP_SendPacket( Connection, Header, 0, NULL ); if( Header->Flags & TCP_FLAG_ACK ) { @@ -388,6 +380,14 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head Log_Log("TCP", "ACKing SYN"); Connection->State = TCP_ST_SYN_RCVD; } + Header->DestPort = Header->SourcePort; + Header->SourcePort = htons(Connection->LocalPort); + Header->AcknowlegementNumber = htonl(Connection->NextSequenceRcv); + Header->SequenceNumber = htonl(Connection->NextSequenceSend); + Header->WindowSize = htons(TCP_WINDOW_SIZE); + Header->Flags = TCP_FLAG_ACK; + Header->DataOffset = (sizeof(tTCPHeader)/4) << 4; + TCP_SendPacket( Connection, Header, 0, NULL ); } break; @@ -426,12 +426,15 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head } Connection->NextSequenceRcv ++; // TODO: Is this right? (empty packet counts as one byte) Log_Log("TCP", "Empty Packet, inc and ACK the current sequence number"); + TCP_INT_SendACK(Connection); + #if 0 Header->DestPort = Header->SourcePort; Header->SourcePort = htons(Connection->LocalPort); Header->AcknowlegementNumber = htonl(Connection->NextSequenceRcv); Header->SequenceNumber = htonl(Connection->NextSequenceSend); Header->Flags |= TCP_FLAG_ACK; TCP_SendPacket( Connection, Header, 0, NULL ); + #endif return ; } @@ -442,7 +445,7 @@ void TCP_INT_HandleConnectionPacket(tTCPConnection *Connection, tTCPHeader *Head sequence_num = ntohl(Header->SequenceNumber); - LOG("TCP", "0x%08x <= 0x%08x < 0x%08x", + LOG("0x%08x <= 0x%08x < 0x%08x", Connection->NextSequenceRcv, ntohl(Header->SequenceNumber), Connection->NextSequenceRcv + TCP_WINDOW_SIZE