18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * llc_c_ev.c - Connection component state transition event qualifiers 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * A 'state' consists of a number of possible event matching functions, 58c2ecf20Sopenharmony_ci * the actions associated with each being executed when that event is 68c2ecf20Sopenharmony_ci * matched; a 'state machine' accepts events in a serial fashion from an 78c2ecf20Sopenharmony_ci * event queue. Each event is passed to each successive event matching 88c2ecf20Sopenharmony_ci * function until a match is made (the event matching function returns 98c2ecf20Sopenharmony_ci * success, or '0') or the list of event matching functions is exhausted. 108c2ecf20Sopenharmony_ci * If a match is made, the actions associated with the event are executed 118c2ecf20Sopenharmony_ci * and the state is changed to that event's transition state. Before some 128c2ecf20Sopenharmony_ci * events are recognized, even after a match has been made, a certain 138c2ecf20Sopenharmony_ci * number of 'event qualifier' functions must also be executed. If these 148c2ecf20Sopenharmony_ci * all execute successfully, then the event is finally executed. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * These event functions must return 0 for success, to show a matched 178c2ecf20Sopenharmony_ci * event, of 1 if the event does not match. Event qualifier functions 188c2ecf20Sopenharmony_ci * must return a 0 for success or a non-zero for failure. Each function 198c2ecf20Sopenharmony_ci * is simply responsible for verifying one single thing and returning 208c2ecf20Sopenharmony_ci * either a success or failure. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * All of followed event functions are described in 802.2 LLC Protocol 238c2ecf20Sopenharmony_ci * standard document except two functions that we added that will explain 248c2ecf20Sopenharmony_ci * in their comments, at below. 258c2ecf20Sopenharmony_ci * 268c2ecf20Sopenharmony_ci * Copyright (c) 1997 by Procom Technology, Inc. 278c2ecf20Sopenharmony_ci * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br> 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * This program can be redistributed or modified under the terms of the 308c2ecf20Sopenharmony_ci * GNU General Public License as published by the Free Software Foundation. 318c2ecf20Sopenharmony_ci * This program is distributed without any warranty or implied warranty 328c2ecf20Sopenharmony_ci * of merchantability or fitness for a particular purpose. 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci * See the GNU General Public License for more details. 358c2ecf20Sopenharmony_ci */ 368c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 378c2ecf20Sopenharmony_ci#include <net/llc_conn.h> 388c2ecf20Sopenharmony_ci#include <net/llc_sap.h> 398c2ecf20Sopenharmony_ci#include <net/sock.h> 408c2ecf20Sopenharmony_ci#include <net/llc_c_ac.h> 418c2ecf20Sopenharmony_ci#include <net/llc_c_ev.h> 428c2ecf20Sopenharmony_ci#include <net/llc_pdu.h> 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#if 1 458c2ecf20Sopenharmony_ci#define dprintk(args...) printk(KERN_DEBUG args) 468c2ecf20Sopenharmony_ci#else 478c2ecf20Sopenharmony_ci#define dprintk(args...) 488c2ecf20Sopenharmony_ci#endif 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/** 518c2ecf20Sopenharmony_ci * llc_util_ns_inside_rx_window - check if sequence number is in rx window 528c2ecf20Sopenharmony_ci * @ns: sequence number of received pdu. 538c2ecf20Sopenharmony_ci * @vr: sequence number which receiver expects to receive. 548c2ecf20Sopenharmony_ci * @rw: receive window size of receiver. 558c2ecf20Sopenharmony_ci * 568c2ecf20Sopenharmony_ci * Checks if sequence number of received PDU is in range of receive 578c2ecf20Sopenharmony_ci * window. Returns 0 for success, 1 otherwise 588c2ecf20Sopenharmony_ci */ 598c2ecf20Sopenharmony_cistatic u16 llc_util_ns_inside_rx_window(u8 ns, u8 vr, u8 rw) 608c2ecf20Sopenharmony_ci{ 618c2ecf20Sopenharmony_ci return !llc_circular_between(vr, ns, 628c2ecf20Sopenharmony_ci (vr + rw - 1) % LLC_2_SEQ_NBR_MODULO); 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/** 668c2ecf20Sopenharmony_ci * llc_util_nr_inside_tx_window - check if sequence number is in tx window 678c2ecf20Sopenharmony_ci * @sk: current connection. 688c2ecf20Sopenharmony_ci * @nr: N(R) of received PDU. 698c2ecf20Sopenharmony_ci * 708c2ecf20Sopenharmony_ci * This routine checks if N(R) of received PDU is in range of transmit 718c2ecf20Sopenharmony_ci * window; on the other hand checks if received PDU acknowledges some 728c2ecf20Sopenharmony_ci * outstanding PDUs that are in transmit window. Returns 0 for success, 1 738c2ecf20Sopenharmony_ci * otherwise. 748c2ecf20Sopenharmony_ci */ 758c2ecf20Sopenharmony_cistatic u16 llc_util_nr_inside_tx_window(struct sock *sk, u8 nr) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci u8 nr1, nr2; 788c2ecf20Sopenharmony_ci struct sk_buff *skb; 798c2ecf20Sopenharmony_ci struct llc_pdu_sn *pdu; 808c2ecf20Sopenharmony_ci struct llc_sock *llc = llc_sk(sk); 818c2ecf20Sopenharmony_ci int rc = 0; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci if (llc->dev->flags & IFF_LOOPBACK) 848c2ecf20Sopenharmony_ci goto out; 858c2ecf20Sopenharmony_ci rc = 1; 868c2ecf20Sopenharmony_ci if (skb_queue_empty(&llc->pdu_unack_q)) 878c2ecf20Sopenharmony_ci goto out; 888c2ecf20Sopenharmony_ci skb = skb_peek(&llc->pdu_unack_q); 898c2ecf20Sopenharmony_ci pdu = llc_pdu_sn_hdr(skb); 908c2ecf20Sopenharmony_ci nr1 = LLC_I_GET_NS(pdu); 918c2ecf20Sopenharmony_ci skb = skb_peek_tail(&llc->pdu_unack_q); 928c2ecf20Sopenharmony_ci pdu = llc_pdu_sn_hdr(skb); 938c2ecf20Sopenharmony_ci nr2 = LLC_I_GET_NS(pdu); 948c2ecf20Sopenharmony_ci rc = !llc_circular_between(nr1, nr, (nr2 + 1) % LLC_2_SEQ_NBR_MODULO); 958c2ecf20Sopenharmony_ciout: 968c2ecf20Sopenharmony_ci return rc; 978c2ecf20Sopenharmony_ci} 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ciint llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb) 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci return ev->prim == LLC_CONN_PRIM && 1048c2ecf20Sopenharmony_ci ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 1058c2ecf20Sopenharmony_ci} 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ciint llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb) 1088c2ecf20Sopenharmony_ci{ 1098c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci return ev->prim == LLC_DATA_PRIM && 1128c2ecf20Sopenharmony_ci ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ciint llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb) 1168c2ecf20Sopenharmony_ci{ 1178c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci return ev->prim == LLC_DISC_PRIM && 1208c2ecf20Sopenharmony_ci ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 1218c2ecf20Sopenharmony_ci} 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ciint llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb) 1248c2ecf20Sopenharmony_ci{ 1258c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci return ev->prim == LLC_RESET_PRIM && 1288c2ecf20Sopenharmony_ci ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 1298c2ecf20Sopenharmony_ci} 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ciint llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb) 1328c2ecf20Sopenharmony_ci{ 1338c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci return ev->type == LLC_CONN_EV_TYPE_SIMPLE && 1368c2ecf20Sopenharmony_ci ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_DETECTED ? 0 : 1; 1378c2ecf20Sopenharmony_ci} 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ciint llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb) 1408c2ecf20Sopenharmony_ci{ 1418c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci return ev->type == LLC_CONN_EV_TYPE_SIMPLE && 1448c2ecf20Sopenharmony_ci ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_CLEARED ? 0 : 1; 1458c2ecf20Sopenharmony_ci} 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ciint llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb) 1488c2ecf20Sopenharmony_ci{ 1498c2ecf20Sopenharmony_ci return 1; 1508c2ecf20Sopenharmony_ci} 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ciint llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) 1538c2ecf20Sopenharmony_ci{ 1548c2ecf20Sopenharmony_ci const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) && 1578c2ecf20Sopenharmony_ci LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_DISC ? 0 : 1; 1588c2ecf20Sopenharmony_ci} 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ciint llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 1618c2ecf20Sopenharmony_ci{ 1628c2ecf20Sopenharmony_ci const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) && 1658c2ecf20Sopenharmony_ci LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_DM ? 0 : 1; 1668c2ecf20Sopenharmony_ci} 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ciint llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 1698c2ecf20Sopenharmony_ci{ 1708c2ecf20Sopenharmony_ci const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) && 1738c2ecf20Sopenharmony_ci LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR ? 0 : 1; 1748c2ecf20Sopenharmony_ci} 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) 1778c2ecf20Sopenharmony_ci{ 1788c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci return llc_conn_space(sk, skb) && 1818c2ecf20Sopenharmony_ci LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 1828c2ecf20Sopenharmony_ci LLC_I_PF_IS_0(pdu) && 1838c2ecf20Sopenharmony_ci LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1; 1848c2ecf20Sopenharmony_ci} 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 1878c2ecf20Sopenharmony_ci{ 1888c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci return llc_conn_space(sk, skb) && 1918c2ecf20Sopenharmony_ci LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 1928c2ecf20Sopenharmony_ci LLC_I_PF_IS_1(pdu) && 1938c2ecf20Sopenharmony_ci LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1; 1948c2ecf20Sopenharmony_ci} 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk, 1978c2ecf20Sopenharmony_ci struct sk_buff *skb) 1988c2ecf20Sopenharmony_ci{ 1998c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 2008c2ecf20Sopenharmony_ci const u8 vr = llc_sk(sk)->vR; 2018c2ecf20Sopenharmony_ci const u8 ns = LLC_I_GET_NS(pdu); 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 2048c2ecf20Sopenharmony_ci LLC_I_PF_IS_0(pdu) && ns != vr && 2058c2ecf20Sopenharmony_ci !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 2068c2ecf20Sopenharmony_ci} 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk, 2098c2ecf20Sopenharmony_ci struct sk_buff *skb) 2108c2ecf20Sopenharmony_ci{ 2118c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 2128c2ecf20Sopenharmony_ci const u8 vr = llc_sk(sk)->vR; 2138c2ecf20Sopenharmony_ci const u8 ns = LLC_I_GET_NS(pdu); 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 2168c2ecf20Sopenharmony_ci LLC_I_PF_IS_1(pdu) && ns != vr && 2178c2ecf20Sopenharmony_ci !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 2188c2ecf20Sopenharmony_ci} 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk, 2218c2ecf20Sopenharmony_ci struct sk_buff *skb) 2228c2ecf20Sopenharmony_ci{ 2238c2ecf20Sopenharmony_ci const struct llc_pdu_sn * pdu = llc_pdu_sn_hdr(skb); 2248c2ecf20Sopenharmony_ci const u8 vr = llc_sk(sk)->vR; 2258c2ecf20Sopenharmony_ci const u8 ns = LLC_I_GET_NS(pdu); 2268c2ecf20Sopenharmony_ci const u16 rc = LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 2278c2ecf20Sopenharmony_ci ns != vr && 2288c2ecf20Sopenharmony_ci llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 2298c2ecf20Sopenharmony_ci if (!rc) 2308c2ecf20Sopenharmony_ci dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", 2318c2ecf20Sopenharmony_ci __func__, llc_sk(sk)->state, ns, vr); 2328c2ecf20Sopenharmony_ci return rc; 2338c2ecf20Sopenharmony_ci} 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) 2368c2ecf20Sopenharmony_ci{ 2378c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci return llc_conn_space(sk, skb) && 2408c2ecf20Sopenharmony_ci LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 2418c2ecf20Sopenharmony_ci LLC_I_PF_IS_0(pdu) && 2428c2ecf20Sopenharmony_ci LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1; 2438c2ecf20Sopenharmony_ci} 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) 2468c2ecf20Sopenharmony_ci{ 2478c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 2508c2ecf20Sopenharmony_ci LLC_I_PF_IS_1(pdu) && 2518c2ecf20Sopenharmony_ci LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1; 2528c2ecf20Sopenharmony_ci} 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 2558c2ecf20Sopenharmony_ci{ 2568c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci return llc_conn_space(sk, skb) && 2598c2ecf20Sopenharmony_ci LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 2608c2ecf20Sopenharmony_ci LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1; 2618c2ecf20Sopenharmony_ci} 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk, 2648c2ecf20Sopenharmony_ci struct sk_buff *skb) 2658c2ecf20Sopenharmony_ci{ 2668c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 2678c2ecf20Sopenharmony_ci const u8 vr = llc_sk(sk)->vR; 2688c2ecf20Sopenharmony_ci const u8 ns = LLC_I_GET_NS(pdu); 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 2718c2ecf20Sopenharmony_ci LLC_I_PF_IS_0(pdu) && ns != vr && 2728c2ecf20Sopenharmony_ci !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 2738c2ecf20Sopenharmony_ci} 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk, 2768c2ecf20Sopenharmony_ci struct sk_buff *skb) 2778c2ecf20Sopenharmony_ci{ 2788c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 2798c2ecf20Sopenharmony_ci const u8 vr = llc_sk(sk)->vR; 2808c2ecf20Sopenharmony_ci const u8 ns = LLC_I_GET_NS(pdu); 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 2838c2ecf20Sopenharmony_ci LLC_I_PF_IS_1(pdu) && ns != vr && 2848c2ecf20Sopenharmony_ci !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 2858c2ecf20Sopenharmony_ci} 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk, 2888c2ecf20Sopenharmony_ci struct sk_buff *skb) 2898c2ecf20Sopenharmony_ci{ 2908c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 2918c2ecf20Sopenharmony_ci const u8 vr = llc_sk(sk)->vR; 2928c2ecf20Sopenharmony_ci const u8 ns = LLC_I_GET_NS(pdu); 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr && 2958c2ecf20Sopenharmony_ci !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 2968c2ecf20Sopenharmony_ci} 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk, 2998c2ecf20Sopenharmony_ci struct sk_buff *skb) 3008c2ecf20Sopenharmony_ci{ 3018c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3028c2ecf20Sopenharmony_ci const u8 vr = llc_sk(sk)->vR; 3038c2ecf20Sopenharmony_ci const u8 ns = LLC_I_GET_NS(pdu); 3048c2ecf20Sopenharmony_ci const u16 rc = LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 3058c2ecf20Sopenharmony_ci ns != vr && 3068c2ecf20Sopenharmony_ci llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 3078c2ecf20Sopenharmony_ci if (!rc) 3088c2ecf20Sopenharmony_ci dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", 3098c2ecf20Sopenharmony_ci __func__, llc_sk(sk)->state, ns, vr); 3108c2ecf20Sopenharmony_ci return rc; 3118c2ecf20Sopenharmony_ci} 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) 3148c2ecf20Sopenharmony_ci{ 3158c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3188c2ecf20Sopenharmony_ci LLC_S_PF_IS_0(pdu) && 3198c2ecf20Sopenharmony_ci LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_REJ ? 0 : 1; 3208c2ecf20Sopenharmony_ci} 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 3238c2ecf20Sopenharmony_ci{ 3248c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3278c2ecf20Sopenharmony_ci LLC_S_PF_IS_1(pdu) && 3288c2ecf20Sopenharmony_ci LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_REJ ? 0 : 1; 3298c2ecf20Sopenharmony_ci} 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) 3328c2ecf20Sopenharmony_ci{ 3338c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3368c2ecf20Sopenharmony_ci LLC_S_PF_IS_0(pdu) && 3378c2ecf20Sopenharmony_ci LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1; 3388c2ecf20Sopenharmony_ci} 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) 3418c2ecf20Sopenharmony_ci{ 3428c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3458c2ecf20Sopenharmony_ci LLC_S_PF_IS_1(pdu) && 3468c2ecf20Sopenharmony_ci LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1; 3478c2ecf20Sopenharmony_ci} 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 3508c2ecf20Sopenharmony_ci{ 3518c2ecf20Sopenharmony_ci const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3548c2ecf20Sopenharmony_ci LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1; 3558c2ecf20Sopenharmony_ci} 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) 3588c2ecf20Sopenharmony_ci{ 3598c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3628c2ecf20Sopenharmony_ci LLC_S_PF_IS_0(pdu) && 3638c2ecf20Sopenharmony_ci LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RNR ? 0 : 1; 3648c2ecf20Sopenharmony_ci} 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 3678c2ecf20Sopenharmony_ci{ 3688c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3718c2ecf20Sopenharmony_ci LLC_S_PF_IS_1(pdu) && 3728c2ecf20Sopenharmony_ci LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RNR ? 0 : 1; 3738c2ecf20Sopenharmony_ci} 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) 3768c2ecf20Sopenharmony_ci{ 3778c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3808c2ecf20Sopenharmony_ci LLC_S_PF_IS_0(pdu) && 3818c2ecf20Sopenharmony_ci LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RNR ? 0 : 1; 3828c2ecf20Sopenharmony_ci} 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) 3858c2ecf20Sopenharmony_ci{ 3868c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3898c2ecf20Sopenharmony_ci LLC_S_PF_IS_1(pdu) && 3908c2ecf20Sopenharmony_ci LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RNR ? 0 : 1; 3918c2ecf20Sopenharmony_ci} 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) 3948c2ecf20Sopenharmony_ci{ 3958c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 3988c2ecf20Sopenharmony_ci LLC_S_PF_IS_0(pdu) && 3998c2ecf20Sopenharmony_ci LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RR ? 0 : 1; 4008c2ecf20Sopenharmony_ci} 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 4038c2ecf20Sopenharmony_ci{ 4048c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 4078c2ecf20Sopenharmony_ci LLC_S_PF_IS_1(pdu) && 4088c2ecf20Sopenharmony_ci LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RR ? 0 : 1; 4098c2ecf20Sopenharmony_ci} 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) 4128c2ecf20Sopenharmony_ci{ 4138c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_ci return llc_conn_space(sk, skb) && 4168c2ecf20Sopenharmony_ci LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 4178c2ecf20Sopenharmony_ci LLC_S_PF_IS_0(pdu) && 4188c2ecf20Sopenharmony_ci LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RR ? 0 : 1; 4198c2ecf20Sopenharmony_ci} 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ciint llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) 4228c2ecf20Sopenharmony_ci{ 4238c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci return llc_conn_space(sk, skb) && 4268c2ecf20Sopenharmony_ci LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 4278c2ecf20Sopenharmony_ci LLC_S_PF_IS_1(pdu) && 4288c2ecf20Sopenharmony_ci LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RR ? 0 : 1; 4298c2ecf20Sopenharmony_ci} 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ciint llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) 4328c2ecf20Sopenharmony_ci{ 4338c2ecf20Sopenharmony_ci const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_ci return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) && 4368c2ecf20Sopenharmony_ci LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME ? 0 : 1; 4378c2ecf20Sopenharmony_ci} 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ciint llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 4408c2ecf20Sopenharmony_ci{ 4418c2ecf20Sopenharmony_ci struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) && 4448c2ecf20Sopenharmony_ci LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_UA ? 0 : 1; 4458c2ecf20Sopenharmony_ci} 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ciint llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 4488c2ecf20Sopenharmony_ci{ 4498c2ecf20Sopenharmony_ci u16 rc = 1; 4508c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci if (LLC_PDU_IS_CMD(pdu)) { 4538c2ecf20Sopenharmony_ci if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) { 4548c2ecf20Sopenharmony_ci if (LLC_I_PF_IS_1(pdu)) 4558c2ecf20Sopenharmony_ci rc = 0; 4568c2ecf20Sopenharmony_ci } else if (LLC_PDU_TYPE_IS_U(pdu) && LLC_U_PF_IS_1(pdu)) 4578c2ecf20Sopenharmony_ci rc = 0; 4588c2ecf20Sopenharmony_ci } 4598c2ecf20Sopenharmony_ci return rc; 4608c2ecf20Sopenharmony_ci} 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ciint llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) 4638c2ecf20Sopenharmony_ci{ 4648c2ecf20Sopenharmony_ci u16 rc = 1; 4658c2ecf20Sopenharmony_ci const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci if (LLC_PDU_IS_CMD(pdu)) { 4688c2ecf20Sopenharmony_ci if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) 4698c2ecf20Sopenharmony_ci rc = 0; 4708c2ecf20Sopenharmony_ci else if (LLC_PDU_TYPE_IS_U(pdu)) 4718c2ecf20Sopenharmony_ci switch (LLC_U_PDU_CMD(pdu)) { 4728c2ecf20Sopenharmony_ci case LLC_2_PDU_CMD_SABME: 4738c2ecf20Sopenharmony_ci case LLC_2_PDU_CMD_DISC: 4748c2ecf20Sopenharmony_ci rc = 0; 4758c2ecf20Sopenharmony_ci break; 4768c2ecf20Sopenharmony_ci } 4778c2ecf20Sopenharmony_ci } 4788c2ecf20Sopenharmony_ci return rc; 4798c2ecf20Sopenharmony_ci} 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_ciint llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 4828c2ecf20Sopenharmony_ci{ 4838c2ecf20Sopenharmony_ci u16 rc = 1; 4848c2ecf20Sopenharmony_ci const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci if (LLC_PDU_IS_RSP(pdu)) { 4878c2ecf20Sopenharmony_ci if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) 4888c2ecf20Sopenharmony_ci rc = 0; 4898c2ecf20Sopenharmony_ci else if (LLC_PDU_TYPE_IS_U(pdu)) 4908c2ecf20Sopenharmony_ci switch (LLC_U_PDU_RSP(pdu)) { 4918c2ecf20Sopenharmony_ci case LLC_2_PDU_RSP_UA: 4928c2ecf20Sopenharmony_ci case LLC_2_PDU_RSP_DM: 4938c2ecf20Sopenharmony_ci case LLC_2_PDU_RSP_FRMR: 4948c2ecf20Sopenharmony_ci rc = 0; 4958c2ecf20Sopenharmony_ci break; 4968c2ecf20Sopenharmony_ci } 4978c2ecf20Sopenharmony_ci } 4988c2ecf20Sopenharmony_ci 4998c2ecf20Sopenharmony_ci return rc; 5008c2ecf20Sopenharmony_ci} 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ciint llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk, 5038c2ecf20Sopenharmony_ci struct sk_buff *skb) 5048c2ecf20Sopenharmony_ci{ 5058c2ecf20Sopenharmony_ci u16 rc = 1; 5068c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 5078c2ecf20Sopenharmony_ci const u8 vs = llc_sk(sk)->vS; 5088c2ecf20Sopenharmony_ci const u8 nr = LLC_I_GET_NR(pdu); 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci if (LLC_PDU_IS_CMD(pdu) && 5118c2ecf20Sopenharmony_ci (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) && 5128c2ecf20Sopenharmony_ci nr != vs && llc_util_nr_inside_tx_window(sk, nr)) { 5138c2ecf20Sopenharmony_ci dprintk("%s: matched, state=%d, vs=%d, nr=%d\n", 5148c2ecf20Sopenharmony_ci __func__, llc_sk(sk)->state, vs, nr); 5158c2ecf20Sopenharmony_ci rc = 0; 5168c2ecf20Sopenharmony_ci } 5178c2ecf20Sopenharmony_ci return rc; 5188c2ecf20Sopenharmony_ci} 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ciint llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk, 5218c2ecf20Sopenharmony_ci struct sk_buff *skb) 5228c2ecf20Sopenharmony_ci{ 5238c2ecf20Sopenharmony_ci u16 rc = 1; 5248c2ecf20Sopenharmony_ci const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 5258c2ecf20Sopenharmony_ci const u8 vs = llc_sk(sk)->vS; 5268c2ecf20Sopenharmony_ci const u8 nr = LLC_I_GET_NR(pdu); 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_ci if (LLC_PDU_IS_RSP(pdu) && 5298c2ecf20Sopenharmony_ci (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) && 5308c2ecf20Sopenharmony_ci nr != vs && llc_util_nr_inside_tx_window(sk, nr)) { 5318c2ecf20Sopenharmony_ci rc = 0; 5328c2ecf20Sopenharmony_ci dprintk("%s: matched, state=%d, vs=%d, nr=%d\n", 5338c2ecf20Sopenharmony_ci __func__, llc_sk(sk)->state, vs, nr); 5348c2ecf20Sopenharmony_ci } 5358c2ecf20Sopenharmony_ci return rc; 5368c2ecf20Sopenharmony_ci} 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_ciint llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb) 5398c2ecf20Sopenharmony_ci{ 5408c2ecf20Sopenharmony_ci return 0; 5418c2ecf20Sopenharmony_ci} 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ciint llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb) 5448c2ecf20Sopenharmony_ci{ 5458c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci return ev->type != LLC_CONN_EV_TYPE_P_TMR; 5488c2ecf20Sopenharmony_ci} 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ciint llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb) 5518c2ecf20Sopenharmony_ci{ 5528c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_ci return ev->type != LLC_CONN_EV_TYPE_ACK_TMR; 5558c2ecf20Sopenharmony_ci} 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ciint llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb) 5588c2ecf20Sopenharmony_ci{ 5598c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci return ev->type != LLC_CONN_EV_TYPE_REJ_TMR; 5628c2ecf20Sopenharmony_ci} 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ciint llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb) 5658c2ecf20Sopenharmony_ci{ 5668c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci return ev->type != LLC_CONN_EV_TYPE_BUSY_TMR; 5698c2ecf20Sopenharmony_ci} 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ciint llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb) 5728c2ecf20Sopenharmony_ci{ 5738c2ecf20Sopenharmony_ci return 1; 5748c2ecf20Sopenharmony_ci} 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ciint llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb) 5778c2ecf20Sopenharmony_ci{ 5788c2ecf20Sopenharmony_ci const struct llc_conn_state_ev *ev = llc_conn_ev(skb); 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ci return ev->type == LLC_CONN_EV_TYPE_SIMPLE && 5818c2ecf20Sopenharmony_ci ev->prim_type == LLC_CONN_EV_TX_BUFF_FULL ? 0 : 1; 5828c2ecf20Sopenharmony_ci} 5838c2ecf20Sopenharmony_ci 5848c2ecf20Sopenharmony_ci/* Event qualifier functions 5858c2ecf20Sopenharmony_ci * 5868c2ecf20Sopenharmony_ci * these functions simply verify the value of a state flag associated with 5878c2ecf20Sopenharmony_ci * the connection and return either a 0 for success or a non-zero value 5888c2ecf20Sopenharmony_ci * for not-success; verify the event is the type we expect 5898c2ecf20Sopenharmony_ci */ 5908c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk, struct sk_buff *skb) 5918c2ecf20Sopenharmony_ci{ 5928c2ecf20Sopenharmony_ci return llc_sk(sk)->data_flag != 1; 5938c2ecf20Sopenharmony_ci} 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk, struct sk_buff *skb) 5968c2ecf20Sopenharmony_ci{ 5978c2ecf20Sopenharmony_ci return llc_sk(sk)->data_flag; 5988c2ecf20Sopenharmony_ci} 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk, struct sk_buff *skb) 6018c2ecf20Sopenharmony_ci{ 6028c2ecf20Sopenharmony_ci return llc_sk(sk)->data_flag != 2; 6038c2ecf20Sopenharmony_ci} 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk, struct sk_buff *skb) 6068c2ecf20Sopenharmony_ci{ 6078c2ecf20Sopenharmony_ci return llc_sk(sk)->p_flag != 1; 6088c2ecf20Sopenharmony_ci} 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_ci/** 6118c2ecf20Sopenharmony_ci * conn_ev_qlfy_last_frame_eq_1 - checks if frame is last in tx window 6128c2ecf20Sopenharmony_ci * @sk: current connection structure. 6138c2ecf20Sopenharmony_ci * @skb: current event. 6148c2ecf20Sopenharmony_ci * 6158c2ecf20Sopenharmony_ci * This function determines when frame which is sent, is last frame of 6168c2ecf20Sopenharmony_ci * transmit window, if it is then this function return zero else return 6178c2ecf20Sopenharmony_ci * one. This function is used for sending last frame of transmit window 6188c2ecf20Sopenharmony_ci * as I-format command with p-bit set to one. Returns 0 if frame is last 6198c2ecf20Sopenharmony_ci * frame, 1 otherwise. 6208c2ecf20Sopenharmony_ci */ 6218c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk, struct sk_buff *skb) 6228c2ecf20Sopenharmony_ci{ 6238c2ecf20Sopenharmony_ci return !(skb_queue_len(&llc_sk(sk)->pdu_unack_q) + 1 == llc_sk(sk)->k); 6248c2ecf20Sopenharmony_ci} 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_ci/** 6278c2ecf20Sopenharmony_ci * conn_ev_qlfy_last_frame_eq_0 - checks if frame isn't last in tx window 6288c2ecf20Sopenharmony_ci * @sk: current connection structure. 6298c2ecf20Sopenharmony_ci * @skb: current event. 6308c2ecf20Sopenharmony_ci * 6318c2ecf20Sopenharmony_ci * This function determines when frame which is sent, isn't last frame of 6328c2ecf20Sopenharmony_ci * transmit window, if it isn't then this function return zero else return 6338c2ecf20Sopenharmony_ci * one. Returns 0 if frame isn't last frame, 1 otherwise. 6348c2ecf20Sopenharmony_ci */ 6358c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk, struct sk_buff *skb) 6368c2ecf20Sopenharmony_ci{ 6378c2ecf20Sopenharmony_ci return skb_queue_len(&llc_sk(sk)->pdu_unack_q) + 1 == llc_sk(sk)->k; 6388c2ecf20Sopenharmony_ci} 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct sk_buff *skb) 6418c2ecf20Sopenharmony_ci{ 6428c2ecf20Sopenharmony_ci return llc_sk(sk)->p_flag; 6438c2ecf20Sopenharmony_ci} 6448c2ecf20Sopenharmony_ci 6458c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct sk_buff *skb) 6468c2ecf20Sopenharmony_ci{ 6478c2ecf20Sopenharmony_ci u8 f_bit; 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_ci llc_pdu_decode_pf_bit(skb, &f_bit); 6508c2ecf20Sopenharmony_ci return llc_sk(sk)->p_flag == f_bit ? 0 : 1; 6518c2ecf20Sopenharmony_ci} 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk, struct sk_buff *skb) 6548c2ecf20Sopenharmony_ci{ 6558c2ecf20Sopenharmony_ci return llc_sk(sk)->remote_busy_flag; 6568c2ecf20Sopenharmony_ci} 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk, struct sk_buff *skb) 6598c2ecf20Sopenharmony_ci{ 6608c2ecf20Sopenharmony_ci return !llc_sk(sk)->remote_busy_flag; 6618c2ecf20Sopenharmony_ci} 6628c2ecf20Sopenharmony_ci 6638c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk, struct sk_buff *skb) 6648c2ecf20Sopenharmony_ci{ 6658c2ecf20Sopenharmony_ci return !(llc_sk(sk)->retry_count < llc_sk(sk)->n2); 6668c2ecf20Sopenharmony_ci} 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk, struct sk_buff *skb) 6698c2ecf20Sopenharmony_ci{ 6708c2ecf20Sopenharmony_ci return !(llc_sk(sk)->retry_count >= llc_sk(sk)->n2); 6718c2ecf20Sopenharmony_ci} 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct sk_buff *skb) 6748c2ecf20Sopenharmony_ci{ 6758c2ecf20Sopenharmony_ci return !llc_sk(sk)->s_flag; 6768c2ecf20Sopenharmony_ci} 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct sk_buff *skb) 6798c2ecf20Sopenharmony_ci{ 6808c2ecf20Sopenharmony_ci return llc_sk(sk)->s_flag; 6818c2ecf20Sopenharmony_ci} 6828c2ecf20Sopenharmony_ci 6838c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk, struct sk_buff *skb) 6848c2ecf20Sopenharmony_ci{ 6858c2ecf20Sopenharmony_ci return !llc_sk(sk)->cause_flag; 6868c2ecf20Sopenharmony_ci} 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk, struct sk_buff *skb) 6898c2ecf20Sopenharmony_ci{ 6908c2ecf20Sopenharmony_ci return llc_sk(sk)->cause_flag; 6918c2ecf20Sopenharmony_ci} 6928c2ecf20Sopenharmony_ci 6938c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_set_status_conn(struct sock *sk, struct sk_buff *skb) 6948c2ecf20Sopenharmony_ci{ 6958c2ecf20Sopenharmony_ci struct llc_conn_state_ev *ev = llc_conn_ev(skb); 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_ci ev->status = LLC_STATUS_CONN; 6988c2ecf20Sopenharmony_ci return 0; 6998c2ecf20Sopenharmony_ci} 7008c2ecf20Sopenharmony_ci 7018c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_set_status_disc(struct sock *sk, struct sk_buff *skb) 7028c2ecf20Sopenharmony_ci{ 7038c2ecf20Sopenharmony_ci struct llc_conn_state_ev *ev = llc_conn_ev(skb); 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci ev->status = LLC_STATUS_DISC; 7068c2ecf20Sopenharmony_ci return 0; 7078c2ecf20Sopenharmony_ci} 7088c2ecf20Sopenharmony_ci 7098c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_set_status_failed(struct sock *sk, struct sk_buff *skb) 7108c2ecf20Sopenharmony_ci{ 7118c2ecf20Sopenharmony_ci struct llc_conn_state_ev *ev = llc_conn_ev(skb); 7128c2ecf20Sopenharmony_ci 7138c2ecf20Sopenharmony_ci ev->status = LLC_STATUS_FAILED; 7148c2ecf20Sopenharmony_ci return 0; 7158c2ecf20Sopenharmony_ci} 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_set_status_remote_busy(struct sock *sk, 7188c2ecf20Sopenharmony_ci struct sk_buff *skb) 7198c2ecf20Sopenharmony_ci{ 7208c2ecf20Sopenharmony_ci struct llc_conn_state_ev *ev = llc_conn_ev(skb); 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_ci ev->status = LLC_STATUS_REMOTE_BUSY; 7238c2ecf20Sopenharmony_ci return 0; 7248c2ecf20Sopenharmony_ci} 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_set_status_refuse(struct sock *sk, struct sk_buff *skb) 7278c2ecf20Sopenharmony_ci{ 7288c2ecf20Sopenharmony_ci struct llc_conn_state_ev *ev = llc_conn_ev(skb); 7298c2ecf20Sopenharmony_ci 7308c2ecf20Sopenharmony_ci ev->status = LLC_STATUS_REFUSE; 7318c2ecf20Sopenharmony_ci return 0; 7328c2ecf20Sopenharmony_ci} 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_set_status_conflict(struct sock *sk, struct sk_buff *skb) 7358c2ecf20Sopenharmony_ci{ 7368c2ecf20Sopenharmony_ci struct llc_conn_state_ev *ev = llc_conn_ev(skb); 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_ci ev->status = LLC_STATUS_CONFLICT; 7398c2ecf20Sopenharmony_ci return 0; 7408c2ecf20Sopenharmony_ci} 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_ciint llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk, struct sk_buff *skb) 7438c2ecf20Sopenharmony_ci{ 7448c2ecf20Sopenharmony_ci struct llc_conn_state_ev *ev = llc_conn_ev(skb); 7458c2ecf20Sopenharmony_ci 7468c2ecf20Sopenharmony_ci ev->status = LLC_STATUS_RESET_DONE; 7478c2ecf20Sopenharmony_ci return 0; 7488c2ecf20Sopenharmony_ci} 749