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 ;;
;; ;;

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