Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
3545 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2013. 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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
 
17
$Revision: 3289 $
18
 
19
;-----------------------------------------------------------------
20
;
21
; TCP_output
22
;
23
; IN:  eax = socket pointer
24
;
25
; OUT: /
26
;
27
;-----------------------------------------------------------------
28
align 4
29
TCP_output:
30
 
3556 hidnplayr 31
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: socket=%x\n", eax
3545 hidnplayr 32
 
33
        push    eax
34
        lea     ecx, [eax + SOCKET.mutex]
35
        call    mutex_lock
36
        pop     eax
37
 
3652 hidnplayr 38
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: socket locked\n"
39
 
3545 hidnplayr 40
; We'll detect the length of the data to be transmitted, and flags to be used
41
; If there is some data, or any critical controls to send (SYN / RST), then transmit
42
; Otherwise, investigate further
43
 
44
        mov     ebx, [eax + TCP_SOCKET.SND_MAX]
45
        cmp     ebx, [eax + TCP_SOCKET.SND_UNA]
46
        jbe     .not_idle
47
 
48
        mov     ebx, [eax + TCP_SOCKET.t_idle]
49
        cmp     ebx, [eax + TCP_SOCKET.t_rxtcur]
50
        jbe     .not_idle
51
 
52
; We have been idle for a while and no ACKS are expected to clock out any data we send..
53
; Slow start to get ack "clock" running again.
54
 
55
        mov     ebx, [eax + TCP_SOCKET.t_maxseg]
56
        mov     [eax + TCP_SOCKET.SND_CWND], ebx
57
 
58
  .not_idle:
59
  .again:
60
        mov     [eax + TCP_SOCKET.temp_bits], 0
61
 
62
        mov     ebx, [eax + TCP_SOCKET.SND_NXT]         ; calculate offset (71)
63
        sub     ebx, [eax + TCP_SOCKET.SND_UNA]         ;
64
 
65
        mov     ecx, [eax + TCP_SOCKET.SND_WND]         ; determine window
66
        cmp     ecx, [eax + TCP_SOCKET.SND_CWND]        ;
67
        jb      @f                                      ;
68
        mov     ecx, [eax + TCP_SOCKET.SND_CWND]        ;
69
       @@:                                              ;
70
 
71
        call    TCP_outflags                            ; flags in dl
72
 
73
;------------------------
74
; data being forced out ?
75
 
76
; If in persist timeout with window of 0, send 1 byte.
77
; Otherwise, if window is small but nonzero, and timer expired,
78
; we will send what we can and go to transmit state
79
 
80
        cmp     [eax + TCP_SOCKET.t_force], 0
81
        je      .no_force
82
 
3556 hidnplayr 83
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: forcing data out\n"
3545 hidnplayr 84
 
85
        test    ecx, ecx
86
        jnz     .no_zero_window
87
 
88
        cmp     ebx, [eax + STREAM_SOCKET.snd.size]
89
        jae     @f
90
 
91
        and     dl, not (TH_FIN)
92
 
93
       @@:
94
        inc     ecx
95
        jmp     .no_force
96
 
97
  .no_zero_window:
3603 hidnplayr 98
        and     [eax + TCP_SOCKET.timer_flags], not timer_flag_persist
3545 hidnplayr 99
        mov     [eax + TCP_SOCKET.t_rxtshift], 0
100
 
101
  .no_force:
102
 
103
;--------------------------------
104
; Calculate how much data to send (106)
105
 
106
        mov     esi, [eax + STREAM_SOCKET.snd.size]
107
        cmp     esi, ecx
108
        jb      @f
109
        mov     esi, ecx
110
       @@:
111
        sub     esi, ebx
112
 
113
 
114
;------------------------
115
; check for window shrink (107)
116
 
117
; If FIN has been set, but not ACKed, but we havent been called to retransmit, esi will be -1
118
; Otherwise, window shrank after we sent into it.
119
 
120
        jae     .not_persist
121
 
122
; enter persist state
123
        xor     esi, esi
124
 
125
; If window shrank to 0
126
        test    ecx, ecx
127
        jnz     @f
128
 
129
; cancel pending retransmit
3603 hidnplayr 130
        and     [eax + TCP_SOCKET.timer_flags], not timer_flag_retransmission
3545 hidnplayr 131
 
132
; pull SND_NXT back to (closed) window, We will enter persist state below.
133
        push    [eax + TCP_SOCKET.SND_UNA]
134
        pop     [eax + TCP_SOCKET.SND_NXT]
135
       @@:
136
 
137
; If window didn't close completely, just wait for an ACK
138
 
139
  .not_persist:
140
 
141
;---------------------------
142
; Send one segment at a time (124)
143
 
144
        cmp     esi, [eax + TCP_SOCKET.t_maxseg]
145
        jbe     @f
146
 
147
        mov     esi, [eax + TCP_SOCKET.t_maxseg]
148
        or      [eax + TCP_SOCKET.temp_bits], TCP_BIT_SENDALOT
149
       @@:
150
 
151
;--------------------------------------------
152
; Turn of FIN flag if send buffer not emptied (128)
153
 
154
        mov     edi, [eax + TCP_SOCKET.SND_NXT]
155
        add     edi, esi
156
        sub     edi, [eax + TCP_SOCKET.SND_UNA]
157
        cmp     edi, [eax + STREAM_SOCKET.snd.size]
158
        jae     @f
159
        and     dl, not (TH_FIN)
160
 
161
       @@:
162
 
163
;-------------------------------
164
; calculate window advertisement (130)
165
 
166
        mov     ecx, SOCKET_MAXDATA
167
        sub     ecx, [eax + STREAM_SOCKET.rcv.size]
168
 
169
;------------------------------
170
; Sender silly window avoidance (131)
171
 
172
        test    esi, esi
173
        jz      .len_zero
174
 
175
        cmp     esi, [eax + TCP_SOCKET.t_maxseg]
176
        je      TCP_send
177
 
178
        add     ebx, esi                                ; offset + length
179
        cmp     ebx, [eax + STREAM_SOCKET.snd.size]
180
        jb      @f
181
 
182
        test    [eax + TCP_SOCKET.t_flags], TF_NODELAY
183
        jnz     TCP_send
184
 
185
        mov     ebx, [eax + TCP_SOCKET.SND_MAX]
186
        cmp     ebx, [eax + TCP_SOCKET.SND_UNA]
187
        je      TCP_send
188
       @@:
189
 
190
        test    [eax + TCP_SOCKET.t_force], -1  ;;;
191
        jnz     TCP_send
192
 
193
        mov     ebx, [eax + TCP_SOCKET.max_sndwnd]
194
        shr     ebx, 1
195
        cmp     esi, ebx
196
        jae     TCP_send
197
 
198
        mov     ebx, [eax + TCP_SOCKET.SND_NXT]
199
        cmp     ebx, [eax + TCP_SOCKET.SND_MAX]
200
        jb      TCP_send
201
 
202
  .len_zero:
203
 
204
;----------------------------------------
205
; Check if a window update should be sent (154)
206
 
3556 hidnplayr 207
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: window=%d\n", ecx
3545 hidnplayr 208
 
209
; Compare available window to amount of window known to peer (as advertised window less next expected input)
210
; If the difference is at least two max size segments, or at least 50% of the maximum possible window,
211
; Then we want to send a window update to the peer.
212
 
213
        test    ecx, ecx
214
        jz      .no_window
215
 
216
        push    ecx
217
        mov     cl, [eax + TCP_SOCKET.RCV_SCALE]
218
        mov     ebx, TCP_max_win
219
        shl     ebx, cl
220
        pop     ecx
3652 hidnplayr 221
 
3545 hidnplayr 222
        cmp     ebx, ecx
223
        jb      @f
224
        mov     ebx, ecx
225
       @@:
226
        sub     ebx, [eax + TCP_SOCKET.RCV_ADV]
227
        add     ebx, [eax + TCP_SOCKET.RCV_NXT]
228
 
229
        mov     edi, [eax + TCP_SOCKET.t_maxseg]
230
        shl     edi, 1
231
 
232
;        cmp     ebx, edi
233
;        jae     TCP_send
234
 
235
;        cmp     ebx, [eax + TCP_SOCKET.]    ;;; TODO: check with receive buffer high water mark
236
;        jae     TCP_send
237
 
238
  .no_window:
239
 
240
;--------------------------
241
; Should a segment be sent? (174)
242
 
3556 hidnplayr 243
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: 174\n"
3545 hidnplayr 244
 
245
        test    [eax + TCP_SOCKET.t_flags], TF_ACKNOW   ; we need to ACK
246
        jnz     TCP_send
247
 
248
        test    dl, TH_SYN + TH_RST                     ; we need to send a SYN or RST
249
        jnz     TCP_send
250
 
251
        mov     ebx, [eax + TCP_SOCKET.SND_UP]          ; when urgent pointer is beyond start of send bufer
252
        cmp     ebx, [eax + TCP_SOCKET.SND_UNA]
253
        ja      TCP_send
254
 
255
        test    dl, TH_FIN
256
        jz      .enter_persist  ; no reason to send, enter persist state
257
 
258
; FIN was set, only send if not already sent, or on retransmit
259
 
260
        test    [eax + TCP_SOCKET.t_flags], TF_SENTFIN
261
        jz      TCP_send
262
 
263
        mov     ebx, [eax + TCP_SOCKET.SND_NXT]
264
        cmp     ebx, [eax + TCP_SOCKET.SND_UNA]
265
        je      TCP_send
266
 
267
;--------------------
268
; Enter persist state (191)
269
 
270
  .enter_persist:
271
 
3600 hidnplayr 272
        cmp     [eax + STREAM_SOCKET.snd.size], 0                       ; Data ready to send?
3545 hidnplayr 273
        jne     @f
3603 hidnplayr 274
        and     [eax + TCP_SOCKET.timer_flags], not timer_flag_retransmission
3545 hidnplayr 275
        jne     @f
276
 
3603 hidnplayr 277
        test    [eax + TCP_SOCKET.timer_flags], timer_flag_persist      ; Persist timer already expired?
3600 hidnplayr 278
        jnz     @f
279
 
3556 hidnplayr 280
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: Entering persist state\n"
3545 hidnplayr 281
 
282
        mov     [eax + TCP_SOCKET.t_rxtshift], 0
283
        call    TCP_set_persist
284
       @@:
285
 
286
;----------------------------
287
; No reason to send a segment (219)
288
 
3556 hidnplayr 289
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: No reason to send a segment\n"
3545 hidnplayr 290
 
291
        pusha
292
        lea     ecx, [eax + SOCKET.mutex]
293
        call    mutex_unlock
294
        popa
295
 
296
; Fixme: returnvalue?
297
 
298
        ret
299
 
300
 
301
 
302
 
303
 
304
 
305
 
306
 
307
 
308
;-----------------------------------------------
309
;
310
; Send a segment (222)
311
;
312
; eax = socket pointer
313
; esi = data len
314
;  dl = flags
315
;
316
;-----------------------------------------------
317
align 4
318
TCP_send:
319
 
3556 hidnplayr 320
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: socket=%x length=%u flags=%x\n", eax, esi, dl
3545 hidnplayr 321
 
322
        push    eax                     ; save socket ptr
323
        push    esi                     ; and data length too
324
        mov     edi, sizeof.TCP_header  ; edi will contain headersize
325
 
326
;------------------------------------
327
; Send options with first SYN segment
328
 
329
        test    dl, TH_SYN
330
        jz      .options_done
331
 
332
        push    [eax + TCP_SOCKET.ISS]
333
        pop     [eax + TCP_SOCKET.SND_NXT]
334
 
335
        test    [eax + TCP_SOCKET.t_flags], TF_NOOPT
336
        jnz     .options_done
337
 
338
        mov     ecx, 1460                              ;;;; FIXME: use routing blablabla to determine MSS
339
        or      ecx, TCP_OPT_MAXSEG shl 24 + 4 shl 16
340
        bswap   ecx
341
        push    ecx
342
        add     di, 4
343
 
3556 hidnplayr 344
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: added maxseg option\n"
3545 hidnplayr 345
 
346
        test    [eax + TCP_SOCKET.t_flags], TF_REQ_SCALE
347
        jz      .no_scale
348
 
349
        test    dl, TH_ACK
350
        jz      .scale_opt
351
 
352
        test    [eax + TCP_SOCKET.t_flags], TF_RCVD_SCALE
353
        jz      .no_scale
354
 
355
  .scale_opt:
356
        mov     cl, [eax + TCP_SOCKET.request_r_scale]
357
        mov     ch, TCP_OPT_NOP
358
        pushw   cx
359
        pushw   TCP_OPT_WINDOW + 3 shl 8
360
        add     di, 4
361
 
3556 hidnplayr 362
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: added scale option\n"
3545 hidnplayr 363
 
364
  .no_scale:
365
  .no_syn:
366
 
367
;------------------------------------
368
; Make the timestamp option if needed
369
 
370
        test    [eax + TCP_SOCKET.t_flags], TF_REQ_TSTMP
371
        jz      .no_timestamp
372
 
373
        test    dl, TH_RST
374
        jnz     .no_timestamp
375
 
376
        test    dl, TH_ACK
377
        jz      .timestamp
378
 
379
        test    [eax + TCP_SOCKET.t_flags], TF_RCVD_TSTMP
380
        jz      .no_timestamp
381
 
382
  .timestamp:
383
        pushd   0
384
        pushd   [timer_ticks]
385
        pushd   TCP_OPT_NOP + TCP_OPT_NOP shl 8 + TCP_OPT_TIMESTAMP shl 16 + 10 shl 24
386
        add     di, 12
387
 
3556 hidnplayr 388
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: added timestamp\n"
3545 hidnplayr 389
 
390
  .no_timestamp:
391
 
392
        ; 
393
 
394
  .options_done:
395
 
396
; eax = socket ptr
397
; edx = flags
398
; edi = header size
399
; esi = data len
400
 
401
;---------------------------------------------
402
; check if we dont exceed the max segment size (270)
403
 
404
        add     esi, edi                        ; total TCP segment size
405
        cmp     esi, [eax + TCP_SOCKET.t_maxseg]
406
        jbe     .no_overflow
407
 
408
        mov     esi, [eax + TCP_SOCKET.t_maxseg]
409
        or      [eax + TCP_SOCKET.temp_bits], TCP_BIT_SENDALOT
410
  .no_overflow:
411
 
412
;-----------------------------------------------------------------
413
; Start by pushing all TCP header values in reverse order on stack
414
; (essentially, creating the tcp header on the stack!)
415
 
416
        pushw   0       ;        .UrgentPointer          dw ?
417
        pushw   0       ;        .Checksum               dw ?
418
        pushw   0x00a0  ;        .Window                 dw ?    ;;;;;;; FIXME (370)
419
        shl     edi, 2  ;        .DataOffset             db ?  only 4 left-most bits
420
        shl     dx, 8
421
        or      dx, di  ;        .Flags                  db ?
422
        pushw   dx
423
        shr     edi, 2  ;        .DataOffset             db ?
424
 
425
        push    [eax + TCP_SOCKET.RCV_NXT]      ;        .AckNumber              dd ?
426
        ntohd   [esp]
427
 
428
        push    [eax + TCP_SOCKET.SND_NXT]      ;        .SequenceNumber         dd ?
429
        ntohd   [esp]
430
 
431
        push    [eax + TCP_SOCKET.RemotePort]   ;        .DestinationPort        dw ?
432
        push    [eax + TCP_SOCKET.LocalPort]    ;        .SourcePort             dw ?
433
 
434
        push    edi                     ; header size
435
 
436
;---------------------
437
; Create the IP packet
438
 
439
        mov     ecx, esi
440
 
441
        mov     ebx, [eax + SOCKET.device]
442
        mov     edx, [eax + IP_SOCKET.LocalIP]  ; source ip
443
        mov     eax, [eax + IP_SOCKET.RemoteIP] ; dest ip
444
        mov     di, IP_PROTO_TCP shl 8 + 128
445
        call    IPv4_output
446
        jz      .ip_error
447
 
448
;-----------------------------------------
449
; Move TCP header from stack to TCP packet
450
 
451
        push    ecx
452
        mov     ecx, [esp + 4]
453
        lea     esi, [esp + 8]
454
        shr     ecx, 2                  ; count is in bytes, we will work with dwords
455
        rep     movsd
456
        pop     ecx                     ; full TCP packet size
457
 
458
        pop     esi                     ; headersize
459
        add     esp, esi                ; remove it from stack
460
 
461
        push    edx                     ; packet size for send proc
462
        push    eax                     ; packet ptr for send proc
463
 
464
        mov     edx, edi                ; begin of data
465
        sub     edx, esi                ; begin of packet (edi = begin of data)
466
        push    ecx
467
        sub     ecx, esi                ; data size
468
 
469
;--------------
470
; Copy the data
471
 
472
; eax = ptr to ring struct
473
; ecx = buffer size
474
; edi = ptr to buffer
475
 
476
        mov     eax, [esp + 16]                 ; get socket ptr
477
 
478
        push    edx
479
        push    [eax + TCP_SOCKET.SND_NXT]      ; we'll need this for timing the transmission
480
        test    ecx, ecx
481
        jz      .nodata
482
        mov     edx, [eax + TCP_SOCKET.SND_NXT]
483
        add     [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number <<< CHECKME
484
        sub     edx, [eax + TCP_SOCKET.SND_UNA] ; offset
485
        add     eax, STREAM_SOCKET.snd
486
        call    SOCKET_ring_read
487
  .nodata:
488
        pop     edi
489
        pop     esi                             ; begin of data
490
        pop     ecx                             ; full packet size
491
        mov     eax, [esp + 12]                 ; socket ptr
492
 
493
;----------------------------------
494
; initialize retransmit timer (400)
495
 
496
;TODO: check t_force and persist
497
 
498
        test    [esi + TCP_header.Flags], TH_SYN + TH_FIN       ; syn and fin take a sequence number
499
        jz      @f
500
        inc     [eax + TCP_SOCKET.SND_NXT]
501
        test    [esi + TCP_header.Flags], TH_FIN
502
        jz      @f
503
        or      [eax + TCP_SOCKET.t_flags], TF_SENTFIN          ; if we sent a fin, set the sentfin flag
504
       @@:
505
 
506
        mov     edx, [eax + TCP_SOCKET.SND_NXT]
507
        cmp     edx, [eax + TCP_SOCKET.SND_MAX]                 ; is this a retransmission?
508
        jbe     @f
509
        mov     [eax + TCP_SOCKET.SND_MAX], edx                 ; [eax + TCP_SOCKET.SND_NXT] from before we updated it
510
 
511
        cmp     [eax + TCP_SOCKET.t_rtt], 0                     ; are we currently timing anything?
512
        je      @f
513
        mov     [eax + TCP_SOCKET.t_rtt], 1                     ; nope, start transmission timer
514
        mov     [eax + TCP_SOCKET.t_rtseq], edi
515
;TODO: update stats
516
       @@:
517
 
518
; set retransmission timer if not already set, and not doing an ACK or keepalive probe
3600 hidnplayr 519
        test    [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
520
        jnz     .retransmit_set
3545 hidnplayr 521
 
522
        cmp     edx, [eax + TCP_SOCKET.SND_UNA]                 ; edx is still [eax + TCP_SOCKET.SND_NXT]
523
        je      .retransmit_set
524
 
525
        mov     edx, [eax + TCP_SOCKET.t_rxtcur]
526
        mov     [eax + TCP_SOCKET.timer_retransmission], edx
3603 hidnplayr 527
        or      [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
3545 hidnplayr 528
 
3600 hidnplayr 529
        test    [eax + TCP_SOCKET.timer_flags], timer_flag_persist
530
        jz      .retransmit_set
3603 hidnplayr 531
        and     [eax + TCP_SOCKET.timer_flags], not timer_flag_persist
3545 hidnplayr 532
        mov     [eax + TCP_SOCKET.t_rxtshift], 0
533
 
534
  .retransmit_set:
535
 
536
;--------------------
537
; Create the checksum
538
 
539
        TCP_checksum (eax + IP_SOCKET.LocalIP), (eax + IP_SOCKET.RemoteIP)
540
        mov     [esi + TCP_header.Checksum], dx
541
 
542
;----------------
543
; Send the packet
544
 
3556 hidnplayr 545
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: Sending with device %x\n", ebx
3545 hidnplayr 546
        call    [ebx + NET_DEVICE.transmit]
547
        jnz     .send_error
548
 
549
;---------------
550
; Ok, data sent!
551
 
552
        pop     ecx
553
        pop     eax
554
 
3644 hidnplayr 555
        call    NET_ptr_to_num4
556
        inc     [TCP_segments_tx + edi]
3545 hidnplayr 557
 
558
; update advertised receive window
559
        test    ecx, ecx
560
        jz      @f
561
        add     ecx, [eax + TCP_SOCKET.RCV_NXT]
562
        cmp     ecx, [eax + TCP_SOCKET.RCV_ADV]
563
        jbe     @f
564
        mov     [eax + TCP_SOCKET.RCV_ADV], ecx
565
       @@:
566
 
567
; update last ack sent
568
        push    [eax + TCP_SOCKET.RCV_NXT]
569
        pop     [eax + TCP_SOCKET.last_ack_sent]
570
 
571
; and flags
572
        and     [eax + TCP_SOCKET.t_flags], not (TF_ACKNOW + TF_DELACK)
573
 
574
;--------------
575
; unlock socket
576
 
3652 hidnplayr 577
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: unlocking socket 0x%x\n", eax
578
 
3545 hidnplayr 579
        push    eax
580
        lea     ecx, [eax + SOCKET.mutex]
581
        call    mutex_unlock
582
        pop     eax
583
 
584
;-----------------------------
585
; Check if we need more output
586
 
587
        test    [eax + TCP_SOCKET.temp_bits], TCP_BIT_SENDALOT
588
        jnz     TCP_output.again
589
 
3556 hidnplayr 590
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: success!\n"
3545 hidnplayr 591
 
592
        xor     eax, eax
593
        ret
594
 
595
 
596
  .ip_error:
597
        pop     ecx
598
        add     esp, ecx
599
        add     esp, 4
600
        pop     eax
601
 
602
        mov     [eax + TCP_SOCKET.timer_retransmission], TCP_time_re_min
3602 hidnplayr 603
        or      [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
3545 hidnplayr 604
 
605
        lea     ecx, [eax + SOCKET.mutex]
606
        call    mutex_unlock
607
 
3602 hidnplayr 608
        DEBUGF  DEBUG_NETWORK_ERROR, "TCP_send: IP error\n"
3545 hidnplayr 609
 
610
        or      eax, -1
611
        ret
612
 
613
 
614
  .send_error:
3652 hidnplayr 615
        add     esp, 4
616
        pop     eax
3545 hidnplayr 617
 
618
        lea     ecx, [eax + SOCKET.mutex]
619
        call    mutex_unlock
620
 
3602 hidnplayr 621
        DEBUGF  DEBUG_NETWORK_ERROR, "TCP_send: sending failed\n"
3545 hidnplayr 622
 
623
        or      eax, -2
624
        ret
625