This source file includes following definitions.
- nr_set_timer
- nr_reset_timer
- nr_timer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <linux/config.h>
20 #ifdef CONFIG_NETROM
21 #include <linux/errno.h>
22 #include <linux/types.h>
23 #include <linux/socket.h>
24 #include <linux/in.h>
25 #include <linux/kernel.h>
26 #include <linux/sched.h>
27 #include <linux/timer.h>
28 #include <linux/string.h>
29 #include <linux/sockios.h>
30 #include <linux/net.h>
31 #include <net/ax25.h>
32 #include <linux/inet.h>
33 #include <linux/netdevice.h>
34 #include <linux/skbuff.h>
35 #include <net/sock.h>
36 #include <asm/segment.h>
37 #include <asm/system.h>
38 #include <linux/fcntl.h>
39 #include <linux/mm.h>
40 #include <linux/interrupt.h>
41 #include <net/netrom.h>
42
43 static void nr_timer(unsigned long);
44
45
46
47
48 void nr_set_timer(struct sock *sk)
49 {
50 unsigned long flags;
51
52 save_flags(flags);
53 cli();
54 del_timer(&sk->timer);
55 restore_flags(flags);
56
57 sk->timer.next = sk->timer.prev = NULL;
58 sk->timer.data = (unsigned long)sk;
59 sk->timer.function = &nr_timer;
60
61 sk->timer.expires = jiffies+10;
62 add_timer(&sk->timer);
63 }
64
65 static void nr_reset_timer(struct sock *sk)
66 {
67 unsigned long flags;
68
69 save_flags(flags);
70 cli();
71 del_timer(&sk->timer);
72 restore_flags(flags);
73
74 sk->timer.data = (unsigned long)sk;
75 sk->timer.function = &nr_timer;
76 sk->timer.expires = jiffies+10;
77 add_timer(&sk->timer);
78 }
79
80
81
82
83
84
85
86 static void nr_timer(unsigned long param)
87 {
88 struct sock *sk = (struct sock *)param;
89
90 switch (sk->nr->state) {
91 case NR_STATE_0:
92
93
94 if (sk->destroy || (sk->state == TCP_LISTEN && sk->dead)) {
95 del_timer(&sk->timer);
96 nr_destroy_socket(sk);
97 return;
98 }
99 break;
100
101 case NR_STATE_3:
102
103
104
105 if (sk->rmem_alloc < (sk->rcvbuf / 2) && (sk->nr->condition & OWN_RX_BUSY_CONDITION)) {
106 sk->nr->condition &= ~OWN_RX_BUSY_CONDITION;
107 nr_write_internal(sk, NR_INFOACK);
108 sk->nr->condition &= ~ACK_PENDING_CONDITION;
109 sk->nr->vl = sk->nr->vr;
110 break;
111 }
112
113
114
115 nr_kick(sk);
116 break;
117
118 default:
119 break;
120 }
121
122 if (sk->nr->t2timer > 0 && --sk->nr->t2timer == 0) {
123 if (sk->nr->state == NR_STATE_3) {
124 if (sk->nr->condition & ACK_PENDING_CONDITION) {
125 sk->nr->condition &= ~ACK_PENDING_CONDITION;
126 nr_enquiry_response(sk);
127 }
128 }
129 }
130
131 if (sk->nr->t4timer > 0 && --sk->nr->t4timer == 0) {
132 sk->nr->condition &= ~PEER_RX_BUSY_CONDITION;
133 }
134
135 if (sk->nr->t1timer == 0 || --sk->nr->t1timer > 0) {
136 nr_reset_timer(sk);
137 return;
138 }
139
140 switch (sk->nr->state) {
141 case NR_STATE_1:
142 if (sk->nr->n2count == sk->nr->n2) {
143 nr_clear_queues(sk);
144 sk->nr->state = NR_STATE_0;
145 sk->state = TCP_CLOSE;
146 sk->err = ETIMEDOUT;
147 if (!sk->dead)
148 sk->state_change(sk);
149 sk->dead = 1;
150 } else {
151 sk->nr->n2count++;
152 nr_write_internal(sk, NR_CONNREQ);
153 }
154 break;
155
156 case NR_STATE_2:
157 if (sk->nr->n2count == sk->nr->n2) {
158 nr_clear_queues(sk);
159 sk->nr->state = NR_STATE_0;
160 sk->state = TCP_CLOSE;
161 sk->err = ETIMEDOUT;
162 if (!sk->dead)
163 sk->state_change(sk);
164 sk->dead = 1;
165 } else {
166 sk->nr->n2count++;
167 nr_write_internal(sk, NR_DISCREQ);
168 }
169 break;
170
171 case NR_STATE_3:
172 if (sk->nr->n2count == sk->nr->n2) {
173 nr_clear_queues(sk);
174 sk->nr->state = NR_STATE_0;
175 sk->state = TCP_CLOSE;
176 sk->err = ETIMEDOUT;
177 if (!sk->dead)
178 sk->state_change(sk);
179 sk->dead = 1;
180 } else {
181 sk->nr->n2count++;
182 nr_requeue_frames(sk);
183 }
184 break;
185 }
186
187 sk->nr->t1timer = sk->nr->t1 = nr_calculate_t1(sk);
188
189 nr_set_timer(sk);
190 }
191
192 #endif