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 ;; ;; 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] ;; ;; Based on the work of [Johnny_B] and [smb] ;;
;; ;; ;; ;;

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; 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, ;; ;; Written by hidnplayr@kolibrios.org, ;;
;; and Clevermouse. ;; ;; and Clevermouse. ;;
@ -238,10 +238,11 @@ macro SOCKET_block socket, loop, done {
test [socket + SOCKET.options], SO_BLOCK ; Is this a blocking socket? test [socket + SOCKET.options], SO_BLOCK ; Is this a blocking socket?
jz done ; No, return immediately jz done ; No, return immediately
push esi pusha
mov esi, 5 ; yes, wait for event mov eax, EVENT_NETWORK
call delay_ms mov ebx, 1337 ; UID: ????
pop esi call wait_event
popa
jmp loop jmp loop
@ -1199,7 +1200,7 @@ SOCKET_check_port:
cmp [esi + UDP_SOCKET.LocalPort], bx cmp [esi + UDP_SOCKET.LocalPort], bx
jne .next_socket 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 ret
.port_ok: .port_ok:

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; 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 ;; ;; Written by hidnplayr@kolibrios.org ;;
;; ;; ;; ;;

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; 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 ;; ;; Written by hidnplayr@kolibrios.org ;;
;; ;; ;; ;;
@ -191,7 +191,7 @@ TCP_input:
; Reset idle timer and keepalive timer ; Reset idle timer and keepalive timer
mov [ebx + TCP_SOCKET.t_idle], 0 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 ; Process TCP options
@ -1501,7 +1501,7 @@ align 4
.respond_ack: .respond_ack:
push ebx push ebx
mov cl, TH_RST mov cl, TH_RST
call TCP_respond_socket call TCP_respond
pop ebx pop ebx
jmp .destroy_new_socket jmp .destroy_new_socket
@ -1509,7 +1509,7 @@ align 4
.respond_syn: .respond_syn:
push ebx push ebx
mov cl, TH_RST + TH_ACK mov cl, TH_RST + TH_ACK
call TCP_respond_socket call TCP_respond
pop ebx pop ebx
jmp .destroy_new_socket jmp .destroy_new_socket

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; 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 ;; ;; Written by hidnplayr@kolibrios.org ;;
;; ;; ;; ;;

View File

@ -3,7 +3,7 @@
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; 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 ;; ;; Written by hidnplayr@kolibrios.org ;;
;; ;; ;; ;;
@ -319,14 +319,14 @@ TCP_outflags:
; ;
; The fast way to send an ACK/RST/keepalive segment ; The fast way to send an ACK/RST/keepalive segment
; ;
; TCP_respond_socket: ; TCP_respond
; ;
; IN: ebx = socket ptr ; IN: ebx = socket ptr
; cl = flags ; cl = flags
; ;
;-------------------------------------- ;--------------------------------------
align 4 align 4
TCP_respond_socket: TCP_respond:
DEBUGF 1,"TCP_respond_socket: socket=%x flags=%x\n", ebx, cl 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 ;; ;; 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 ;; ;; Written by hidnplayr@kolibrios.org ;;
;; ;; ;; ;;
@ -42,7 +42,7 @@ local .exit
push ebx push ebx
mov cl, TH_ACK mov cl, TH_ACK
call TCP_respond_socket call TCP_respond
; and [ebx + TCP_SOCKET.t_flags], TF_ACKNOW ;; ; and [ebx + TCP_SOCKET.t_flags], TF_ACKNOW ;;
; mov eax, ebx ;; ; mov eax, ebx ;;
; call TCP_output ;; ; call TCP_output ;;
@ -99,11 +99,29 @@ local .exit
DEBUGF 1,"socket %x: Keepalive expired\n", eax DEBUGF 1,"socket %x: Keepalive expired\n", eax
cmp [eax + TCP_SOCKET.state], TCPS_ESTABLISHED
ja .dont_kill
push eax push eax
call TCP_disconnect call TCP_disconnect
pop eax pop eax
jmp .loop 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: .check_more3:
dec [eax + TCP_SOCKET.timer_timed_wait] dec [eax + TCP_SOCKET.timer_timed_wait]
jnz .check_more5 jnz .check_more5