^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * llc_s_ev.c - Defines SAP component events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * The followed event functions are SAP component events which are described
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * in 802.2 LLC protocol standard document.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (c) 1997 by Procom Technology, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * This program can be redistributed or modified under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * GNU General Public License as published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This program is distributed without any warranty or implied warranty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * of merchantability or fitness for a particular purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * See the GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/socket.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <net/llc_if.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <net/llc_s_ev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <net/llc_pdu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) int llc_sap_ev_activation_req(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) return ev->type == LLC_SAP_EV_TYPE_SIMPLE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ev->prim_type == LLC_SAP_EV_ACTIVATION_REQ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) int llc_sap_ev_rx_ui(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_CMD(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_UI ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int llc_sap_ev_unitdata_req(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return ev->type == LLC_SAP_EV_TYPE_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ev->prim == LLC_DATAUNIT_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^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) int llc_sap_ev_xid_req(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) return ev->type == LLC_SAP_EV_TYPE_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ev->prim == LLC_XID_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_CMD(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_XID ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_RSP(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_XID ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) int llc_sap_ev_test_req(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return ev->type == LLC_SAP_EV_TYPE_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) ev->prim == LLC_TEST_PRIM &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_CMD(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_TEST ? 0 : 1;
^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_sap_ev_rx_test_r(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_RSP(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) LLC_PDU_TYPE_IS_U(pdu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_TEST ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int llc_sap_ev_deactivation_req(struct llc_sap *sap, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct llc_sap_state_ev *ev = llc_sap_ev(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) return ev->type == LLC_SAP_EV_TYPE_SIMPLE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) ev->prim_type == LLC_SAP_EV_DEACTIVATION_REQ ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }