Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. ;----------------------
  3. ; 160 ms timer
  4. ;----------------------
  5. macro   TCP_timer_160ms {
  6.  
  7. local   .loop
  8. local   .exit
  9.  
  10.         mov     eax, net_sockets
  11.   .loop:
  12.         mov     eax, [eax + SOCKET.NextPtr]
  13.         or      eax, eax
  14.         jz      .exit
  15.  
  16.         cmp     [eax + SOCKET.Protocol], IP_PROTO_TCP           ;;; We should also check if family is AF_INET
  17.         jne     .loop
  18.  
  19.         dec     [eax + TCP_SOCKET.timer_ack]
  20.         jnz     .loop
  21.  
  22.         DEBUGF  1,"TCP ack for socket %x expired, time to piggyback!\n", eax
  23.  
  24.         push    eax
  25.         call    TCP_respond_socket
  26.         pop     eax
  27.  
  28.         jmp     .loop
  29.  
  30.   .exit:
  31.  
  32. }
  33.  
  34.  
  35. ;----------------------
  36. ; 640 ms timer
  37. ;----------------------
  38. macro   TCP_timer_640ms {
  39.  
  40. local   .loop
  41. local   .exit
  42.  
  43. ; Update TCP sequence number
  44.  
  45.         add     [TCP_sequence_num], 64000
  46.  
  47. ; scan through all the active TCP sockets, decrementing ALL timers
  48. ; timers do not have the chance to wrap because the keepalive timer will kill the socket when it expires
  49.  
  50.         mov     eax, net_sockets
  51.   .loop:
  52.         mov     eax, [eax + SOCKET.NextPtr]
  53.   .check_only:
  54.         or      eax, eax
  55.         jz      .exit
  56.  
  57.         cmp     [eax + SOCKET.Domain], AF_INET4
  58.         jne     .loop
  59.  
  60.         cmp     [eax + SOCKET.Protocol], IP_PROTO_TCP
  61.         jne     .loop
  62.  
  63.  
  64. ;---------------
  65.  
  66.         cmp     [eax + SOCKET.lock], 0
  67.         jz      @f
  68.  
  69.         DEBUGF  1,"\nlocked\n"
  70.        @@:
  71.  
  72. ;-----------
  73.  
  74.         inc     [eax + TCP_SOCKET.t_idle]
  75.         dec     [eax + TCP_SOCKET.timer_retransmission]
  76.         jnz     .check_more2
  77.  
  78.         DEBUGF  1,"socket %x: Retransmission timer expired\n", eax
  79.  
  80.         push    eax
  81.         call    TCP_output
  82.         pop     eax
  83.  
  84.   .check_more2:
  85.         dec     [eax + TCP_SOCKET.timer_keepalive]
  86.         jnz     .check_more3
  87.  
  88.         DEBUGF  1,"socket %x: Keepalive expired\n", eax
  89.  
  90.         call    TCP_close
  91.         jmp     .loop
  92.  
  93.   .check_more3:
  94.         dec     [eax + TCP_SOCKET.timer_timed_wait]
  95.         jnz     .check_more5
  96.  
  97.         DEBUGF  1,"socket %x: 2MSL timer expired\n", eax
  98.  
  99.   .check_more5:
  100.         dec     [eax + TCP_SOCKET.timer_persist]
  101.         jnz     .loop
  102.  
  103.         DEBUGF  1,"socket %x: persist timer expired\n", eax
  104.  
  105.         jmp     .loop
  106.   .exit:
  107.  
  108. }