Subversion Repositories Kolibri OS

Rev

Rev 1763 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1763 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
6
;;  Part of the tcp/ip network stack for KolibriOS                 ;;
7
;;                                                                 ;;
8
;;   Written by hidnplayr@kolibrios.org                            ;;
9
;;                                                                 ;;
10
;;    Based on the code of 4.4BSD                                  ;;
11
;;                                                                 ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
13
;;             Version 2, June 1991                                ;;
14
;;                                                                 ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1733 hidnplayr 16
 
1763 hidnplayr 17
$Revision: 1773 $
18
 
1733 hidnplayr 19
;----------------------
20
; 160 ms timer
21
;----------------------
22
macro	TCP_timer_160ms {
23
 
24
local	.loop
25
local	.exit
26
 
27
	mov	eax, net_sockets
28
  .loop:
29
	mov	eax, [eax + SOCKET.NextPtr]
30
	or	eax, eax
31
	jz	.exit
32
 
33
	cmp	[eax + SOCKET.Protocol], IP_PROTO_TCP		;;; We should also check if family is AF_INET
34
	jne	.loop
35
 
36
	dec	[eax + TCP_SOCKET.timer_ack]
37
	jnz	.loop
38
 
39
	DEBUGF	1,"TCP ack for socket %x expired, time to piggyback!\n", eax
40
 
41
	push	eax
42
	call	TCP_respond_socket
43
	pop	eax
44
 
45
	jmp	.loop
46
 
47
  .exit:
48
 
49
}
50
 
51
 
52
;----------------------
53
; 640 ms timer
54
;----------------------
55
macro	TCP_timer_640ms {
56
 
57
local	.loop
58
local	.exit
59
 
60
; Update TCP sequence number
61
 
62
	add	[TCP_sequence_num], 64000
63
 
64
; scan through all the active TCP sockets, decrementing ALL timers
65
; timers do not have the chance to wrap because the keepalive timer will kill the socket when it expires
66
 
67
	mov	eax, net_sockets
68
  .loop:
69
	mov	eax, [eax + SOCKET.NextPtr]
70
  .check_only:
71
	or	eax, eax
72
	jz	.exit
73
 
74
	cmp	[eax + SOCKET.Domain], AF_INET4
75
	jne	.loop
76
 
77
	cmp	[eax + SOCKET.Protocol], IP_PROTO_TCP
78
	jne	.loop
79
 
80
	inc	[eax + TCP_SOCKET.t_idle]
81
	dec	[eax + TCP_SOCKET.timer_retransmission]
82
	jnz	.check_more2
83
 
84
	DEBUGF	1,"socket %x: Retransmission timer expired\n", eax
85
 
86
	push	eax
87
	call	TCP_output
88
	pop	eax
89
 
90
  .check_more2:
91
	dec	[eax + TCP_SOCKET.timer_keepalive]
92
	jnz	.check_more3
93
 
94
	DEBUGF	1,"socket %x: Keepalive expired\n", eax
95
 
96
	call	TCP_close
97
	jmp	.loop
98
 
99
  .check_more3:
100
	dec	[eax + TCP_SOCKET.timer_timed_wait]
101
	jnz	.check_more5
102
 
103
	DEBUGF	1,"socket %x: 2MSL timer expired\n", eax
104
 
105
  .check_more5:
106
	dec	[eax + TCP_SOCKET.timer_persist]
107
	jnz	.loop
108
 
109
	DEBUGF	1,"socket %x: persist timer expired\n", eax
110
 
111
	jmp	.loop
112
  .exit:
113
 
1773 hidnplayr 114
}
115
 
116
 
117
 
118
; eax = socket
119
 
120
TCP_cancel_timers:
121
 
122
	push	eax edi
123
 
124
	lea	edi, [eax + TCP_SOCKET.timer_retransmission]
125
	xor	eax, eax
126
	stosd
127
	stosd
128
	stosd
129
	stosd
130
	stosd
131
 
132
	pop	edi eax
133
 
134
 
135
	ret