From 30373c2ee1b727fef961dea754233fb96586b22f Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sun, 8 Nov 2009 21:44:04 +0000 Subject: [PATCH] changes in net branch: Some more changes in TCP code. I should perhaps read the full RFC before doing any further changes.. git-svn-id: svn://kolibrios.org@1255 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/net/network/socket.inc | 2 +- kernel/branches/net/network/tcp.inc | 47 ++++++++++++++------------ 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/kernel/branches/net/network/socket.inc b/kernel/branches/net/network/socket.inc index 3baf1a45eb..81c1384e80 100644 --- a/kernel/branches/net/network/socket.inc +++ b/kernel/branches/net/network/socket.inc @@ -866,7 +866,7 @@ socket_check_port: align 4 socket_internal_receiver: - DEBUGF 1,"Internal socket receiver: buffer %x, offset: %x\n", esi, edi + DEBUGF 1,"Internal socket receiver: buffer %x, offset: %x size=%u socket: %x\n", esi, edi, ecx, eax push edi ; offset push ecx ; size diff --git a/kernel/branches/net/network/tcp.inc b/kernel/branches/net/network/tcp.inc index d1dfe20997..a80615d7ca 100644 --- a/kernel/branches/net/network/tcp.inc +++ b/kernel/branches/net/network/tcp.inc @@ -563,8 +563,8 @@ TCP_send_ack: push edx eax - lea esi, [esi + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.SND_NXT] - inc_INET esi +; lea esi, [esi + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.SND_NXT] +; inc_INET esi ; Now, calculate the checksum pushw TCP_Packet.Options shl 8 @@ -598,6 +598,11 @@ TCP_send_ack: +;---------- TCB state handlers start here + + + + align 4 stateTCB_LISTEN: @@ -676,6 +681,9 @@ stateTCB_SYN_SENT: mov [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.RCV_NXT], eax ; Update our recv.nxt field mov [ebx + SOCKET_head.lock], 0 + lea esi, [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.SND_NXT] + inc_INET esi + ; Send an ACK mov eax, ebx pop ebx @@ -726,6 +734,10 @@ stateTCB_ESTABLISHED: DEBUGF 1,"TCBStateHandler: Established\n" + mov eax, [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.RCV_NXT] + cmp eax, [edx + TCP_Packet.SequenceNumber] + jne .exit + ; Here we are expecting data, or a request to close ; OR both... @@ -749,32 +761,20 @@ stateTCB_ESTABLISHED: ; First, look at the incoming window. If this is less than or equal to 1024, ; Set the socket window timer to 1. This will stop an additional Packets being queued. ; ** I may need to tweak this value, since I do not know how many Packets are already queued + push ecx mov cx, [edx + TCP_Packet.Window] xchg cl, ch cmp cx, 1024 ja @f - mov [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.wndsizeTimer], 1 - - @@: ; OK, here is the deal - ; My recv.nct field holds the seq of the expected next rec byte - ; if the recevied sequence number is not equal to this, do not - ; increment the recv.nxt field, do not copy data - just send a - ; repeat ack. - - ; recv.nxt is in dword [edx+24], in inet format - ; recv seq is in [sktAddr]+56, in inet format - ; just do a comparision - mov ecx, [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.RCV_NXT] - cmp [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_CLOSE_WAIT - jne @f - mov ecx, eax - - @@: cmp ecx, [edx + TCP_Packet.SequenceNumber] - jne .ack + @@: + pop ecx test ecx, ecx - jnz .data + jnz .data ; Read data, if any + + lea esi, [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.SND_NXT] + inc_INET esi ; If we had received a fin, we need to ACK it. cmp [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_CLOSE_WAIT @@ -782,10 +782,15 @@ stateTCB_ESTABLISHED: jmp .exit .data: + ;;; + lea esi, [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.SND_NXT] + add_INET esi + DEBUGF 1,"Got data!\n" mov esi, [esp + 4] sub edx, esi mov edi, edx + mov eax, ebx call socket_internal_receiver .ack: