implemented TCP_rangeset and TCP_set_persist

git-svn-id: svn://kolibrios.org@2955 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-08-28 20:48:45 +00:00
parent c10e7c783c
commit d3c3f6e418
5 changed files with 66 additions and 26 deletions

View File

@ -55,7 +55,8 @@ struct TCP_SOCKET IP_SOCKET
RemotePort dw ?
t_state dd ? ; TCB state
t_rxtshift dd ?
t_rxtshift db ?
rb 3 ; align
t_rxtcur dd ?
t_dupacks dd ?
t_maxseg dd ?
@ -125,10 +126,10 @@ struct TCP_SOCKET IP_SOCKET
;-------
; Timers
timer_retransmission dw ? ; rexmt
timer_persist dw ?
timer_keepalive dw ? ; keepalive/syn timeout
timer_timed_wait dw ? ; also used as 2msl timer
timer_retransmission dd ? ; rexmt
timer_persist dd ?
timer_keepalive dd ? ; keepalive/syn timeout
timer_timed_wait dd ? ; also used as 2msl timer
; extra

View File

@ -198,7 +198,7 @@ TCP_input:
;--------------------
; Process TCP options
push ecx
push ecx
movzx ecx, [edx + TCP_header.DataOffset]
cmp ecx, sizeof.TCP_header ; Does header contain any options?
@ -943,7 +943,7 @@ TCP_input:
jne .no_restart
mov eax, [ebx + TCP_SOCKET.t_rxtcur]
mov [ebx + TCP_SOCKET.timer_retransmission], ax
mov [ebx + TCP_SOCKET.timer_retransmission], eax
.no_restart:

View File

@ -277,7 +277,7 @@ TCP_output:
DEBUGF 1,"TCP_output: Entering persist state\n"
mov [eax + TCP_SOCKET.t_rxtshift], 0
TCP_set_persist eax
call TCP_set_persist
@@:
;----------------------------
@ -523,7 +523,7 @@ TCP_send:
je .retransmit_set
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
jne .retransmit_set

View File

@ -16,6 +16,11 @@
$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 {
;-------------
@ -467,36 +472,63 @@ TCP_respond_segment:
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
; cmp [socket + TCP_socket.timer_retransmission]
cmp [eax + TCP_SOCKET.timer_retransmission], 0
jg @f
; calculate RTO
; mov ecx, [socket + TCP_socket.t_srtt]
; shr ecx, 2
; add ecx, [socket + TCP_socket.t_rttvar]
; shr ecx, 1
push ebx
mov ebx, [eax + TCP_SOCKET.t_srtt]
shr ebx, 2
add ebx, [eax + TCP_SOCKET.t_rttvar]
shr ebx, 1
; and [socket + TCP_socket.t_flags], not TF_PREVVALID
;if (tcp_timer_active(tp, TT_REXMT))
; panic("tcp_setpersist: retransmit pending");
mov cl, [eax + TCP_SOCKET.t_rxtshift]
shl ebx, cl
; Start/restart persistance timer.
;TCPT_RANGESET(tt, t * tcp_backoff[tp->t_rxtshift], TCPTV_PERSMIN, TCPTV_PERSMAX);
;tcp_timer_activate(tp, TT_PERSIST, tt);
TCPT_RANGESET [eax + TCP_SOCKET.timer_persist], ebx, TCP_time_pers_min, TCP_time_pers_max
; cmp [socket + TCP_socket.t_rxtshift], TCP_MAXRXTSHIFT
; jae @f
; inc [socket + TCP_socket.t_rxtshift]
; @@:
pop ebx
}
cmp [eax + TCP_SOCKET.t_rxtshift], TCP_max_rxtshift
jae @f
inc [eax + TCP_SOCKET.t_rxtshift]
@@:
ret

View File

@ -116,6 +116,13 @@ local .exit
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
.exit: