^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * llc_c_ev.c - Connection component state transition event qualifiers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * A 'state' consists of a number of possible event matching functions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * the actions associated with each being executed when that event is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * matched; a 'state machine' accepts events in a serial fashion from an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * event queue. Each event is passed to each successive event matching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * function until a match is made (the event matching function returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * success, or '0') or the list of event matching functions is exhausted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * If a match is made, the actions associated with the event are executed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * and the state is changed to that event's transition state. Before some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * events are recognized, even after a match has been made, a certain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * number of 'event qualifier' functions must also be executed. If these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * all execute successfully, then the event is finally executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * These event functions must return 0 for success, to show a matched
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * event, of 1 if the event does not match. Event qualifier functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * must return a 0 for success or a non-zero for failure. Each function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * is simply responsible for verifying one single thing and returning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * either a success or failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * All of followed event functions are described in 802.2 LLC Protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * standard document except two functions that we added that will explain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * in their comments, at below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * Copyright (c) 1997 by Procom Technology, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * This program can be redistributed or modified under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * GNU General Public License as published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * This program is distributed without any warranty or implied warranty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * of merchantability or fitness for a particular purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * See the GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <net/llc_conn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <net/llc_sap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <net/llc_c_ac.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <net/llc_c_ev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <net/llc_pdu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #if 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define dprintk(args...) printk(KERN_DEBUG args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define dprintk(args...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * llc_util_ns_inside_rx_window - check if sequence number is in rx window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * @ns: sequence number of received pdu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * @vr: sequence number which receiver expects to receive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * @rw: receive window size of receiver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * Checks if sequence number of received PDU is in range of receive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * window. Returns 0 for success, 1 otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static u16 llc_util_ns_inside_rx_window(u8 ns, u8 vr, u8 rw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) return !llc_circular_between(vr, ns,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) (vr + rw - 1) % LLC_2_SEQ_NBR_MODULO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * llc_util_nr_inside_tx_window - check if sequence number is in tx window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * @sk: current connection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * @nr: N(R) of received PDU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * This routine checks if N(R) of received PDU is in range of transmit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * window; on the other hand checks if received PDU acknowledges some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * outstanding PDUs that are in transmit window. Returns 0 for success, 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static u16 llc_util_nr_inside_tx_window(struct sock *sk, u8 nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) u8 nr1, nr2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct llc_pdu_sn *pdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct llc_sock *llc = llc_sk(sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (llc->dev->flags & IFF_LOOPBACK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) if (skb_queue_empty(&llc->pdu_unack_q))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) skb = skb_peek(&llc->pdu_unack_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) nr1 = LLC_I_GET_NS(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) skb = skb_peek_tail(&llc->pdu_unack_q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) nr2 = LLC_I_GET_NS(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) rc = !llc_circular_between(nr1, nr, (nr2 + 1) % LLC_2_SEQ_NBR_MODULO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) return ev->prim == LLC_CONN_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return ev->prim == LLC_DATA_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return ev->prim == LLC_DISC_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return ev->prim == LLC_RESET_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) return ev->type == LLC_CONN_EV_TYPE_SIMPLE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_DETECTED ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) return ev->type == LLC_CONN_EV_TYPE_SIMPLE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_CLEARED ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_DISC ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_DM ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return llc_conn_space(sk, skb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) LLC_I_PF_IS_0(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return llc_conn_space(sk, skb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) LLC_I_PF_IS_1(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) const u8 vr = llc_sk(sk)->vR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) const u8 ns = LLC_I_GET_NS(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) LLC_I_PF_IS_0(pdu) && ns != vr &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) const u8 vr = llc_sk(sk)->vR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) const u8 ns = LLC_I_GET_NS(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) LLC_I_PF_IS_1(pdu) && ns != vr &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) const struct llc_pdu_sn * pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) const u8 vr = llc_sk(sk)->vR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) const u8 ns = LLC_I_GET_NS(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) const u16 rc = LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) ns != vr &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) dprintk("%s: matched, state=%d, ns=%d, vr=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) __func__, llc_sk(sk)->state, ns, vr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) return llc_conn_space(sk, skb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) LLC_I_PF_IS_0(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) LLC_I_PF_IS_1(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) return llc_conn_space(sk, skb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) LLC_I_GET_NS(pdu) == llc_sk(sk)->vR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) const u8 vr = llc_sk(sk)->vR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) const u8 ns = LLC_I_GET_NS(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) LLC_I_PF_IS_0(pdu) && ns != vr &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) const u8 vr = llc_sk(sk)->vR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) const u8 ns = LLC_I_GET_NS(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) LLC_I_PF_IS_1(pdu) && ns != vr &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) const u8 vr = llc_sk(sk)->vR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) const u8 ns = LLC_I_GET_NS(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) const u8 vr = llc_sk(sk)->vR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) const u8 ns = LLC_I_GET_NS(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) const u16 rc = LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ns != vr &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) dprintk("%s: matched, state=%d, ns=%d, vr=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) __func__, llc_sk(sk)->state, ns, vr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) LLC_S_PF_IS_0(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_REJ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) LLC_S_PF_IS_1(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_REJ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) LLC_S_PF_IS_0(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) LLC_S_PF_IS_1(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) LLC_S_PF_IS_0(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RNR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) LLC_S_PF_IS_1(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RNR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) LLC_S_PF_IS_0(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RNR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) LLC_S_PF_IS_1(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RNR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) LLC_S_PF_IS_0(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) LLC_S_PF_IS_1(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) LLC_S_PDU_CMD(pdu) == LLC_2_PDU_CMD_RR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) return llc_conn_space(sk, skb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) LLC_S_PF_IS_0(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) return llc_conn_space(sk, skb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) LLC_S_PF_IS_1(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_RR ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_UA ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) u16 rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) if (LLC_PDU_IS_CMD(pdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) if (LLC_I_PF_IS_1(pdu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) } else if (LLC_PDU_TYPE_IS_U(pdu) && LLC_U_PF_IS_1(pdu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) u16 rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) if (LLC_PDU_IS_CMD(pdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) else if (LLC_PDU_TYPE_IS_U(pdu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) switch (LLC_U_PDU_CMD(pdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) case LLC_2_PDU_CMD_SABME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) case LLC_2_PDU_CMD_DISC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) u16 rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) if (LLC_PDU_IS_RSP(pdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) else if (LLC_PDU_TYPE_IS_U(pdu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) switch (LLC_U_PDU_RSP(pdu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) case LLC_2_PDU_RSP_UA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) case LLC_2_PDU_RSP_DM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) case LLC_2_PDU_RSP_FRMR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) u16 rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) const u8 vs = llc_sk(sk)->vS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) const u8 nr = LLC_I_GET_NR(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) if (LLC_PDU_IS_CMD(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) nr != vs && llc_util_nr_inside_tx_window(sk, nr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) dprintk("%s: matched, state=%d, vs=%d, nr=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) __func__, llc_sk(sk)->state, vs, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) u16 rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) const u8 vs = llc_sk(sk)->vS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) const u8 nr = LLC_I_GET_NR(pdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) if (LLC_PDU_IS_RSP(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) nr != vs && llc_util_nr_inside_tx_window(sk, nr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) dprintk("%s: matched, state=%d, vs=%d, nr=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) __func__, llc_sk(sk)->state, vs, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) return ev->type != LLC_CONN_EV_TYPE_P_TMR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) return ev->type != LLC_CONN_EV_TYPE_ACK_TMR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) return ev->type != LLC_CONN_EV_TYPE_REJ_TMR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) return ev->type != LLC_CONN_EV_TYPE_BUSY_TMR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) return ev->type == LLC_CONN_EV_TYPE_SIMPLE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) ev->prim_type == LLC_CONN_EV_TX_BUFF_FULL ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) /* Event qualifier functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) * these functions simply verify the value of a state flag associated with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) * the connection and return either a 0 for success or a non-zero value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) * for not-success; verify the event is the type we expect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) int llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) return llc_sk(sk)->data_flag != 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) int llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) return llc_sk(sk)->data_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) int llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) return llc_sk(sk)->data_flag != 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) return llc_sk(sk)->p_flag != 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) * conn_ev_qlfy_last_frame_eq_1 - checks if frame is last in tx window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) * @sk: current connection structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) * @skb: current event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) * This function determines when frame which is sent, is last frame of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) * transmit window, if it is then this function return zero else return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) * one. This function is used for sending last frame of transmit window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) * as I-format command with p-bit set to one. Returns 0 if frame is last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) * frame, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) int llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) return !(skb_queue_len(&llc_sk(sk)->pdu_unack_q) + 1 == llc_sk(sk)->k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) * conn_ev_qlfy_last_frame_eq_0 - checks if frame isn't last in tx window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) * @sk: current connection structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) * @skb: current event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) * This function determines when frame which is sent, isn't last frame of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) * transmit window, if it isn't then this function return zero else return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) * one. Returns 0 if frame isn't last frame, 1 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) int llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) return skb_queue_len(&llc_sk(sk)->pdu_unack_q) + 1 == llc_sk(sk)->k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) int llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) return llc_sk(sk)->p_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) int llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) u8 f_bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) llc_pdu_decode_pf_bit(skb, &f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) return llc_sk(sk)->p_flag == f_bit ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) int llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) return llc_sk(sk)->remote_busy_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) int llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) return !llc_sk(sk)->remote_busy_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) int llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) return !(llc_sk(sk)->retry_count < llc_sk(sk)->n2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) int llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) return !(llc_sk(sk)->retry_count >= llc_sk(sk)->n2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) int llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) return !llc_sk(sk)->s_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) int llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) return llc_sk(sk)->s_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) int llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) return !llc_sk(sk)->cause_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) int llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) return llc_sk(sk)->cause_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) int llc_conn_ev_qlfy_set_status_conn(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) ev->status = LLC_STATUS_CONN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) int llc_conn_ev_qlfy_set_status_disc(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) ev->status = LLC_STATUS_DISC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) int llc_conn_ev_qlfy_set_status_failed(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) ev->status = LLC_STATUS_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) int llc_conn_ev_qlfy_set_status_remote_busy(struct sock *sk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) ev->status = LLC_STATUS_REMOTE_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) int llc_conn_ev_qlfy_set_status_refuse(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) ev->status = LLC_STATUS_REFUSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) int llc_conn_ev_qlfy_set_status_conflict(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) ev->status = LLC_STATUS_CONFLICT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) int llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) struct llc_conn_state_ev *ev = llc_conn_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) ev->status = LLC_STATUS_RESET_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) }