Fixed TCP keepalive

git-svn-id: svn://kolibrios.org@3143 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-12-28 19:56:52 +00:00
parent 5847bbc023
commit 14077f9230
7 changed files with 39 additions and 20 deletions

View File

@ -5,7 +5,7 @@
;; ;;
;; IPv4.INC ;;
;; ;;
;; Part of the tcp/ip network stack for KolibriOS ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
;; ;;
;; Based on the work of [Johnny_B] and [smb] ;;
;; ;;

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Part of the tcp/ip network stack for KolibriOS ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
;; ;;
;; Written by hidnplayr@kolibrios.org, ;;
;; and Clevermouse. ;;
@ -238,10 +238,11 @@ macro SOCKET_block socket, loop, done {
test [socket + SOCKET.options], SO_BLOCK ; Is this a blocking socket?
jz done ; No, return immediately
push esi
mov esi, 5 ; yes, wait for event
call delay_ms
pop esi
pusha
mov eax, EVENT_NETWORK
mov ebx, 1337 ; UID: ????
call wait_event
popa
jmp loop
@ -1199,7 +1200,7 @@ SOCKET_check_port:
cmp [esi + UDP_SOCKET.LocalPort], bx
jne .next_socket
DEBUGF 1,"local port %u already in use\n", bx
DEBUGF 1,"local port %x already in use\n", bx ; FIXME: find a way to print big endian values with debugf
ret
.port_ok:

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Part of the tcp/ip network stack for KolibriOS ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
;; ;;
@ -64,7 +64,7 @@ TCP_time_re_min = 2 ; min retransmission (1,28s)
TCP_time_re_max = 100 ; max retransmission (64s)
TCP_time_pers_min = 8 ; min persist (5,12s)
TCP_time_pers_max = 94 ; max persist (60,16s)
TCP_time_keep_init = 118 ; connectione stablishment (75,52s)
TCP_time_keep_init = 118 ; connection establishment (75,52s)
TCP_time_keep_idle = 4608 ; idle time before 1st probe (2h)
TCP_time_keep_interval = 118 ; between probes when no response (75,52s)
TCP_time_rtt_default = 5 ; default Round Trip Time (3,2s)

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Part of the tcp/ip network stack for KolibriOS ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
;; ;;
@ -191,7 +191,7 @@ TCP_input:
; Reset idle timer and keepalive timer
mov [ebx + TCP_SOCKET.t_idle], 0
mov [ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval
mov [ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_idle
;--------------------
; Process TCP options
@ -1501,7 +1501,7 @@ align 4
.respond_ack:
push ebx
mov cl, TH_RST
call TCP_respond_socket
call TCP_respond
pop ebx
jmp .destroy_new_socket
@ -1509,7 +1509,7 @@ align 4
.respond_syn:
push ebx
mov cl, TH_RST + TH_ACK
call TCP_respond_socket
call TCP_respond
pop ebx
jmp .destroy_new_socket

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Part of the tcp/ip network stack for KolibriOS ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
;; ;;

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Part of the tcp/ip network stack for KolibriOS ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
;; ;;
@ -319,14 +319,14 @@ TCP_outflags:
;
; The fast way to send an ACK/RST/keepalive segment
;
; TCP_respond_socket:
; TCP_respond
;
; IN: ebx = socket ptr
; cl = flags
;
;--------------------------------------
align 4
TCP_respond_socket:
TCP_respond:
DEBUGF 1,"TCP_respond_socket: socket=%x flags=%x\n", ebx, cl

View File

@ -1,9 +1,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Part of the tcp/ip network stack for KolibriOS ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
;; ;;
@ -42,7 +42,7 @@ local .exit
push ebx
mov cl, TH_ACK
call TCP_respond_socket
call TCP_respond
; and [ebx + TCP_SOCKET.t_flags], TF_ACKNOW ;;
; mov eax, ebx ;;
; call TCP_output ;;
@ -99,11 +99,29 @@ local .exit
DEBUGF 1,"socket %x: Keepalive expired\n", eax
cmp [eax + TCP_SOCKET.state], TCPS_ESTABLISHED
ja .dont_kill
push eax
call TCP_disconnect
pop eax
jmp .loop
.dont_kill:
test [eax + SOCKET.options], SO_KEEPALIVE
jz .reset_keepalive
push eax
mov ebx, eax
xor cl, cl
call TCP_respond ; send keepalive
pop eax
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval
jmp .check_more3
.reset_keepalive:
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_idle
.check_more3:
dec [eax + TCP_SOCKET.timer_timed_wait]
jnz .check_more5