Subversion Repositories Kolibri OS

Rev

Rev 2936 | Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                                 ;;
  3. ;; Copyright (C) KolibriOS team 2004-2011. 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: 2955 $
  18.  
  19. ;----------------------
  20. ; 160 ms timer
  21. ;----------------------
  22. macro   TCP_timer_160ms {
  23.  
  24. local   .loop
  25. local   .exit
  26.  
  27.         mov     ebx, net_sockets
  28.   .loop:
  29.         mov     ebx, [ebx + SOCKET.NextPtr]
  30.         or      ebx, ebx
  31.         jz      .exit
  32.  
  33.         cmp     [ebx + SOCKET.Domain], AF_INET4
  34.         jne     .loop
  35.  
  36.         cmp     [ebx + SOCKET.Protocol], IP_PROTO_TCP
  37.         jne     .loop
  38.  
  39.         test    [ebx + TCP_SOCKET.t_flags], TF_DELACK
  40.         jz      .loop
  41.         and     [ebx + TCP_SOCKET.t_flags], not (TF_DELACK)
  42.  
  43.         push    ebx
  44.         mov     cl, TH_ACK
  45.         call    TCP_respond_socket
  46. ;        and     [ebx + TCP_SOCKET.t_flags], TF_ACKNOW   ;;
  47. ;        mov     eax, ebx                                ;;
  48. ;        call    TCP_output                              ;;
  49.         pop     ebx
  50.  
  51.         jmp     .loop
  52.  
  53.   .exit:
  54.  
  55. }
  56.  
  57.  
  58. ;----------------------
  59. ; 640 ms timer
  60. ;----------------------
  61. macro   TCP_timer_640ms {
  62.  
  63. local   .loop
  64. local   .exit
  65.  
  66. ; Update TCP sequence number
  67.  
  68.         add     [TCP_sequence_num], 64000
  69.  
  70. ; scan through all the active TCP sockets, decrementing ALL timers
  71. ; timers do not have the chance to wrap because the keepalive timer will kill the socket when it expires
  72.  
  73.         mov     eax, net_sockets
  74.   .loop:
  75.         mov     eax, [eax + SOCKET.NextPtr]
  76.   .check_only:
  77.         or      eax, eax
  78.         jz      .exit
  79.  
  80.         cmp     [eax + SOCKET.Domain], AF_INET4
  81.         jne     .loop
  82.  
  83.         cmp     [eax + SOCKET.Protocol], IP_PROTO_TCP
  84.         jne     .loop
  85.  
  86.         inc     [eax + TCP_SOCKET.t_idle]
  87.         dec     [eax + TCP_SOCKET.timer_retransmission]
  88.         jnz     .check_more2
  89.  
  90.         DEBUGF  1,"socket %x: Retransmission timer expired\n", eax
  91.  
  92.         push    eax
  93.         call    TCP_output
  94.         pop     eax
  95.  
  96.   .check_more2:
  97.         dec     [eax + TCP_SOCKET.timer_keepalive]
  98.         jnz     .check_more3
  99.  
  100.         DEBUGF  1,"socket %x: Keepalive expired\n", eax
  101.  
  102.         push    eax
  103.         call    TCP_disconnect
  104.         pop     eax
  105.         jmp     .loop
  106.  
  107.   .check_more3:
  108.         dec     [eax + TCP_SOCKET.timer_timed_wait]
  109.         jnz     .check_more5
  110.  
  111.         DEBUGF  1,"socket %x: 2MSL timer expired\n", eax
  112.  
  113.   .check_more5:
  114.         dec     [eax + TCP_SOCKET.timer_persist]
  115.         jnz     .loop
  116.  
  117.         DEBUGF  1,"socket %x: persist timer expired\n", eax
  118.  
  119.         call    TCP_set_persist
  120.         mov     [eax + TCP_SOCKET.t_force], 1
  121.         push    eax
  122.         call    TCP_output
  123.         pop     eax
  124.         mov     [eax + TCP_SOCKET.t_force], 0
  125.  
  126.         jmp     .loop
  127.   .exit:
  128.  
  129. }
  130.  
  131.  
  132.  
  133. ; eax = socket
  134.  
  135. TCP_cancel_timers:
  136.  
  137.         push    eax edi
  138.  
  139.         lea     edi, [eax + TCP_SOCKET.timer_retransmission]
  140.         xor     eax, eax
  141.         stosd
  142.         stosd
  143.         stosd
  144.         stosd
  145.         stosd
  146.  
  147.         pop     edi eax
  148.  
  149.  
  150.         ret