Subversion Repositories Kolibri OS

Rev

Rev 2936 | 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: 2955 $
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
2936 hidnplayr 46
;        and     [ebx + TCP_SOCKET.t_flags], TF_ACKNOW   ;;
47
;        mov     eax, ebx                                ;;
48
;        call    TCP_output                              ;;
2879 hidnplayr 49
        pop     ebx
1733 hidnplayr 50
 
2879 hidnplayr 51
        jmp     .loop
1733 hidnplayr 52
 
53
  .exit:
54
 
55
}
56
 
57
 
58
;----------------------
59
; 640 ms timer
60
;----------------------
2879 hidnplayr 61
macro   TCP_timer_640ms {
1733 hidnplayr 62
 
2879 hidnplayr 63
local   .loop
64
local   .exit
1733 hidnplayr 65
 
66
; Update TCP sequence number
67
 
2879 hidnplayr 68
        add     [TCP_sequence_num], 64000
1733 hidnplayr 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
 
2879 hidnplayr 73
        mov     eax, net_sockets
1733 hidnplayr 74
  .loop:
2879 hidnplayr 75
        mov     eax, [eax + SOCKET.NextPtr]
1733 hidnplayr 76
  .check_only:
2879 hidnplayr 77
        or      eax, eax
78
        jz      .exit
1733 hidnplayr 79
 
2879 hidnplayr 80
        cmp     [eax + SOCKET.Domain], AF_INET4
81
        jne     .loop
1733 hidnplayr 82
 
2879 hidnplayr 83
        cmp     [eax + SOCKET.Protocol], IP_PROTO_TCP
84
        jne     .loop
1733 hidnplayr 85
 
2879 hidnplayr 86
        inc     [eax + TCP_SOCKET.t_idle]
87
        dec     [eax + TCP_SOCKET.timer_retransmission]
88
        jnz     .check_more2
1733 hidnplayr 89
 
2879 hidnplayr 90
        DEBUGF  1,"socket %x: Retransmission timer expired\n", eax
1733 hidnplayr 91
 
2879 hidnplayr 92
        push    eax
93
        call    TCP_output
94
        pop     eax
1733 hidnplayr 95
 
96
  .check_more2:
2879 hidnplayr 97
        dec     [eax + TCP_SOCKET.timer_keepalive]
98
        jnz     .check_more3
1733 hidnplayr 99
 
2879 hidnplayr 100
        DEBUGF  1,"socket %x: Keepalive expired\n", eax
1733 hidnplayr 101
 
2936 hidnplayr 102
        push    eax
2879 hidnplayr 103
        call    TCP_disconnect
2936 hidnplayr 104
        pop     eax
2879 hidnplayr 105
        jmp     .loop
1733 hidnplayr 106
 
107
  .check_more3:
2879 hidnplayr 108
        dec     [eax + TCP_SOCKET.timer_timed_wait]
109
        jnz     .check_more5
1733 hidnplayr 110
 
2879 hidnplayr 111
        DEBUGF  1,"socket %x: 2MSL timer expired\n", eax
1733 hidnplayr 112
 
113
  .check_more5:
2879 hidnplayr 114
        dec     [eax + TCP_SOCKET.timer_persist]
115
        jnz     .loop
1733 hidnplayr 116
 
2879 hidnplayr 117
        DEBUGF  1,"socket %x: persist timer expired\n", eax
1733 hidnplayr 118
 
2955 hidnplayr 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
 
2879 hidnplayr 126
        jmp     .loop
1733 hidnplayr 127
  .exit:
128
 
1773 hidnplayr 129
}
130
 
131
 
132
 
133
; eax = socket
134
 
135
TCP_cancel_timers:
136
 
2879 hidnplayr 137
        push    eax edi
1773 hidnplayr 138
 
2879 hidnplayr 139
        lea     edi, [eax + TCP_SOCKET.timer_retransmission]
140
        xor     eax, eax
141
        stosd
142
        stosd
143
        stosd
144
        stosd
145
        stosd
1773 hidnplayr 146
 
2879 hidnplayr 147
        pop     edi eax
1773 hidnplayr 148
 
149
 
2879 hidnplayr 150
        ret