forked from KolibriOS/kolibrios
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
This commit is contained in:
parent
2fcdc75ae8
commit
30373c2ee1
@ -866,7 +866,7 @@ socket_check_port:
|
|||||||
align 4
|
align 4
|
||||||
socket_internal_receiver:
|
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 edi ; offset
|
||||||
push ecx ; size
|
push ecx ; size
|
||||||
|
@ -563,8 +563,8 @@ TCP_send_ack:
|
|||||||
|
|
||||||
push edx eax
|
push edx eax
|
||||||
|
|
||||||
lea esi, [esi + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.SND_NXT]
|
; lea esi, [esi + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.SND_NXT]
|
||||||
inc_INET esi
|
; inc_INET esi
|
||||||
|
|
||||||
; Now, calculate the checksum
|
; Now, calculate the checksum
|
||||||
pushw TCP_Packet.Options shl 8
|
pushw TCP_Packet.Options shl 8
|
||||||
@ -598,6 +598,11 @@ TCP_send_ack:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;---------- TCB state handlers start here
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
stateTCB_LISTEN:
|
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.end + IPv4_SOCKET.end + TCP_SOCKET.RCV_NXT], eax ; Update our recv.nxt field
|
||||||
mov [ebx + SOCKET_head.lock], 0
|
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
|
; Send an ACK
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
pop ebx
|
pop ebx
|
||||||
@ -726,6 +734,10 @@ stateTCB_ESTABLISHED:
|
|||||||
|
|
||||||
DEBUGF 1,"TCBStateHandler: Established\n"
|
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
|
; Here we are expecting data, or a request to close
|
||||||
; OR both...
|
; OR both...
|
||||||
|
|
||||||
@ -749,32 +761,20 @@ stateTCB_ESTABLISHED:
|
|||||||
; First, look at the incoming window. If this is less than or equal to 1024,
|
; 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.
|
; 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
|
; ** 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]
|
mov cx, [edx + TCP_Packet.Window]
|
||||||
xchg cl, ch
|
xchg cl, ch
|
||||||
cmp cx, 1024
|
cmp cx, 1024
|
||||||
ja @f
|
ja @f
|
||||||
|
|
||||||
mov [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.wndsizeTimer], 1
|
mov [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.wndsizeTimer], 1
|
||||||
|
@@:
|
||||||
@@: ; OK, here is the deal
|
pop ecx
|
||||||
; 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
|
|
||||||
|
|
||||||
test ecx, 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.
|
; 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
|
cmp [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_CLOSE_WAIT
|
||||||
@ -782,10 +782,15 @@ stateTCB_ESTABLISHED:
|
|||||||
jmp .exit
|
jmp .exit
|
||||||
|
|
||||||
.data:
|
.data:
|
||||||
|
;;;
|
||||||
|
lea esi, [ebx + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.SND_NXT]
|
||||||
|
add_INET esi
|
||||||
|
|
||||||
DEBUGF 1,"Got data!\n"
|
DEBUGF 1,"Got data!\n"
|
||||||
mov esi, [esp + 4]
|
mov esi, [esp + 4]
|
||||||
sub edx, esi
|
sub edx, esi
|
||||||
mov edi, edx
|
mov edi, edx
|
||||||
|
mov eax, ebx
|
||||||
call socket_internal_receiver
|
call socket_internal_receiver
|
||||||
|
|
||||||
.ack:
|
.ack:
|
||||||
|
Loading…
Reference in New Issue
Block a user