Subversion Repositories Kolibri OS

Rev

Rev 3711 | Rev 4366 | 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.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: socket locked\n"
  39.  
  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.  
  83.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: forcing data out\n"
  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:
  98.         and     [eax + TCP_SOCKET.timer_flags], not timer_flag_persist
  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
  130.         and     [eax + TCP_SOCKET.timer_flags], not timer_flag_retransmission
  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.  
  207.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: window=%d\n", ecx
  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
  221.  
  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.  
  243.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: 174\n"
  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.  
  272.         cmp     [eax + STREAM_SOCKET.snd.size], 0                       ; Data ready to send?
  273.         jne     @f
  274.         and     [eax + TCP_SOCKET.timer_flags], not timer_flag_retransmission
  275.         jne     @f
  276.  
  277.         test    [eax + TCP_SOCKET.timer_flags], timer_flag_persist      ; Persist timer already expired?
  278.         jnz     @f
  279.  
  280.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: Entering persist state\n"
  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.  
  289.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_output: No reason to send a segment\n"
  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.  
  320.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: socket=%x length=%u flags=%x\n", eax, esi, dl
  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.  
  344.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: added maxseg option\n"
  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.  
  362.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: added scale option\n"
  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.  
  388.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: added timestamp\n"
  389.  
  390.   .no_timestamp:
  391.  
  392.         ; <Add additional options here>
  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.         mov     edx, [eax + IP_SOCKET.LocalIP]  ; source ip
  441.         mov     eax, [eax + IP_SOCKET.RemoteIP] ; dest ip
  442.         mov     di, IP_PROTO_TCP shl 8 + 128
  443.         call    IPv4_output
  444.         jz      .ip_error
  445.  
  446. ;-----------------------------------------
  447. ; Move TCP header from stack to TCP packet
  448.  
  449.         push    ecx
  450.         mov     ecx, [esp + 4]
  451.         lea     esi, [esp + 8]
  452.         shr     ecx, 2                  ; count is in bytes, we will work with dwords
  453.         rep movsd
  454.         pop     ecx                     ; full TCP packet size
  455.  
  456.         pop     esi                     ; headersize
  457.         add     esp, esi                ; remove it from stack
  458.  
  459.         push    edx                     ; packet size for send proc
  460.         push    eax                     ; packet ptr for send proc
  461.  
  462.         mov     edx, edi                ; begin of data
  463.         sub     edx, esi                ; begin of packet (edi = begin of data)
  464.         push    ecx
  465.         sub     ecx, esi                ; data size
  466.  
  467. ;--------------
  468. ; Copy the data
  469.  
  470. ; eax = ptr to ring struct
  471. ; ecx = buffer size
  472. ; edi = ptr to buffer
  473.  
  474.         mov     eax, [esp + 16]                 ; get socket ptr
  475.  
  476.         push    edx
  477.         push    [eax + TCP_SOCKET.SND_NXT]      ; we'll need this for timing the transmission
  478.         test    ecx, ecx
  479.         jz      .nodata
  480.         mov     edx, [eax + TCP_SOCKET.SND_NXT]
  481.         add     [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number <<< CHECKME
  482.         sub     edx, [eax + TCP_SOCKET.SND_UNA] ; offset
  483.         add     eax, STREAM_SOCKET.snd
  484.         call    SOCKET_ring_read
  485.   .nodata:
  486.         pop     edi
  487.         pop     esi                             ; begin of data
  488.         pop     ecx                             ; full packet size
  489.         mov     eax, [esp + 12]                 ; socket ptr
  490.  
  491. ;----------------------------------
  492. ; initialize retransmit timer (400)
  493.  
  494. ;TODO: check t_force and persist
  495.  
  496.         test    [esi + TCP_header.Flags], TH_SYN + TH_FIN       ; syn and fin take a sequence number
  497.         jz      @f
  498.         inc     [eax + TCP_SOCKET.SND_NXT]
  499.         test    [esi + TCP_header.Flags], TH_FIN
  500.         jz      @f
  501.         or      [eax + TCP_SOCKET.t_flags], TF_SENTFIN          ; if we sent a fin, set the sentfin flag
  502.        @@:
  503.  
  504.         mov     edx, [eax + TCP_SOCKET.SND_NXT]
  505.         cmp     edx, [eax + TCP_SOCKET.SND_MAX]                 ; is this a retransmission?
  506.         jbe     @f
  507.         mov     [eax + TCP_SOCKET.SND_MAX], edx                 ; [eax + TCP_SOCKET.SND_NXT] from before we updated it
  508.  
  509.         cmp     [eax + TCP_SOCKET.t_rtt], 0                     ; are we currently timing anything?
  510.         je      @f
  511.         mov     [eax + TCP_SOCKET.t_rtt], 1                     ; nope, start transmission timer
  512.         mov     [eax + TCP_SOCKET.t_rtseq], edi
  513. ;TODO: update stats
  514.        @@:
  515.  
  516. ; set retransmission timer if not already set, and not doing an ACK or keepalive probe
  517.         test    [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
  518.         jnz     .retransmit_set
  519.  
  520.         cmp     edx, [eax + TCP_SOCKET.SND_UNA]                 ; edx is still [eax + TCP_SOCKET.SND_NXT]
  521.         je      .retransmit_set
  522.  
  523.         mov     edx, [eax + TCP_SOCKET.t_rxtcur]
  524.         mov     [eax + TCP_SOCKET.timer_retransmission], edx
  525.         or      [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
  526.  
  527.         test    [eax + TCP_SOCKET.timer_flags], timer_flag_persist
  528.         jz      .retransmit_set
  529.         and     [eax + TCP_SOCKET.timer_flags], not timer_flag_persist
  530.         mov     [eax + TCP_SOCKET.t_rxtshift], 0
  531.  
  532.   .retransmit_set:
  533.  
  534. ;--------------------
  535. ; Create the checksum
  536.  
  537.         TCP_checksum (eax + IP_SOCKET.LocalIP), (eax + IP_SOCKET.RemoteIP)
  538.         mov     [esi + TCP_header.Checksum], dx
  539.  
  540. ;----------------
  541. ; Send the packet
  542.  
  543.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: Sending with device %x\n", ebx
  544.         call    [ebx + NET_DEVICE.transmit]
  545.         jnz     .send_error
  546.  
  547. ;---------------
  548. ; Ok, data sent!
  549.  
  550.         pop     ecx
  551.         pop     eax
  552.  
  553.         call    NET_ptr_to_num4
  554.         inc     [TCP_segments_tx + edi]
  555.  
  556. ; update advertised receive window
  557.         test    ecx, ecx
  558.         jz      @f
  559.         add     ecx, [eax + TCP_SOCKET.RCV_NXT]
  560.         cmp     ecx, [eax + TCP_SOCKET.RCV_ADV]
  561.         jbe     @f
  562.         mov     [eax + TCP_SOCKET.RCV_ADV], ecx
  563.        @@:
  564.  
  565. ; update last ack sent
  566.         push    [eax + TCP_SOCKET.RCV_NXT]
  567.         pop     [eax + TCP_SOCKET.last_ack_sent]
  568.  
  569. ; and flags
  570.         and     [eax + TCP_SOCKET.t_flags], not (TF_ACKNOW + TF_DELACK)
  571.  
  572. ;--------------
  573. ; unlock socket
  574.  
  575.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: unlocking socket 0x%x\n", eax
  576.  
  577.         push    eax
  578.         lea     ecx, [eax + SOCKET.mutex]
  579.         call    mutex_unlock
  580.         pop     eax
  581.  
  582. ;-----------------------------
  583. ; Check if we need more output
  584.  
  585.         test    [eax + TCP_SOCKET.temp_bits], TCP_BIT_SENDALOT
  586.         jnz     TCP_output.again
  587.  
  588.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_send: success!\n"
  589.  
  590.         xor     eax, eax
  591.         ret
  592.  
  593.  
  594.   .ip_error:
  595.         pop     ecx
  596.         add     esp, ecx
  597.         add     esp, 4
  598.         pop     eax
  599.  
  600.         mov     [eax + TCP_SOCKET.timer_retransmission], TCP_time_re_min
  601.         or      [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
  602.  
  603.         lea     ecx, [eax + SOCKET.mutex]
  604.         call    mutex_unlock
  605.  
  606.         DEBUGF  DEBUG_NETWORK_ERROR, "TCP_send: IP error\n"
  607.  
  608.         or      eax, -1
  609.         ret
  610.  
  611.  
  612.   .send_error:
  613.         add     esp, 4
  614.         pop     eax
  615.  
  616.         lea     ecx, [eax + SOCKET.mutex]
  617.         call    mutex_unlock
  618.  
  619.         DEBUGF  DEBUG_NETWORK_ERROR, "TCP_send: sending failed\n"
  620.  
  621.         or      eax, -2
  622.         ret
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.