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