Subversion Repositories Kolibri OS

Rev

Rev 2305 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2305 Rev 2362
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  Part of the tcp/ip network stack for KolibriOS                 ;;
6
;;  Part of the tcp/ip network stack for KolibriOS                 ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;   Written by hidnplayr@kolibrios.org                            ;;
8
;;   Written by hidnplayr@kolibrios.org                            ;;
Line 12... Line 12...
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
13
;;             Version 2, June 1991                                ;;
13
;;             Version 2, June 1991                                ;;
14
;;                                                                 ;;
14
;;                                                                 ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 16... Line 16...
16
 
16
 
Line 17... Line 17...
17
$Revision: 2305 $
17
$Revision: 2362 $
18
 
18
 
19
;-----------------------------------------------------------------
19
;-----------------------------------------------------------------
20
;
20
;
Line 73... Line 73...
73
	jz	.no_force
73
	jz	.no_force
Line 74... Line 74...
74
 
74
 
75
	test	ecx, ecx
75
	test	ecx, ecx
Line 76... Line 76...
76
	jnz	.no_zero_window
76
	jnz	.no_zero_window
77
 
77
 
Line 78... Line 78...
78
	cmp	ebx, [eax + STREAM_SOCKET.snd + RING_BUFFER.size]
78
	cmp	ebx, [eax + STREAM_SOCKET.snd.size]
Line 79... Line 79...
79
	jae	@f
79
	jae	@f
Line 91... Line 91...
91
  .no_force:
91
  .no_force:
Line 92... Line 92...
92
 
92
 
93
;--------------------------------
93
;--------------------------------
Line 94... Line 94...
94
; Calculate how much data to send (106)
94
; Calculate how much data to send (106)
95
 
95
 
96
	mov	esi, [eax + STREAM_SOCKET.snd + RING_BUFFER.size]
96
	mov	esi, [eax + STREAM_SOCKET.snd.size]
97
	cmp	esi, ecx
97
	cmp	esi, ecx
98
	jb	@f
98
	jb	@f
99
	mov	esi, ecx
99
	mov	esi, ecx
Line 144... Line 144...
144
; Turn of FIN flag if send buffer not emptied (128)
144
; Turn of FIN flag if send buffer not emptied (128)
Line 145... Line 145...
145
 
145
 
146
	mov	edi, [eax + TCP_SOCKET.SND_NXT]
146
	mov	edi, [eax + TCP_SOCKET.SND_NXT]
147
	add	edi, esi
147
	add	edi, esi
148
	sub	edi, [eax + TCP_SOCKET.SND_UNA]
148
	sub	edi, [eax + TCP_SOCKET.SND_UNA]
149
	sub	edi, [eax + STREAM_SOCKET.snd + RING_BUFFER.size]
149
	sub	edi, [eax + STREAM_SOCKET.snd.size]
Line 150... Line 150...
150
	jns	@f
150
	jns	@f
Line 151... Line 151...
151
 
151
 
Line 152... Line 152...
152
	and	dl, not (TH_FIN)
152
	and	dl, not (TH_FIN)
153
 
153
 
Line 154... Line 154...
154
       @@:
154
       @@:
155
 
155
 
Line 156... Line 156...
156
;-------------------------------
156
;-------------------------------
157
; calculate window advertisement (130)
157
; calculate window advertisement (130)
Line 158... Line 158...
158
 
158
 
159
	mov	ecx, SOCKET_MAXDATA
159
	mov	ecx, SOCKET_MAXDATA
Line 160... Line 160...
160
	sub	ecx, [eax + STREAM_SOCKET.rcv + RING_BUFFER.size]
160
	sub	ecx, [eax + STREAM_SOCKET.rcv.size]
161
 
161
 
Line -... Line 162...
-
 
162
;------------------------------
-
 
163
; Sender silly window avoidance (131)
162
;------------------------------
164
 
-
 
165
	test	esi, esi
-
 
166
	jz	.len_zero
-
 
167
 
-
 
168
	cmp	esi, [eax + TCP_SOCKET.t_maxseg]
Line 163... Line 169...
163
; Sender silly window avoidance (131)
169
	je	.send
164
 
170
 
Line 165... Line 171...
165
	test	esi, esi
171
	test	[eax + TCP_SOCKET.t_flags], TF_NODELAY
Line 188... Line 194...
188
; Check if a window update should be sent (154)
194
; Check if a window update should be sent (154)
Line 189... Line 195...
189
 
195
 
190
	test	ecx, ecx
196
	test	ecx, ecx
Line -... Line 197...
-
 
197
	jz	.no_window
-
 
198
 
-
 
199
	push	ecx
-
 
200
	mov	cl, [eax + TCP_SOCKET.RCV_SCALE]
-
 
201
	inc	cl					; we want it *2
-
 
202
	mov	ebx, TCP_max_win
-
 
203
	shl	ebx, cl
-
 
204
	pop	ecx
-
 
205
	cmp	ebx, ecx
-
 
206
	cmovb	ebx, ecx
-
 
207
 
-
 
208
	; now ebx is TWICE the amount we can increase the window
-
 
209
	; (with TCP_max_win shl rcv_scale as the maximum)
-
 
210
 
-
 
211
	cmp	ebx, [eax + TCP_SOCKET.t_maxseg]
-
 
212
	jae	.send
191
	jz	.no_window
213
 
Line 192... Line 214...
192
 
214
  ;;;      cmp     ebx, [eax + ]                        ;;; TODO: check receive buffer high water mark
Line 193... Line 215...
193
;;; TODO 167-172
215
    ;;;    jae     .send
194
 
216
 
Line 222... Line 244...
222
;--------------------
244
;--------------------
223
; Enter persist state (191)
245
; Enter persist state (191)
Line 224... Line 246...
224
 
246
 
Line -... Line 247...
-
 
247
  .enter_persist:
-
 
248
 
225
  .enter_persist:
249
	cmp	[eax + STREAM_SOCKET.snd.size], 0	; Data ready to send?
-
 
250
	jne	@f
-
 
251
	cmp	[eax + TCP_SOCKET.timer_retransmission], 0
-
 
252
	jne	@f
Line -... Line 253...
-
 
253
	cmp	[eax + TCP_SOCKET.timer_persist], 0	; Persist timer already expired?
Line -... Line 254...
-
 
254
	jne	@f
-
 
255
 
226
 
256
	DEBUGF	1,"Entering persist state\n"
Line 227... Line 257...
227
	DEBUGF	1,"Entering persist state\n"
257
 
228
 
258
	mov	[eax + TCP_SOCKET.t_rxtshift], 0
Line 229... Line 259...
229
 
259
	TCP_set_persist eax
Line 461... Line 491...
461
	je	.retransmit_set
491
	je	.retransmit_set
Line 462... Line 492...
462
 
492
 
463
	mov	edx, [eax + TCP_SOCKET.t_rxtcur]
493
	mov	edx, [eax + TCP_SOCKET.t_rxtcur]
Line -... Line 494...
-
 
494
	mov	[eax + TCP_SOCKET.timer_retransmission], dx
-
 
495
 
464
	mov	[eax + TCP_SOCKET.timer_retransmission], dx
496
	cmp	[eax + TCP_SOCKET.timer_persist], 0
465
 
497
	jne	@f
466
	mov	[eax + TCP_SOCKET.timer_persist], 0
498
	mov	[eax + TCP_SOCKET.timer_persist], 0
Line 467... Line 499...
467
	mov	[eax + TCP_SOCKET.t_rxtshift], 0	;;; TODO: only do this if timer_persist was set
499
	mov	[eax + TCP_SOCKET.t_rxtshift], 0
Line 468... Line 500...
468
 
500
       @@:
469
 
501