Subversion Repositories Kolibri OS

Rev

Rev 1733 | 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.         inc     [eax + TCP_SOCKET.t_idle]
  64.         dec     [eax + TCP_SOCKET.timer_retransmission]
  65.         jnz     .check_more2
  66.  
  67.         DEBUGF  1,"socket %x: Retransmission timer expired\n", eax
  68.  
  69.         push    eax
  70.         call    TCP_output
  71.         pop     eax
  72.  
  73.   .check_more2:
  74.         dec     [eax + TCP_SOCKET.timer_keepalive]
  75.         jnz     .check_more3
  76.  
  77.         DEBUGF  1,"socket %x: Keepalive expired\n", eax
  78.  
  79.         call    TCP_close
  80.         jmp     .loop
  81.  
  82.   .check_more3:
  83.         dec     [eax + TCP_SOCKET.timer_timed_wait]
  84.         jnz     .check_more5
  85.  
  86.         DEBUGF  1,"socket %x: 2MSL timer expired\n", eax
  87.  
  88.   .check_more5:
  89.         dec     [eax + TCP_SOCKET.timer_persist]
  90.         jnz     .loop
  91.  
  92.         DEBUGF  1,"socket %x: persist timer expired\n", eax
  93.  
  94.         jmp     .loop
  95.   .exit:
  96.  
  97. }