blob: 8354ae40ec85b5380dd24d49749452b66fd884a5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * llc_c_ac.c - actions performed during connection state transition.
3 *
4 * Description:
5 * Functions in this module are implementation of connection component actions
6 * Details of actions can be found in IEEE-802.2 standard document.
7 * All functions have one connection and one event as input argument. All of
8 * them return 0 On success and 1 otherwise.
9 *
10 * Copyright (c) 1997 by Procom Technology, Inc.
11 * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
12 *
13 * This program can be redistributed or modified under the terms of the
14 * GNU General Public License as published by the Free Software Foundation.
15 * This program is distributed without any warranty or implied warranty
16 * of merchantability or fitness for a particular purpose.
17 *
18 * See the GNU General Public License for more details.
19 */
20#include <linux/netdevice.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090021#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <net/llc_conn.h>
23#include <net/llc_sap.h>
24#include <net/sock.h>
25#include <net/llc_c_ev.h>
26#include <net/llc_c_ac.h>
27#include <net/llc_c_st.h>
28#include <net/llc_pdu.h>
29#include <net/llc.h>
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb);
33static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb);
34static int llc_conn_ac_data_confirm(struct sock *sk, struct sk_buff *ev);
35
36static int llc_conn_ac_inc_npta_value(struct sock *sk, struct sk_buff *skb);
37
38static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
39 struct sk_buff *skb);
40
41static int llc_conn_ac_set_p_flag_1(struct sock *sk, struct sk_buff *skb);
42
43#define INCORRECT 0
44
45int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb)
46{
47 struct llc_sock *llc = llc_sk(sk);
48
49 if (llc->remote_busy_flag) {
50 u8 nr;
51 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
52
53 llc->remote_busy_flag = 0;
54 del_timer(&llc->busy_state_timer.timer);
55 nr = LLC_I_GET_NR(pdu);
56 llc_conn_resend_i_pdu_as_cmd(sk, nr, 0);
57 }
58 return 0;
59}
60
61int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb)
62{
Arnaldo Carvalho de Melod3894242005-09-22 07:57:21 -030063 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Arnaldo Carvalho de Melod3894242005-09-22 07:57:21 -030065 ev->ind_prim = LLC_CONN_PRIM;
66 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067}
68
69int llc_conn_ac_conn_confirm(struct sock *sk, struct sk_buff *skb)
70{
71 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
72
73 ev->cfm_prim = LLC_CONN_PRIM;
74 return 0;
75}
76
77static int llc_conn_ac_data_confirm(struct sock *sk, struct sk_buff *skb)
78{
79 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
80
81 ev->cfm_prim = LLC_DATA_PRIM;
82 return 0;
83}
84
85int llc_conn_ac_data_ind(struct sock *sk, struct sk_buff *skb)
86{
87 llc_conn_rtn_pdu(sk, skb);
88 return 0;
89}
90
91int llc_conn_ac_disc_ind(struct sock *sk, struct sk_buff *skb)
92{
93 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
94 u8 reason = 0;
95 int rc = 0;
96
97 if (ev->type == LLC_CONN_EV_TYPE_PDU) {
98 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
99
100 if (LLC_PDU_IS_RSP(pdu) &&
101 LLC_PDU_TYPE_IS_U(pdu) &&
102 LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_DM)
103 reason = LLC_DISC_REASON_RX_DM_RSP_PDU;
104 else if (LLC_PDU_IS_CMD(pdu) &&
105 LLC_PDU_TYPE_IS_U(pdu) &&
106 LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_DISC)
107 reason = LLC_DISC_REASON_RX_DISC_CMD_PDU;
108 } else if (ev->type == LLC_CONN_EV_TYPE_ACK_TMR)
109 reason = LLC_DISC_REASON_ACK_TMR_EXP;
Arnaldo Carvalho de Melobdcc66c2005-09-22 03:38:15 -0300110 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 rc = -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 if (!rc) {
113 ev->reason = reason;
114 ev->ind_prim = LLC_DISC_PRIM;
115 }
116 return rc;
117}
118
119int llc_conn_ac_disc_confirm(struct sock *sk, struct sk_buff *skb)
120{
121 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
122
123 ev->reason = ev->status;
124 ev->cfm_prim = LLC_DISC_PRIM;
125 return 0;
126}
127
128int llc_conn_ac_rst_ind(struct sock *sk, struct sk_buff *skb)
129{
130 u8 reason = 0;
131 int rc = 1;
132 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
133 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
134 struct llc_sock *llc = llc_sk(sk);
135
136 switch (ev->type) {
137 case LLC_CONN_EV_TYPE_PDU:
138 if (LLC_PDU_IS_RSP(pdu) &&
139 LLC_PDU_TYPE_IS_U(pdu) &&
140 LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR) {
141 reason = LLC_RESET_REASON_LOCAL;
142 rc = 0;
143 } else if (LLC_PDU_IS_CMD(pdu) &&
144 LLC_PDU_TYPE_IS_U(pdu) &&
145 LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME) {
146 reason = LLC_RESET_REASON_REMOTE;
147 rc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 }
149 break;
150 case LLC_CONN_EV_TYPE_ACK_TMR:
151 case LLC_CONN_EV_TYPE_P_TMR:
152 case LLC_CONN_EV_TYPE_REJ_TMR:
153 case LLC_CONN_EV_TYPE_BUSY_TMR:
154 if (llc->retry_count > llc->n2) {
155 reason = LLC_RESET_REASON_LOCAL;
156 rc = 0;
Arnaldo Carvalho de Melobdcc66c2005-09-22 03:38:15 -0300157 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 break;
159 }
160 if (!rc) {
161 ev->reason = reason;
162 ev->ind_prim = LLC_RESET_PRIM;
163 }
164 return rc;
165}
166
167int llc_conn_ac_rst_confirm(struct sock *sk, struct sk_buff *skb)
168{
169 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
170
171 ev->reason = 0;
172 ev->cfm_prim = LLC_RESET_PRIM;
173 return 0;
174}
175
176int llc_conn_ac_clear_remote_busy_if_f_eq_1(struct sock *sk,
177 struct sk_buff *skb)
178{
179 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
180
181 if (LLC_PDU_IS_RSP(pdu) &&
182 LLC_PDU_TYPE_IS_I(pdu) &&
183 LLC_I_PF_IS_1(pdu) && llc_sk(sk)->ack_pf)
184 llc_conn_ac_clear_remote_busy(sk, skb);
185 return 0;
186}
187
188int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2(struct sock *sk,
189 struct sk_buff *skb)
190{
191 struct llc_sock *llc = llc_sk(sk);
192
193 if (llc->data_flag == 2)
194 del_timer(&llc->rej_sent_timer.timer);
195 return 0;
196}
197
198int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
199{
200 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300201 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700202 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
204 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 struct llc_sap *sap = llc->sap;
206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
208 llc->daddr.lsap, LLC_PDU_CMD);
209 llc_pdu_init_as_disc_cmd(nskb, 1);
210 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300211 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 goto free;
213 llc_conn_send_pdu(sk, nskb);
214 llc_conn_ac_set_p_flag_1(sk, skb);
215 }
216out:
217 return rc;
218free:
219 kfree_skb(nskb);
220 goto out;
221}
222
223int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
224{
225 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300226 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700227 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
229 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 struct llc_sap *sap = llc->sap;
231 u8 f_bit;
232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 llc_pdu_decode_pf_bit(skb, &f_bit);
234 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
235 llc->daddr.lsap, LLC_PDU_RSP);
236 llc_pdu_init_as_dm_rsp(nskb, f_bit);
237 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300238 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 goto free;
240 llc_conn_send_pdu(sk, nskb);
241 }
242out:
243 return rc;
244free:
245 kfree_skb(nskb);
246 goto out;
247}
248
249int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
250{
251 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300252 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700253 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
255 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 struct llc_sap *sap = llc->sap;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
259 llc->daddr.lsap, LLC_PDU_RSP);
Arnaldo Carvalho de Melo838a75d2005-09-22 03:44:23 -0300260 llc_pdu_init_as_dm_rsp(nskb, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300262 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 goto free;
264 llc_conn_send_pdu(sk, nskb);
265 }
266out:
267 return rc;
268free:
269 kfree_skb(nskb);
270 goto out;
271}
272
273int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk, struct sk_buff *skb)
274{
275 u8 f_bit;
276 int rc = -ENOBUFS;
277 struct sk_buff *nskb;
278 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
279 struct llc_sock *llc = llc_sk(sk);
280
281 llc->rx_pdu_hdr = *((u32 *)pdu);
282 if (LLC_PDU_IS_CMD(pdu))
283 llc_pdu_decode_pf_bit(skb, &f_bit);
284 else
285 f_bit = 0;
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700286 nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
287 sizeof(struct llc_frmr_info));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 if (nskb) {
289 struct llc_sap *sap = llc->sap;
290
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
292 llc->daddr.lsap, LLC_PDU_RSP);
293 llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
294 llc->vR, INCORRECT);
295 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300296 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 goto free;
298 llc_conn_send_pdu(sk, nskb);
299 }
300out:
301 return rc;
302free:
303 kfree_skb(nskb);
304 goto out;
305}
306
307int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb)
308{
309 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300310 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700311 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
312 sizeof(struct llc_frmr_info));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
314 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 struct llc_sap *sap = llc->sap;
316 struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr;
317
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
319 llc->daddr.lsap, LLC_PDU_RSP);
Arnaldo Carvalho de Melo838a75d2005-09-22 03:44:23 -0300320 llc_pdu_init_as_frmr_rsp(nskb, pdu, 0, llc->vS,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 llc->vR, INCORRECT);
322 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300323 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 goto free;
325 llc_conn_send_pdu(sk, nskb);
326 }
327out:
328 return rc;
329free:
330 kfree_skb(nskb);
331 goto out;
332}
333
334int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
335{
336 u8 f_bit;
337 int rc = -ENOBUFS;
338 struct sk_buff *nskb;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300339 struct llc_sock *llc = llc_sk(sk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
341 llc_pdu_decode_pf_bit(skb, &f_bit);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700342 nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
343 sizeof(struct llc_frmr_info));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 struct llc_sap *sap = llc->sap;
346 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
347
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
349 llc->daddr.lsap, LLC_PDU_RSP);
350 llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
351 llc->vR, INCORRECT);
352 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300353 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 goto free;
355 llc_conn_send_pdu(sk, nskb);
356 }
357out:
358 return rc;
359free:
360 kfree_skb(nskb);
361 goto out;
362}
363
364int llc_conn_ac_send_i_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
365{
366 int rc;
367 struct llc_sock *llc = llc_sk(sk);
368 struct llc_sap *sap = llc->sap;
369
370 llc_pdu_header_init(skb, LLC_PDU_TYPE_I, sap->laddr.lsap,
371 llc->daddr.lsap, LLC_PDU_CMD);
372 llc_pdu_init_as_i_cmd(skb, 1, llc->vS, llc->vR);
373 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300374 if (likely(!rc)) {
Eric Biggersff339162019-10-06 14:24:25 -0700375 skb_get(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 llc_conn_send_pdu(sk, skb);
377 llc_conn_ac_inc_vs_by_1(sk, skb);
378 }
379 return rc;
380}
381
382static int llc_conn_ac_send_i_cmd_p_set_0(struct sock *sk, struct sk_buff *skb)
383{
384 int rc;
385 struct llc_sock *llc = llc_sk(sk);
386 struct llc_sap *sap = llc->sap;
387
388 llc_pdu_header_init(skb, LLC_PDU_TYPE_I, sap->laddr.lsap,
389 llc->daddr.lsap, LLC_PDU_CMD);
390 llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR);
391 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300392 if (likely(!rc)) {
Eric Biggersff339162019-10-06 14:24:25 -0700393 skb_get(skb);
394 llc_conn_send_pdu(sk, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 llc_conn_ac_inc_vs_by_1(sk, skb);
396 }
397 return rc;
398}
399
400int llc_conn_ac_send_i_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
401{
402 int rc;
403 struct llc_sock *llc = llc_sk(sk);
404 struct llc_sap *sap = llc->sap;
405
406 llc_pdu_header_init(skb, LLC_PDU_TYPE_I, sap->laddr.lsap,
407 llc->daddr.lsap, LLC_PDU_CMD);
408 llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR);
409 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300410 if (likely(!rc)) {
Eric Biggersff339162019-10-06 14:24:25 -0700411 skb_get(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 llc_conn_send_pdu(sk, skb);
413 llc_conn_ac_inc_vs_by_1(sk, skb);
414 }
415 return 0;
416}
417
418int llc_conn_ac_resend_i_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
419{
420 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
421 u8 nr = LLC_I_GET_NR(pdu);
422
423 llc_conn_resend_i_pdu_as_cmd(sk, nr, 0);
424 return 0;
425}
426
427int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,
428 struct sk_buff *skb)
429{
430 u8 nr;
431 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
432 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300433 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700434 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
436 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 struct llc_sap *sap = llc->sap;
438
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
440 llc->daddr.lsap, LLC_PDU_RSP);
441 llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
442 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300443 if (likely(!rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 llc_conn_send_pdu(sk, nskb);
445 else
446 kfree_skb(skb);
447 }
448 if (rc) {
449 nr = LLC_I_GET_NR(pdu);
450 rc = 0;
451 llc_conn_resend_i_pdu_as_cmd(sk, nr, 0);
452 }
453 return rc;
454}
455
456int llc_conn_ac_resend_i_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
457{
458 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
459 u8 nr = LLC_I_GET_NR(pdu);
460
461 llc_conn_resend_i_pdu_as_rsp(sk, nr, 1);
462 return 0;
463}
464
465int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
466{
467 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300468 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700469 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
471 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 struct llc_sap *sap = llc->sap;
473
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
475 llc->daddr.lsap, LLC_PDU_CMD);
476 llc_pdu_init_as_rej_cmd(nskb, 1, llc->vR);
477 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300478 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 goto free;
480 llc_conn_send_pdu(sk, nskb);
481 }
482out:
483 return rc;
484free:
485 kfree_skb(nskb);
486 goto out;
487}
488
489int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
490{
491 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300492 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700493 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494
495 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 struct llc_sap *sap = llc->sap;
497
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
499 llc->daddr.lsap, LLC_PDU_RSP);
Arnaldo Carvalho de Melo838a75d2005-09-22 03:44:23 -0300500 llc_pdu_init_as_rej_rsp(nskb, 1, llc->vR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300502 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 goto free;
504 llc_conn_send_pdu(sk, nskb);
505 }
506out:
507 return rc;
508free:
509 kfree_skb(nskb);
510 goto out;
511}
512
513int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
514{
515 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300516 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700517 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518
519 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 struct llc_sap *sap = llc->sap;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
523 llc->daddr.lsap, LLC_PDU_RSP);
Arnaldo Carvalho de Melo838a75d2005-09-22 03:44:23 -0300524 llc_pdu_init_as_rej_rsp(nskb, 0, llc->vR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300526 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 goto free;
528 llc_conn_send_pdu(sk, nskb);
529 }
530out:
531 return rc;
532free:
533 kfree_skb(nskb);
534 goto out;
535}
536
537int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
538{
539 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300540 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700541 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542
543 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 struct llc_sap *sap = llc->sap;
545
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
547 llc->daddr.lsap, LLC_PDU_CMD);
548 llc_pdu_init_as_rnr_cmd(nskb, 1, llc->vR);
549 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300550 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 goto free;
552 llc_conn_send_pdu(sk, nskb);
553 }
554out:
555 return rc;
556free:
557 kfree_skb(nskb);
558 goto out;
559}
560
561int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
562{
563 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300564 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700565 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566
567 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 struct llc_sap *sap = llc->sap;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
571 llc->daddr.lsap, LLC_PDU_RSP);
Arnaldo Carvalho de Melo838a75d2005-09-22 03:44:23 -0300572 llc_pdu_init_as_rnr_rsp(nskb, 1, llc->vR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300574 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 goto free;
576 llc_conn_send_pdu(sk, nskb);
577 }
578out:
579 return rc;
580free:
581 kfree_skb(nskb);
582 goto out;
583}
584
585int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
586{
587 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300588 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700589 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590
591 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 struct llc_sap *sap = llc->sap;
593
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
595 llc->daddr.lsap, LLC_PDU_RSP);
Arnaldo Carvalho de Melo838a75d2005-09-22 03:44:23 -0300596 llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300598 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 goto free;
600 llc_conn_send_pdu(sk, nskb);
601 }
602out:
603 return rc;
604free:
605 kfree_skb(nskb);
606 goto out;
607}
608
609int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb)
610{
611 struct llc_sock *llc = llc_sk(sk);
612
613 if (!llc->remote_busy_flag) {
614 llc->remote_busy_flag = 1;
615 mod_timer(&llc->busy_state_timer.timer,
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300616 jiffies + llc->busy_state_timer.expire);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 }
618 return 0;
619}
620
621int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
622{
623 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300624 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700625 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626
627 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 struct llc_sap *sap = llc->sap;
629
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
631 llc->daddr.lsap, LLC_PDU_RSP);
632 llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR);
633 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300634 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 goto free;
636 llc_conn_send_pdu(sk, nskb);
637 }
638out:
639 return rc;
640free:
641 kfree_skb(nskb);
642 goto out;
643}
644
645int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
646{
647 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300648 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700649 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650
651 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 struct llc_sap *sap = llc->sap;
653
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
655 llc->daddr.lsap, LLC_PDU_CMD);
656 llc_pdu_init_as_rr_cmd(nskb, 1, llc->vR);
657 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300658 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 goto free;
660 llc_conn_send_pdu(sk, nskb);
661 }
662out:
663 return rc;
664free:
665 kfree_skb(nskb);
666 goto out;
667}
668
669int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
670{
671 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300672 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700673 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674
675 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 struct llc_sap *sap = llc->sap;
677 u8 f_bit = 1;
678
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
680 llc->daddr.lsap, LLC_PDU_RSP);
681 llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
682 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300683 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 goto free;
685 llc_conn_send_pdu(sk, nskb);
686 }
687out:
688 return rc;
689free:
690 kfree_skb(nskb);
691 goto out;
692}
693
694int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
695{
696 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300697 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700698 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699
700 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 struct llc_sap *sap = llc->sap;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
704 llc->daddr.lsap, LLC_PDU_RSP);
Arnaldo Carvalho de Melo838a75d2005-09-22 03:44:23 -0300705 llc_pdu_init_as_rr_rsp(nskb, 1, llc->vR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300707 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 goto free;
709 llc_conn_send_pdu(sk, nskb);
710 }
711out:
712 return rc;
713free:
714 kfree_skb(nskb);
715 goto out;
716}
717
718int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
719{
720 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300721 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700722 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723
724 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 struct llc_sap *sap = llc->sap;
726
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
728 llc->daddr.lsap, LLC_PDU_RSP);
729 llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
730 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300731 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 goto free;
733 llc_conn_send_pdu(sk, nskb);
734 }
735out:
736 return rc;
737free:
738 kfree_skb(nskb);
739 goto out;
740}
741
742int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
743{
744 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300745 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700746 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747
748 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 struct llc_sap *sap = llc->sap;
750
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
752 llc->daddr.lsap, LLC_PDU_RSP);
753 llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
754 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300755 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 goto free;
757 llc_conn_send_pdu(sk, nskb);
758 }
759out:
760 return rc;
761free:
762 kfree_skb(nskb);
763 goto out;
764}
765
766void llc_conn_set_p_flag(struct sock *sk, u8 value)
767{
768 int state_changed = llc_sk(sk)->p_flag && !value;
769
770 llc_sk(sk)->p_flag = value;
771
772 if (state_changed)
773 sk->sk_state_change(sk);
774}
775
776int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
777{
778 int rc = -ENOBUFS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700780 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781
782 if (nskb) {
783 struct llc_sap *sap = llc->sap;
784 u8 *dmac = llc->daddr.mac;
785
786 if (llc->dev->flags & IFF_LOOPBACK)
787 dmac = llc->dev->dev_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
789 llc->daddr.lsap, LLC_PDU_CMD);
790 llc_pdu_init_as_sabme_cmd(nskb, 1);
791 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, dmac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300792 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 goto free;
794 llc_conn_send_pdu(sk, nskb);
795 llc_conn_set_p_flag(sk, 1);
796 }
797out:
798 return rc;
799free:
800 kfree_skb(nskb);
801 goto out;
802}
803
804int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
805{
806 u8 f_bit;
807 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300808 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700809 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810
811 llc_pdu_decode_pf_bit(skb, &f_bit);
812 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 struct llc_sap *sap = llc->sap;
814
815 nskb->dev = llc->dev;
816 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
817 llc->daddr.lsap, LLC_PDU_RSP);
818 llc_pdu_init_as_ua_rsp(nskb, f_bit);
819 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300820 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 goto free;
822 llc_conn_send_pdu(sk, nskb);
823 }
824out:
825 return rc;
826free:
827 kfree_skb(nskb);
828 goto out;
829}
830
831int llc_conn_ac_set_s_flag_0(struct sock *sk, struct sk_buff *skb)
832{
833 llc_sk(sk)->s_flag = 0;
834 return 0;
835}
836
837int llc_conn_ac_set_s_flag_1(struct sock *sk, struct sk_buff *skb)
838{
839 llc_sk(sk)->s_flag = 1;
840 return 0;
841}
842
843int llc_conn_ac_start_p_timer(struct sock *sk, struct sk_buff *skb)
844{
845 struct llc_sock *llc = llc_sk(sk);
846
847 llc_conn_set_p_flag(sk, 1);
848 mod_timer(&llc->pf_cycle_timer.timer,
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300849 jiffies + llc->pf_cycle_timer.expire);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 return 0;
851}
852
853/**
854 * llc_conn_ac_send_ack_if_needed - check if ack is needed
855 * @sk: current connection structure
856 * @skb: current event
857 *
858 * Checks number of received PDUs which have not been acknowledged, yet,
859 * If number of them reaches to "npta"(Number of PDUs To Acknowledge) then
860 * sends an RR response as acknowledgement for them. Returns 0 for
861 * success, 1 otherwise.
862 */
863int llc_conn_ac_send_ack_if_needed(struct sock *sk, struct sk_buff *skb)
864{
865 u8 pf_bit;
866 struct llc_sock *llc = llc_sk(sk);
867
868 llc_pdu_decode_pf_bit(skb, &pf_bit);
869 llc->ack_pf |= pf_bit & 1;
870 if (!llc->ack_must_be_send) {
871 llc->first_pdu_Ns = llc->vR;
872 llc->ack_must_be_send = 1;
873 llc->ack_pf = pf_bit & 1;
874 }
Jochen Friedrich59c61962005-11-14 21:57:15 -0800875 if (((llc->vR - llc->first_pdu_Ns + 1 + LLC_2_SEQ_NBR_MODULO)
876 % LLC_2_SEQ_NBR_MODULO) >= llc->npta) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 llc_conn_ac_send_rr_rsp_f_set_ackpf(sk, skb);
878 llc->ack_must_be_send = 0;
879 llc->ack_pf = 0;
880 llc_conn_ac_inc_npta_value(sk, skb);
881 }
882 return 0;
883}
884
885/**
886 * llc_conn_ac_rst_sendack_flag - resets ack_must_be_send flag
887 * @sk: current connection structure
888 * @skb: current event
889 *
890 * This action resets ack_must_be_send flag of given connection, this flag
891 * indicates if there is any PDU which has not been acknowledged yet.
892 * Returns 0 for success, 1 otherwise.
893 */
894int llc_conn_ac_rst_sendack_flag(struct sock *sk, struct sk_buff *skb)
895{
896 llc_sk(sk)->ack_must_be_send = llc_sk(sk)->ack_pf = 0;
897 return 0;
898}
899
900/**
901 * llc_conn_ac_send_i_rsp_f_set_ackpf - acknowledge received PDUs
902 * @sk: current connection structure
903 * @skb: current event
904 *
905 * Sends an I response PDU with f-bit set to ack_pf flag as acknowledge to
906 * all received PDUs which have not been acknowledged, yet. ack_pf flag is
907 * set to one if one PDU with p-bit set to one is received. Returns 0 for
908 * success, 1 otherwise.
909 */
910static int llc_conn_ac_send_i_rsp_f_set_ackpf(struct sock *sk,
911 struct sk_buff *skb)
912{
913 int rc;
914 struct llc_sock *llc = llc_sk(sk);
915 struct llc_sap *sap = llc->sap;
916
917 llc_pdu_header_init(skb, LLC_PDU_TYPE_I, sap->laddr.lsap,
918 llc->daddr.lsap, LLC_PDU_RSP);
919 llc_pdu_init_as_i_cmd(skb, llc->ack_pf, llc->vS, llc->vR);
920 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300921 if (likely(!rc)) {
Eric Biggersff339162019-10-06 14:24:25 -0700922 skb_get(skb);
923 llc_conn_send_pdu(sk, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 llc_conn_ac_inc_vs_by_1(sk, skb);
925 }
926 return rc;
927}
928
929/**
930 * llc_conn_ac_send_i_as_ack - sends an I-format PDU to acknowledge rx PDUs
931 * @sk: current connection structure.
932 * @skb: current event.
933 *
934 * This action sends an I-format PDU as acknowledge to received PDUs which
935 * have not been acknowledged, yet, if there is any. By using of this
936 * action number of acknowledgements decreases, this technic is called
937 * piggy backing. Returns 0 for success, 1 otherwise.
938 */
939int llc_conn_ac_send_i_as_ack(struct sock *sk, struct sk_buff *skb)
940{
941 struct llc_sock *llc = llc_sk(sk);
Cong Wang4703f3f2018-03-26 15:08:33 -0700942 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943
944 if (llc->ack_must_be_send) {
Cong Wang4703f3f2018-03-26 15:08:33 -0700945 ret = llc_conn_ac_send_i_rsp_f_set_ackpf(sk, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 llc->ack_must_be_send = 0 ;
947 llc->ack_pf = 0;
Cong Wang4703f3f2018-03-26 15:08:33 -0700948 } else {
949 ret = llc_conn_ac_send_i_cmd_p_set_0(sk, skb);
950 }
951
952 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953}
954
955/**
956 * llc_conn_ac_send_rr_rsp_f_set_ackpf - ack all rx PDUs not yet acked
957 * @sk: current connection structure.
958 * @skb: current event.
959 *
960 * This action sends an RR response with f-bit set to ack_pf flag as
961 * acknowledge to all received PDUs which have not been acknowledged, yet,
962 * if there is any. ack_pf flag indicates if a PDU has been received with
963 * p-bit set to one. Returns 0 for success, 1 otherwise.
964 */
965static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
966 struct sk_buff *skb)
967{
968 int rc = -ENOBUFS;
Arnaldo Carvalho de Melo1d67e652005-09-22 03:27:56 -0300969 struct llc_sock *llc = llc_sk(sk);
Joonwoo Parkf83f1762008-03-31 21:02:47 -0700970 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971
972 if (nskb) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 struct llc_sap *sap = llc->sap;
974
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
976 llc->daddr.lsap, LLC_PDU_RSP);
977 llc_pdu_init_as_rr_rsp(nskb, llc->ack_pf, llc->vR);
978 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300979 if (unlikely(rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 goto free;
981 llc_conn_send_pdu(sk, nskb);
982 }
983out:
984 return rc;
985free:
986 kfree_skb(nskb);
987 goto out;
988}
989
990/**
991 * llc_conn_ac_inc_npta_value - tries to make value of npta greater
992 * @sk: current connection structure.
993 * @skb: current event.
994 *
995 * After "inc_cntr" times calling of this action, "npta" increase by one.
996 * this action tries to make vale of "npta" greater as possible; number of
997 * acknowledgements decreases by increasing of "npta". Returns 0 for
998 * success, 1 otherwise.
999 */
1000static int llc_conn_ac_inc_npta_value(struct sock *sk, struct sk_buff *skb)
1001{
1002 struct llc_sock *llc = llc_sk(sk);
1003
1004 if (!llc->inc_cntr) {
1005 llc->dec_step = 0;
1006 llc->dec_cntr = llc->inc_cntr = 2;
1007 ++llc->npta;
David S. Miller38199822005-11-17 15:17:42 -08001008 if (llc->npta > (u8) ~LLC_2_SEQ_NBR_MODULO)
1009 llc->npta = (u8) ~LLC_2_SEQ_NBR_MODULO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 } else
1011 --llc->inc_cntr;
1012 return 0;
1013}
1014
1015/**
1016 * llc_conn_ac_adjust_npta_by_rr - decreases "npta" by one
1017 * @sk: current connection structure.
1018 * @skb: current event.
1019 *
1020 * After receiving "dec_cntr" times RR command, this action decreases
1021 * "npta" by one. Returns 0 for success, 1 otherwise.
1022 */
1023int llc_conn_ac_adjust_npta_by_rr(struct sock *sk, struct sk_buff *skb)
1024{
1025 struct llc_sock *llc = llc_sk(sk);
1026
1027 if (!llc->connect_step && !llc->remote_busy_flag) {
1028 if (!llc->dec_step) {
1029 if (!llc->dec_cntr) {
1030 llc->inc_cntr = llc->dec_cntr = 2;
1031 if (llc->npta > 0)
1032 llc->npta = llc->npta - 1;
1033 } else
1034 llc->dec_cntr -=1;
1035 }
1036 } else
1037 llc->connect_step = 0 ;
1038 return 0;
1039}
1040
1041/**
1042 * llc_conn_ac_adjust_npta_by_rnr - decreases "npta" by one
1043 * @sk: current connection structure.
1044 * @skb: current event.
1045 *
1046 * After receiving "dec_cntr" times RNR command, this action decreases
1047 * "npta" by one. Returns 0 for success, 1 otherwise.
1048 */
1049int llc_conn_ac_adjust_npta_by_rnr(struct sock *sk, struct sk_buff *skb)
1050{
1051 struct llc_sock *llc = llc_sk(sk);
1052
1053 if (llc->remote_busy_flag)
1054 if (!llc->dec_step) {
1055 if (!llc->dec_cntr) {
1056 llc->inc_cntr = llc->dec_cntr = 2;
1057 if (llc->npta > 0)
1058 --llc->npta;
1059 } else
1060 --llc->dec_cntr;
1061 }
1062 return 0;
1063}
1064
1065/**
1066 * llc_conn_ac_dec_tx_win_size - decreases tx window size
1067 * @sk: current connection structure.
1068 * @skb: current event.
1069 *
1070 * After receiving of a REJ command or response, transmit window size is
1071 * decreased by number of PDUs which are outstanding yet. Returns 0 for
1072 * success, 1 otherwise.
1073 */
1074int llc_conn_ac_dec_tx_win_size(struct sock *sk, struct sk_buff *skb)
1075{
1076 struct llc_sock *llc = llc_sk(sk);
1077 u8 unacked_pdu = skb_queue_len(&llc->pdu_unack_q);
1078
Jochen Friedrich59c61962005-11-14 21:57:15 -08001079 if (llc->k - unacked_pdu < 1)
1080 llc->k = 1;
1081 else
1082 llc->k -= unacked_pdu;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083 return 0;
1084}
1085
1086/**
1087 * llc_conn_ac_inc_tx_win_size - tx window size is inc by 1
1088 * @sk: current connection structure.
1089 * @skb: current event.
1090 *
1091 * After receiving an RR response with f-bit set to one, transmit window
1092 * size is increased by one. Returns 0 for success, 1 otherwise.
1093 */
1094int llc_conn_ac_inc_tx_win_size(struct sock *sk, struct sk_buff *skb)
1095{
1096 struct llc_sock *llc = llc_sk(sk);
1097
1098 llc->k += 1;
David S. Miller38199822005-11-17 15:17:42 -08001099 if (llc->k > (u8) ~LLC_2_SEQ_NBR_MODULO)
1100 llc->k = (u8) ~LLC_2_SEQ_NBR_MODULO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 return 0;
1102}
1103
1104int llc_conn_ac_stop_all_timers(struct sock *sk, struct sk_buff *skb)
1105{
Cong Wange202fa92018-04-19 12:25:38 -07001106 llc_sk_stop_all_timers(sk, false);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 return 0;
1108}
1109
1110int llc_conn_ac_stop_other_timers(struct sock *sk, struct sk_buff *skb)
1111{
1112 struct llc_sock *llc = llc_sk(sk);
1113
1114 del_timer(&llc->rej_sent_timer.timer);
1115 del_timer(&llc->pf_cycle_timer.timer);
1116 del_timer(&llc->busy_state_timer.timer);
1117 llc->ack_must_be_send = 0;
1118 llc->ack_pf = 0;
1119 return 0;
1120}
1121
1122int llc_conn_ac_start_ack_timer(struct sock *sk, struct sk_buff *skb)
1123{
1124 struct llc_sock *llc = llc_sk(sk);
1125
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -03001126 mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 return 0;
1128}
1129
1130int llc_conn_ac_start_rej_timer(struct sock *sk, struct sk_buff *skb)
1131{
1132 struct llc_sock *llc = llc_sk(sk);
1133
1134 mod_timer(&llc->rej_sent_timer.timer,
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -03001135 jiffies + llc->rej_sent_timer.expire);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 return 0;
1137}
1138
1139int llc_conn_ac_start_ack_tmr_if_not_running(struct sock *sk,
1140 struct sk_buff *skb)
1141{
1142 struct llc_sock *llc = llc_sk(sk);
1143
1144 if (!timer_pending(&llc->ack_timer.timer))
1145 mod_timer(&llc->ack_timer.timer,
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -03001146 jiffies + llc->ack_timer.expire);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 return 0;
1148}
1149
1150int llc_conn_ac_stop_ack_timer(struct sock *sk, struct sk_buff *skb)
1151{
1152 del_timer(&llc_sk(sk)->ack_timer.timer);
1153 return 0;
1154}
1155
1156int llc_conn_ac_stop_p_timer(struct sock *sk, struct sk_buff *skb)
1157{
1158 struct llc_sock *llc = llc_sk(sk);
1159
1160 del_timer(&llc->pf_cycle_timer.timer);
1161 llc_conn_set_p_flag(sk, 0);
1162 return 0;
1163}
1164
1165int llc_conn_ac_stop_rej_timer(struct sock *sk, struct sk_buff *skb)
1166{
1167 del_timer(&llc_sk(sk)->rej_sent_timer.timer);
1168 return 0;
1169}
1170
1171int llc_conn_ac_upd_nr_received(struct sock *sk, struct sk_buff *skb)
1172{
1173 int acked;
1174 u16 unacked = 0;
1175 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
1176 struct llc_sock *llc = llc_sk(sk);
1177
1178 llc->last_nr = PDU_SUPV_GET_Nr(pdu);
1179 acked = llc_conn_remove_acked_pdus(sk, llc->last_nr, &unacked);
1180 /* On loopback we don't queue I frames in unack_pdu_q queue. */
1181 if (acked > 0 || (llc->dev->flags & IFF_LOOPBACK)) {
1182 llc->retry_count = 0;
1183 del_timer(&llc->ack_timer.timer);
1184 if (llc->failed_data_req) {
1185 /* already, we did not accept data from upper layer
1186 * (tx_window full or unacceptable state). Now, we
1187 * can send data and must inform to upper layer.
1188 */
1189 llc->failed_data_req = 0;
1190 llc_conn_ac_data_confirm(sk, skb);
1191 }
1192 if (unacked)
1193 mod_timer(&llc->ack_timer.timer,
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -03001194 jiffies + llc->ack_timer.expire);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 } else if (llc->failed_data_req) {
1196 u8 f_bit;
1197
1198 llc_pdu_decode_pf_bit(skb, &f_bit);
1199 if (f_bit == 1) {
1200 llc->failed_data_req = 0;
1201 llc_conn_ac_data_confirm(sk, skb);
1202 }
1203 }
1204 return 0;
1205}
1206
1207int llc_conn_ac_upd_p_flag(struct sock *sk, struct sk_buff *skb)
1208{
1209 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
1210
1211 if (LLC_PDU_IS_RSP(pdu)) {
1212 u8 f_bit;
1213
1214 llc_pdu_decode_pf_bit(skb, &f_bit);
1215 if (f_bit) {
1216 llc_conn_set_p_flag(sk, 0);
1217 llc_conn_ac_stop_p_timer(sk, skb);
1218 }
1219 }
1220 return 0;
1221}
1222
1223int llc_conn_ac_set_data_flag_2(struct sock *sk, struct sk_buff *skb)
1224{
1225 llc_sk(sk)->data_flag = 2;
1226 return 0;
1227}
1228
1229int llc_conn_ac_set_data_flag_0(struct sock *sk, struct sk_buff *skb)
1230{
1231 llc_sk(sk)->data_flag = 0;
1232 return 0;
1233}
1234
1235int llc_conn_ac_set_data_flag_1(struct sock *sk, struct sk_buff *skb)
1236{
1237 llc_sk(sk)->data_flag = 1;
1238 return 0;
1239}
1240
1241int llc_conn_ac_set_data_flag_1_if_data_flag_eq_0(struct sock *sk,
1242 struct sk_buff *skb)
1243{
1244 if (!llc_sk(sk)->data_flag)
1245 llc_sk(sk)->data_flag = 1;
1246 return 0;
1247}
1248
1249int llc_conn_ac_set_p_flag_0(struct sock *sk, struct sk_buff *skb)
1250{
1251 llc_conn_set_p_flag(sk, 0);
1252 return 0;
1253}
1254
1255static int llc_conn_ac_set_p_flag_1(struct sock *sk, struct sk_buff *skb)
1256{
1257 llc_conn_set_p_flag(sk, 1);
1258 return 0;
1259}
1260
1261int llc_conn_ac_set_remote_busy_0(struct sock *sk, struct sk_buff *skb)
1262{
1263 llc_sk(sk)->remote_busy_flag = 0;
1264 return 0;
1265}
1266
1267int llc_conn_ac_set_cause_flag_0(struct sock *sk, struct sk_buff *skb)
1268{
1269 llc_sk(sk)->cause_flag = 0;
1270 return 0;
1271}
1272
1273int llc_conn_ac_set_cause_flag_1(struct sock *sk, struct sk_buff *skb)
1274{
1275 llc_sk(sk)->cause_flag = 1;
1276 return 0;
1277}
1278
1279int llc_conn_ac_set_retry_cnt_0(struct sock *sk, struct sk_buff *skb)
1280{
1281 llc_sk(sk)->retry_count = 0;
1282 return 0;
1283}
1284
1285int llc_conn_ac_inc_retry_cnt_by_1(struct sock *sk, struct sk_buff *skb)
1286{
1287 llc_sk(sk)->retry_count++;
1288 return 0;
1289}
1290
1291int llc_conn_ac_set_vr_0(struct sock *sk, struct sk_buff *skb)
1292{
1293 llc_sk(sk)->vR = 0;
1294 return 0;
1295}
1296
1297int llc_conn_ac_inc_vr_by_1(struct sock *sk, struct sk_buff *skb)
1298{
1299 llc_sk(sk)->vR = PDU_GET_NEXT_Vr(llc_sk(sk)->vR);
1300 return 0;
1301}
1302
1303int llc_conn_ac_set_vs_0(struct sock *sk, struct sk_buff *skb)
1304{
1305 llc_sk(sk)->vS = 0;
1306 return 0;
1307}
1308
1309int llc_conn_ac_set_vs_nr(struct sock *sk, struct sk_buff *skb)
1310{
1311 llc_sk(sk)->vS = llc_sk(sk)->last_nr;
1312 return 0;
1313}
1314
Arnaldo Carvalho de Melo2928c192005-09-22 05:14:33 -03001315static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316{
Jochen Friedrich59c61962005-11-14 21:57:15 -08001317 llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % LLC_2_SEQ_NBR_MODULO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 return 0;
1319}
1320
Arnaldo Carvalho de Meloe0dd5512005-09-22 03:50:15 -03001321static void llc_conn_tmr_common_cb(unsigned long timeout_data, u8 type)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322{
1323 struct sock *sk = (struct sock *)timeout_data;
1324 struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
1325
1326 bh_lock_sock(sk);
1327 if (skb) {
1328 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
1329
Arnaldo Carvalho de Melo04e42232005-09-22 04:40:59 -03001330 skb_set_owner_r(skb, sk);
Arnaldo Carvalho de Meloe0dd5512005-09-22 03:50:15 -03001331 ev->type = type;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332 llc_process_tmr_ev(sk, skb);
1333 }
1334 bh_unlock_sock(sk);
1335}
1336
Arnaldo Carvalho de Meloe0dd5512005-09-22 03:50:15 -03001337void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data)
1338{
1339 llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_P_TMR);
1340}
1341
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342void llc_conn_busy_tmr_cb(unsigned long timeout_data)
1343{
Arnaldo Carvalho de Meloe0dd5512005-09-22 03:50:15 -03001344 llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_BUSY_TMR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345}
1346
1347void llc_conn_ack_tmr_cb(unsigned long timeout_data)
1348{
Arnaldo Carvalho de Meloe0dd5512005-09-22 03:50:15 -03001349 llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_ACK_TMR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350}
1351
1352void llc_conn_rej_tmr_cb(unsigned long timeout_data)
1353{
Arnaldo Carvalho de Meloe0dd5512005-09-22 03:50:15 -03001354 llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_REJ_TMR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355}
1356
1357int llc_conn_ac_rst_vs(struct sock *sk, struct sk_buff *skb)
1358{
1359 llc_sk(sk)->X = llc_sk(sk)->vS;
1360 llc_conn_ac_set_vs_nr(sk, skb);
1361 return 0;
1362}
1363
1364int llc_conn_ac_upd_vs(struct sock *sk, struct sk_buff *skb)
1365{
1366 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
1367 u8 nr = PDU_SUPV_GET_Nr(pdu);
1368
1369 if (llc_circular_between(llc_sk(sk)->vS, nr, llc_sk(sk)->X))
1370 llc_conn_ac_set_vs_nr(sk, skb);
1371 return 0;
1372}
1373
1374/*
1375 * Non-standard actions; these not contained in IEEE specification; for
1376 * our own usage
1377 */
1378/**
1379 * llc_conn_disc - removes connection from SAP list and frees it
1380 * @sk: closed connection
1381 * @skb: occurred event
1382 */
1383int llc_conn_disc(struct sock *sk, struct sk_buff *skb)
1384{
1385 /* FIXME: this thing seems to want to die */
1386 return 0;
1387}
1388
1389/**
1390 * llc_conn_reset - resets connection
1391 * @sk : reseting connection.
1392 * @skb: occurred event.
1393 *
1394 * Stop all timers, empty all queues and reset all flags.
1395 */
1396int llc_conn_reset(struct sock *sk, struct sk_buff *skb)
1397{
1398 llc_sk_reset(sk);
1399 return 0;
1400}
1401
1402/**
1403 * llc_circular_between - designates that b is between a and c or not
1404 * @a: lower bound
1405 * @b: element to see if is between a and b
1406 * @c: upper bound
1407 *
1408 * This function designates that b is between a and c or not (for example,
1409 * 0 is between 127 and 1). Returns 1 if b is between a and c, 0
1410 * otherwise.
1411 */
1412u8 llc_circular_between(u8 a, u8 b, u8 c)
1413{
1414 b = b - a;
1415 c = c - a;
1416 return b <= c;
1417}
1418
1419/**
1420 * llc_process_tmr_ev - timer backend
1421 * @sk: active connection
1422 * @skb: occurred event
1423 *
1424 * This function is called from timer callback functions. When connection
1425 * is busy (during sending a data frame) timer expiration event must be
1426 * queued. Otherwise this event can be sent to connection state machine.
1427 * Queued events will process by llc_backlog_rcv function after sending
1428 * data frame.
1429 */
1430static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb)
1431{
1432 if (llc_sk(sk)->state == LLC_CONN_OUT_OF_SVC) {
1433 printk(KERN_WARNING "%s: timer called on closed connection\n",
Harvey Harrison0dc47872008-03-05 20:47:47 -08001434 __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 kfree_skb(skb);
1436 } else {
1437 if (!sock_owned_by_user(sk))
1438 llc_conn_state_process(sk, skb);
1439 else {
1440 llc_set_backlog_type(skb, LLC_EVENT);
Zhu Yia3a858f2010-03-04 18:01:47 +00001441 __sk_add_backlog(sk, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442 }
1443 }
1444}