Subversion Repositories Kolibri OS

Rev

Rev 1885 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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