forked from KolibriOS/kolibrios
Bugfixes in Net branch:
- Fixed delayed ACK (misimplementation) - Fixed zero window problem and checksum for TCP_respond_socket git-svn-id: svn://kolibrios.org@1830 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7a5537dc4f
commit
0d53bac040
@ -131,7 +131,6 @@ virtual at IP_SOCKET.end
|
||||
;-------
|
||||
; Timers
|
||||
.timer_retransmission dw ? ; rexmt
|
||||
.timer_ack dw ?
|
||||
.timer_persist dw ?
|
||||
.timer_keepalive dw ? ; keepalive/syn timeout
|
||||
.timer_timed_wait dw ? ; also used as 2msl timer
|
||||
@ -1209,12 +1208,12 @@ SOCKET_ring_read:
|
||||
.nd:
|
||||
pop ecx
|
||||
|
||||
; .no_data_at_all:
|
||||
.no_data_at_all:
|
||||
ret
|
||||
|
||||
.less_data:
|
||||
mov ecx, [eax + RING_BUFFER.size]
|
||||
test ecx, ecx
|
||||
; test ecx, ecx
|
||||
; jz .no_data_at_all
|
||||
jmp .copy
|
||||
|
||||
|
@ -32,6 +32,7 @@ $Revision$
|
||||
; OUT: /
|
||||
;
|
||||
;-----------------------------------------------------------------
|
||||
|
||||
align 4
|
||||
TCP_input:
|
||||
|
||||
@ -153,11 +154,15 @@ TCP_input:
|
||||
;----------------
|
||||
; Lock the socket
|
||||
|
||||
cmp [ebx + SOCKET.lock], 0
|
||||
jne .drop_not_locked ;;; HACK ! HACK ! dirty fucking HACK ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
add ebx, SOCKET.lock
|
||||
DEBUGF 1,"lock: %x\n", [ebx]
|
||||
call wait_mutex
|
||||
sub ebx, SOCKET.lock
|
||||
|
||||
|
||||
DEBUGF 1,"Socket locked\n"
|
||||
|
||||
;---------------------------------------
|
||||
@ -371,7 +376,7 @@ TCP_input:
|
||||
mov [ebx + TCP_SOCKET.SND_UNA], eax
|
||||
|
||||
; Stop retransmit timer
|
||||
mov [ebx + TCP_SOCKET.timer_ack], 0
|
||||
mov [ebx + TCP_SOCKET.timer_retransmission], 0
|
||||
|
||||
; Awaken waiting processes
|
||||
mov [ebx + SOCKET.lock], 0
|
||||
@ -646,7 +651,7 @@ align 4
|
||||
sub eax, [edx + TCP_segment.SequenceNumber]
|
||||
jle .no_duplicate
|
||||
|
||||
DEBUGF 1,"Uh oh.. %x bytes of duplicate data!\n", eax
|
||||
DEBUGF 1,"Uh oh.. %u bytes of duplicate data!\n", eax
|
||||
|
||||
test [edx + TCP_segment.Flags], TH_SYN
|
||||
jz .no_dup_syn
|
||||
@ -669,8 +674,6 @@ align 4
|
||||
jz .no_duplicate
|
||||
.no_dup_syn:
|
||||
|
||||
DEBUGF 1,"Going to drop %u out of %u bytes\n", eax, ecx
|
||||
|
||||
; eax holds number of bytes to drop
|
||||
|
||||
; Check for entire duplicate packet
|
||||
@ -678,6 +681,8 @@ align 4
|
||||
cmp eax, ecx
|
||||
jge .duplicate
|
||||
|
||||
DEBUGF 1,"Going to drop %u out of %u bytes\n", eax, ecx
|
||||
|
||||
;;; TODO: apply figure 28.30
|
||||
|
||||
; Check for duplicate FIN
|
||||
@ -718,7 +723,7 @@ align 4
|
||||
|
||||
;;; TODO
|
||||
|
||||
jmp .drop ;;; DROP the packet ??
|
||||
jmp .drop_after_ack
|
||||
|
||||
.no_duplicate:
|
||||
|
||||
@ -1456,8 +1461,8 @@ align 4
|
||||
mov [ebx + SOCKET.lock], 0
|
||||
|
||||
push ebx
|
||||
mov eax, ebx
|
||||
call TCP_output
|
||||
mov cl, TH_ACK
|
||||
call TCP_respond_socket
|
||||
pop ebx
|
||||
|
||||
call kernel_free
|
||||
@ -1500,10 +1505,9 @@ align 4
|
||||
|
||||
.respond_ack:
|
||||
|
||||
mov dl, TH_RST
|
||||
|
||||
push ebx
|
||||
call TCP_respond_segment
|
||||
mov cl, TH_RST
|
||||
call TCP_respond_socket
|
||||
pop ebx
|
||||
|
||||
jmp .destroy_new_socket
|
||||
@ -1511,9 +1515,8 @@ align 4
|
||||
|
||||
.respond_syn:
|
||||
|
||||
mov dl, TH_RST + TH_ACK
|
||||
|
||||
push ebx
|
||||
mov cl, TH_RST + TH_ACK
|
||||
call TCP_respond_socket
|
||||
pop ebx
|
||||
|
||||
|
@ -361,7 +361,7 @@ TCP_output:
|
||||
|
||||
pushw 0 ; .UrgentPointer dw ?
|
||||
pushw 0 ; .Checksum dw ?
|
||||
pushw 0x00a0 ; .Window dw ? ;;;;;;;
|
||||
pushw 0x00a0 ; .Window dw ? ;;;;;;; FIXME
|
||||
shl edi, 2 ; .DataOffset db ? only 4 left-most bits
|
||||
shl dx, 8
|
||||
or dx, di ; .Flags db ?
|
||||
|
@ -228,7 +228,7 @@ TCP_outflags:
|
||||
|
||||
;---------------------------------------
|
||||
;
|
||||
; The easy way to send an ACK/RST/keepalive segment
|
||||
; The fast way to send an ACK/RST/keepalive segment
|
||||
;
|
||||
; TCP_respond_socket:
|
||||
;
|
||||
@ -274,8 +274,9 @@ TCP_respond_socket:
|
||||
stosb
|
||||
mov al, cl
|
||||
stosb
|
||||
mov ax, [esi + TCP_SOCKET.RCV_WND]
|
||||
rol ax, 8
|
||||
; mov ax, [esi + TCP_SOCKET.RCV_WND]
|
||||
; rol ax, 8
|
||||
mov ax, 0x00a0 ;;;;;;; FIXME
|
||||
stosw ; window
|
||||
xor eax, eax
|
||||
stosd ; checksum + urgentpointer
|
||||
@ -287,7 +288,7 @@ TCP_respond_socket:
|
||||
sub edi, TCP_segment.Data
|
||||
mov ecx, TCP_segment.Data
|
||||
xchg esi, edi
|
||||
TCP_checksum (edi + IP_SOCKET.LocalIP), (esi + IP_SOCKET.RemoteIP)
|
||||
TCP_checksum (edi + IP_SOCKET.LocalIP), (edi + IP_SOCKET.RemoteIP)
|
||||
mov [esi+TCP_segment.Checksum], dx
|
||||
|
||||
;--------------------
|
||||
|
@ -24,23 +24,26 @@ macro TCP_timer_160ms {
|
||||
local .loop
|
||||
local .exit
|
||||
|
||||
mov eax, net_sockets
|
||||
mov ebx, net_sockets
|
||||
.loop:
|
||||
mov eax, [eax + SOCKET.NextPtr]
|
||||
or eax, eax
|
||||
mov ebx, [ebx + SOCKET.NextPtr]
|
||||
or ebx, ebx
|
||||
jz .exit
|
||||
|
||||
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP ;;; We should also check if family is AF_INET
|
||||
cmp [ebx + SOCKET.Domain], AF_INET4
|
||||
jne .loop
|
||||
|
||||
dec [eax + TCP_SOCKET.timer_ack]
|
||||
jnz .loop
|
||||
cmp [ebx + SOCKET.Protocol], IP_PROTO_TCP ;;; We should also check if family is AF_INET
|
||||
jne .loop
|
||||
|
||||
DEBUGF 1,"TCP ack for socket %x expired, time to piggyback!\n", eax
|
||||
test [ebx + TCP_SOCKET.t_flags], TF_DELACK
|
||||
jz .loop
|
||||
and [ebx + TCP_SOCKET.t_flags], not (TF_DELACK)
|
||||
|
||||
push eax
|
||||
push ebx
|
||||
mov cl, TH_ACK
|
||||
call TCP_respond_socket
|
||||
pop eax
|
||||
pop ebx
|
||||
|
||||
jmp .loop
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user