Subversion Repositories Kolibri OS

Rev

Rev 3602 | Rev 3652 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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