forked from KolibriOS/kolibrios
implemented TCP_rangeset and TCP_set_persist
git-svn-id: svn://kolibrios.org@2955 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c10e7c783c
commit
d3c3f6e418
@ -55,7 +55,8 @@ struct TCP_SOCKET IP_SOCKET
|
|||||||
RemotePort dw ?
|
RemotePort dw ?
|
||||||
|
|
||||||
t_state dd ? ; TCB state
|
t_state dd ? ; TCB state
|
||||||
t_rxtshift dd ?
|
t_rxtshift db ?
|
||||||
|
rb 3 ; align
|
||||||
t_rxtcur dd ?
|
t_rxtcur dd ?
|
||||||
t_dupacks dd ?
|
t_dupacks dd ?
|
||||||
t_maxseg dd ?
|
t_maxseg dd ?
|
||||||
@ -125,10 +126,10 @@ struct TCP_SOCKET IP_SOCKET
|
|||||||
|
|
||||||
;-------
|
;-------
|
||||||
; Timers
|
; Timers
|
||||||
timer_retransmission dw ? ; rexmt
|
timer_retransmission dd ? ; rexmt
|
||||||
timer_persist dw ?
|
timer_persist dd ?
|
||||||
timer_keepalive dw ? ; keepalive/syn timeout
|
timer_keepalive dd ? ; keepalive/syn timeout
|
||||||
timer_timed_wait dw ? ; also used as 2msl timer
|
timer_timed_wait dd ? ; also used as 2msl timer
|
||||||
|
|
||||||
; extra
|
; extra
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ TCP_input:
|
|||||||
;--------------------
|
;--------------------
|
||||||
; Process TCP options
|
; Process TCP options
|
||||||
|
|
||||||
push ecx
|
push ecx
|
||||||
|
|
||||||
movzx ecx, [edx + TCP_header.DataOffset]
|
movzx ecx, [edx + TCP_header.DataOffset]
|
||||||
cmp ecx, sizeof.TCP_header ; Does header contain any options?
|
cmp ecx, sizeof.TCP_header ; Does header contain any options?
|
||||||
@ -943,7 +943,7 @@ TCP_input:
|
|||||||
jne .no_restart
|
jne .no_restart
|
||||||
|
|
||||||
mov eax, [ebx + TCP_SOCKET.t_rxtcur]
|
mov eax, [ebx + TCP_SOCKET.t_rxtcur]
|
||||||
mov [ebx + TCP_SOCKET.timer_retransmission], ax
|
mov [ebx + TCP_SOCKET.timer_retransmission], eax
|
||||||
|
|
||||||
.no_restart:
|
.no_restart:
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ TCP_output:
|
|||||||
DEBUGF 1,"TCP_output: Entering persist state\n"
|
DEBUGF 1,"TCP_output: Entering persist state\n"
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
||||||
TCP_set_persist eax
|
call TCP_set_persist
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
;----------------------------
|
;----------------------------
|
||||||
@ -523,7 +523,7 @@ TCP_send:
|
|||||||
je .retransmit_set
|
je .retransmit_set
|
||||||
|
|
||||||
mov edx, [eax + TCP_SOCKET.t_rxtcur]
|
mov edx, [eax + TCP_SOCKET.t_rxtcur]
|
||||||
mov [eax + TCP_SOCKET.timer_retransmission], dx
|
mov [eax + TCP_SOCKET.timer_retransmission], edx
|
||||||
|
|
||||||
cmp [eax + TCP_SOCKET.timer_persist], 0
|
cmp [eax + TCP_SOCKET.timer_persist], 0
|
||||||
jne .retransmit_set
|
jne .retransmit_set
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
|
|
||||||
$Revision$
|
$Revision$
|
||||||
|
|
||||||
|
align 4
|
||||||
|
iglobal
|
||||||
|
TCP_backoff db 0,1,2,3,4,5,6,6,6,6,6,6,6
|
||||||
|
endg
|
||||||
|
|
||||||
macro TCP_checksum IP1, IP2 {
|
macro TCP_checksum IP1, IP2 {
|
||||||
|
|
||||||
;-------------
|
;-------------
|
||||||
@ -467,36 +472,63 @@ TCP_respond_segment:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
macro TCPT_RANGESET timer, value, min, max {
|
||||||
|
|
||||||
macro TCP_set_persist socket {
|
local .min
|
||||||
|
local .max
|
||||||
|
local .done
|
||||||
|
|
||||||
|
cmp value, min
|
||||||
|
jb .min
|
||||||
|
cmp value, max
|
||||||
|
ja .max
|
||||||
|
|
||||||
|
mov timer, value
|
||||||
|
jmp .done
|
||||||
|
|
||||||
|
.min:
|
||||||
|
mov timer, value
|
||||||
|
jmp .done
|
||||||
|
|
||||||
|
.max:
|
||||||
|
mov timer, value
|
||||||
|
jmp .done
|
||||||
|
|
||||||
|
.done:
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
align 4
|
||||||
|
TCP_set_persist:
|
||||||
|
|
||||||
; First, check if retransmit timer is not set, retransmit and persist are mutually exclusive
|
; First, check if retransmit timer is not set, retransmit and persist are mutually exclusive
|
||||||
|
|
||||||
; cmp [socket + TCP_socket.timer_retransmission]
|
cmp [eax + TCP_SOCKET.timer_retransmission], 0
|
||||||
|
jg @f
|
||||||
|
|
||||||
; calculate RTO
|
; calculate RTO
|
||||||
|
|
||||||
; mov ecx, [socket + TCP_socket.t_srtt]
|
push ebx
|
||||||
; shr ecx, 2
|
mov ebx, [eax + TCP_SOCKET.t_srtt]
|
||||||
; add ecx, [socket + TCP_socket.t_rttvar]
|
shr ebx, 2
|
||||||
; shr ecx, 1
|
add ebx, [eax + TCP_SOCKET.t_rttvar]
|
||||||
|
shr ebx, 1
|
||||||
|
|
||||||
; and [socket + TCP_socket.t_flags], not TF_PREVVALID
|
mov cl, [eax + TCP_SOCKET.t_rxtshift]
|
||||||
|
shl ebx, cl
|
||||||
;if (tcp_timer_active(tp, TT_REXMT))
|
|
||||||
; panic("tcp_setpersist: retransmit pending");
|
|
||||||
|
|
||||||
; Start/restart persistance timer.
|
; Start/restart persistance timer.
|
||||||
|
|
||||||
;TCPT_RANGESET(tt, t * tcp_backoff[tp->t_rxtshift], TCPTV_PERSMIN, TCPTV_PERSMAX);
|
TCPT_RANGESET [eax + TCP_SOCKET.timer_persist], ebx, TCP_time_pers_min, TCP_time_pers_max
|
||||||
;tcp_timer_activate(tp, TT_PERSIST, tt);
|
|
||||||
|
|
||||||
; cmp [socket + TCP_socket.t_rxtshift], TCP_MAXRXTSHIFT
|
pop ebx
|
||||||
; jae @f
|
|
||||||
; inc [socket + TCP_socket.t_rxtshift]
|
|
||||||
; @@:
|
|
||||||
|
|
||||||
}
|
cmp [eax + TCP_SOCKET.t_rxtshift], TCP_max_rxtshift
|
||||||
|
jae @f
|
||||||
|
inc [eax + TCP_SOCKET.t_rxtshift]
|
||||||
|
@@:
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,6 +116,13 @@ local .exit
|
|||||||
|
|
||||||
DEBUGF 1,"socket %x: persist timer expired\n", eax
|
DEBUGF 1,"socket %x: persist timer expired\n", eax
|
||||||
|
|
||||||
|
call TCP_set_persist
|
||||||
|
mov [eax + TCP_SOCKET.t_force], 1
|
||||||
|
push eax
|
||||||
|
call TCP_output
|
||||||
|
pop eax
|
||||||
|
mov [eax + TCP_SOCKET.t_force], 0
|
||||||
|
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.exit:
|
.exit:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user