2011-01-24 23:01:54 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; Part of the tcp/ip network stack for KolibriOS ;;
|
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
|
|
|
;; ;;
|
|
|
|
;; Based on the code of 4.4BSD ;;
|
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
2011-01-08 15:59:21 +01:00
|
|
|
|
|
|
|
;----------------------
|
|
|
|
; 160 ms timer
|
|
|
|
;----------------------
|
2012-07-18 00:20:18 +02:00
|
|
|
macro TCP_timer_160ms {
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
local .loop
|
|
|
|
local .exit
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
mov ebx, net_sockets
|
2011-01-08 15:59:21 +01:00
|
|
|
.loop:
|
2012-07-18 00:20:18 +02:00
|
|
|
mov ebx, [ebx + SOCKET.NextPtr]
|
|
|
|
or ebx, ebx
|
|
|
|
jz .exit
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
cmp [ebx + SOCKET.Domain], AF_INET4
|
|
|
|
jne .loop
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
cmp [ebx + SOCKET.Protocol], IP_PROTO_TCP
|
|
|
|
jne .loop
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
test [ebx + TCP_SOCKET.t_flags], TF_DELACK
|
|
|
|
jz .loop
|
|
|
|
and [ebx + TCP_SOCKET.t_flags], not (TF_DELACK)
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
push ebx
|
|
|
|
mov cl, TH_ACK
|
|
|
|
call TCP_respond_socket
|
2012-08-26 12:13:59 +02:00
|
|
|
; and [ebx + TCP_SOCKET.t_flags], TF_ACKNOW ;;
|
|
|
|
; mov eax, ebx ;;
|
|
|
|
; call TCP_output ;;
|
2012-07-18 00:20:18 +02:00
|
|
|
pop ebx
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
jmp .loop
|
2011-01-08 15:59:21 +01:00
|
|
|
|
|
|
|
.exit:
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
;----------------------
|
|
|
|
; 640 ms timer
|
|
|
|
;----------------------
|
2012-07-18 00:20:18 +02:00
|
|
|
macro TCP_timer_640ms {
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
local .loop
|
|
|
|
local .exit
|
2011-01-08 15:59:21 +01:00
|
|
|
|
|
|
|
; Update TCP sequence number
|
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
add [TCP_sequence_num], 64000
|
2011-01-08 15:59:21 +01:00
|
|
|
|
|
|
|
; scan through all the active TCP sockets, decrementing ALL timers
|
|
|
|
; timers do not have the chance to wrap because the keepalive timer will kill the socket when it expires
|
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
mov eax, net_sockets
|
2011-01-08 15:59:21 +01:00
|
|
|
.loop:
|
2012-07-18 00:20:18 +02:00
|
|
|
mov eax, [eax + SOCKET.NextPtr]
|
2011-01-08 15:59:21 +01:00
|
|
|
.check_only:
|
2012-07-18 00:20:18 +02:00
|
|
|
or eax, eax
|
|
|
|
jz .exit
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
cmp [eax + SOCKET.Domain], AF_INET4
|
|
|
|
jne .loop
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP
|
|
|
|
jne .loop
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
inc [eax + TCP_SOCKET.t_idle]
|
|
|
|
dec [eax + TCP_SOCKET.timer_retransmission]
|
|
|
|
jnz .check_more2
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
DEBUGF 1,"socket %x: Retransmission timer expired\n", eax
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
push eax
|
|
|
|
call TCP_output
|
|
|
|
pop eax
|
2011-01-08 15:59:21 +01:00
|
|
|
|
|
|
|
.check_more2:
|
2012-07-18 00:20:18 +02:00
|
|
|
dec [eax + TCP_SOCKET.timer_keepalive]
|
|
|
|
jnz .check_more3
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
DEBUGF 1,"socket %x: Keepalive expired\n", eax
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-08-26 12:13:59 +02:00
|
|
|
push eax
|
2012-07-18 00:20:18 +02:00
|
|
|
call TCP_disconnect
|
2012-08-26 12:13:59 +02:00
|
|
|
pop eax
|
2012-07-18 00:20:18 +02:00
|
|
|
jmp .loop
|
2011-01-08 15:59:21 +01:00
|
|
|
|
|
|
|
.check_more3:
|
2012-07-18 00:20:18 +02:00
|
|
|
dec [eax + TCP_SOCKET.timer_timed_wait]
|
|
|
|
jnz .check_more5
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
DEBUGF 1,"socket %x: 2MSL timer expired\n", eax
|
2011-01-08 15:59:21 +01:00
|
|
|
|
|
|
|
.check_more5:
|
2012-07-18 00:20:18 +02:00
|
|
|
dec [eax + TCP_SOCKET.timer_persist]
|
|
|
|
jnz .loop
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
DEBUGF 1,"socket %x: persist timer expired\n", eax
|
2011-01-08 15:59:21 +01:00
|
|
|
|
2012-08-28 22:48:45 +02:00
|
|
|
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
|
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
jmp .loop
|
2011-01-08 15:59:21 +01:00
|
|
|
.exit:
|
|
|
|
|
2011-01-28 17:49:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; eax = socket
|
|
|
|
|
|
|
|
TCP_cancel_timers:
|
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
push eax edi
|
2011-01-28 17:49:08 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
lea edi, [eax + TCP_SOCKET.timer_retransmission]
|
|
|
|
xor eax, eax
|
|
|
|
stosd
|
|
|
|
stosd
|
|
|
|
stosd
|
|
|
|
stosd
|
|
|
|
stosd
|
2011-01-28 17:49:08 +01:00
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
pop edi eax
|
2011-01-28 17:49:08 +01:00
|
|
|
|
|
|
|
|
2012-07-18 00:20:18 +02:00
|
|
|
ret
|