Subversion Repositories Kolibri OS

Rev

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

Rev 4366 Rev 4387
Line 19... Line 19...
19
;-----------------------------------------------------------------
19
;-----------------------------------------------------------------
20
;
20
;
21
; TCP_output
21
; TCP_output
22
;
22
;
23
; IN:  eax = socket pointer
23
; IN:  eax = socket pointer
24
;
-
 
25
; OUT: /
24
; OUT: eax = 0 on success/errorcode
26
;
25
;
27
;-----------------------------------------------------------------
26
;-----------------------------------------------------------------
28
align 4
27
align 4
29
proc TCP_output
28
proc TCP_output
Line 175... Line 174...
175
 
174
 
176
        test    esi, esi
175
        test    esi, esi
Line 177... Line 176...
177
        jz      .len_zero
176
        jz      .len_zero
178
 
177
 
Line 179... Line 178...
179
        cmp     esi, [eax + TCP_SOCKET.t_maxseg]
178
        cmp     esi, [eax + TCP_SOCKET.t_maxseg]
180
        je      TCP_send
179
        je      .send
181
 
180
 
Line 182... Line 181...
182
        add     ebx, esi                                ; offset + length
181
        add     ebx, esi                                ; offset + length
183
        cmp     ebx, [eax + STREAM_SOCKET.snd.size]
182
        cmp     ebx, [eax + STREAM_SOCKET.snd.size]
Line 184... Line 183...
184
        jb      @f
183
        jb      @f
185
 
184
 
186
        test    [eax + TCP_SOCKET.t_flags], TF_NODELAY
185
        test    [eax + TCP_SOCKET.t_flags], TF_NODELAY
187
        jnz     TCP_send
186
        jnz     .send
Line 188... Line 187...
188
 
187
 
189
        mov     ebx, [eax + TCP_SOCKET.SND_MAX]
188
        mov     ebx, [eax + TCP_SOCKET.SND_MAX]
Line 190... Line 189...
190
        cmp     ebx, [eax + TCP_SOCKET.SND_UNA]
189
        cmp     ebx, [eax + TCP_SOCKET.SND_UNA]
191
        je      TCP_send
190
        je      .send
192
       @@:
191
       @@:
193
 
192
 
Line 194... Line 193...
194
        test    [eax + TCP_SOCKET.t_force], -1  ;;;
193
        test    [eax + TCP_SOCKET.t_force], -1  ;;;
195
        jnz     TCP_send
194
        jnz     .send
196
 
195
 
Line 197... Line 196...
197
        mov     ebx, [eax + TCP_SOCKET.max_sndwnd]
196
        mov     ebx, [eax + TCP_SOCKET.max_sndwnd]
Line 198... Line 197...
198
        shr     ebx, 1
197
        shr     ebx, 1
199
        cmp     esi, ebx
198
        cmp     esi, ebx
Line 231... Line 230...
231
        add     ebx, [eax + TCP_SOCKET.RCV_NXT]
230
        add     ebx, [eax + TCP_SOCKET.RCV_NXT]
Line 232... Line 231...
232
 
231
 
233
        mov     edi, [eax + TCP_SOCKET.t_maxseg]
232
        mov     edi, [eax + TCP_SOCKET.t_maxseg]
Line 234... Line 233...
234
        shl     edi, 1
233
        shl     edi, 1
235
 
234
 
Line -... Line 235...
-
 
235
        cmp     ebx, edi
236
;        cmp     ebx, edi
236
        jae     .send
237
;        jae     TCP_send
237
 
Line 238... Line 238...
238
 
238
        shl     ebx, 1
Line 239... Line 239...
239
;        cmp     ebx, [eax + TCP_SOCKET.]    ;;; TODO: check with receive buffer high water mark
239
;        cmp     ebx, [eax + TCP_SOCKET.]    ;;; TODO: check with receive buffer high water mark
240
;        jae     TCP_send
240
;        jae     TCP_send
Line 241... Line -...
241
 
-
 
242
  .no_window:
-
 
243
 
241
 
244
;--------------------------
242
  .no_window:
Line 245... Line 243...
245
; Should a segment be sent? (174)
243
 
246
 
244
;--------------------------
Line 247... Line 245...
247
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: 174\n"
245
; Should a segment be sent? (174)
248
 
246
 
249
        test    [eax + TCP_SOCKET.t_flags], TF_ACKNOW   ; we need to ACK
247
        test    [eax + TCP_SOCKET.t_flags], TF_ACKNOW   ; we need to ACK
Line 250... Line 248...
250
        jnz     TCP_send
248
        jnz     .send
251
 
249
 
Line 252... Line 250...
252
        test    dl, TH_SYN + TH_RST                     ; we need to send a SYN or RST
250
        test    dl, TH_SYN + TH_RST                     ; we need to send a SYN or RST
Line 253... Line 251...
253
        jnz     TCP_send
251
        jnz     .send
254
 
252
 
Line 255... Line 253...
255
        mov     ebx, [eax + TCP_SOCKET.SND_UP]          ; when urgent pointer is beyond start of send bufer
253
        mov     ebx, [eax + TCP_SOCKET.SND_UP]          ; when urgent pointer is beyond start of send bufer
256
        cmp     ebx, [eax + TCP_SOCKET.SND_UNA]
254
        cmp     ebx, [eax + TCP_SOCKET.SND_UNA]
257
        ja      TCP_send
255
        ja      .send
Line 258... Line 256...
258
 
256
 
259
        test    dl, TH_FIN
257
        test    dl, TH_FIN
Line 260... Line 258...
260
        jz      .enter_persist  ; no reason to send, enter persist state
258
        jz      .enter_persist  ; no reason to send, enter persist state
Line 300... Line 298...
300
; Fixme: returnvalue?
298
; Fixme: returnvalue?
Line 301... Line 299...
301
 
299
 
Line 302... Line -...
302
        ret
-
 
303
 
-
 
304
 
-
 
305
 
-
 
306
 
-
 
307
 
-
 
308
 
-
 
309
 
300
        ret
310
 
301
 
311
 
302
 
312
;-----------------------------------------------
303
;-----------------------------------------------
313
;
304
;
314
; Send a segment (222)
305
; Send a segment (222)
315
;
306
;
316
; eax = socket pointer
307
; eax = socket pointer
317
; esi = data len
308
; esi = data len
318
;  dl = flags
-
 
319
;
309
;  dl = flags
Line 320... Line 310...
320
;-----------------------------------------------
310
;
Line 321... Line 311...
321
align 4
311
;-----------------------------------------------
322
TCP_send:
312
  .send:
Line 568... Line 558...
568
  .retransmit_set:
558
  .retransmit_set:
Line 569... Line 559...
569
 
559
 
570
;--------------------
560
;--------------------
Line -... Line 561...
-
 
561
; Create the checksum
-
 
562
 
-
 
563
        xor     dx, dx
-
 
564
        test    [ebx + NET_DEVICE.hwacc], NET_HWACC_TCP_IPv4_OUT
571
; Create the checksum
565
        jnz     .checksum_ok
-
 
566
 
-
 
567
        TCP_checksum (eax + IP_SOCKET.LocalIP), (eax + IP_SOCKET.RemoteIP)
572
 
568
 
Line 573... Line 569...
573
        TCP_checksum (eax + IP_SOCKET.LocalIP), (eax + IP_SOCKET.RemoteIP)
569
  .checksum_ok:
574
        mov     [esi + TCP_header.Checksum], dx
570
        mov     [esi + TCP_header.Checksum], dx