162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * llc_s_ev.c - Defines SAP component events 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * The followed event functions are SAP component events which are described 562306a36Sopenharmony_ci * in 802.2 LLC protocol standard document. 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (c) 1997 by Procom Technology, Inc. 862306a36Sopenharmony_ci * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br> 962306a36Sopenharmony_ci * 1062306a36Sopenharmony_ci * This program can be redistributed or modified under the terms of the 1162306a36Sopenharmony_ci * GNU General Public License as published by the Free Software Foundation. 1262306a36Sopenharmony_ci * This program is distributed without any warranty or implied warranty 1362306a36Sopenharmony_ci * of merchantability or fitness for a particular purpose. 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * See the GNU General Public License for more details. 1662306a36Sopenharmony_ci */ 1762306a36Sopenharmony_ci#include <linux/socket.h> 1862306a36Sopenharmony_ci#include <net/sock.h> 1962306a36Sopenharmony_ci#include <net/llc_if.h> 2062306a36Sopenharmony_ci#include <net/llc_s_ev.h> 2162306a36Sopenharmony_ci#include <net/llc_pdu.h> 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ciint llc_sap_ev_activation_req(struct llc_sap *sap, struct sk_buff *skb) 2462306a36Sopenharmony_ci{ 2562306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_SIMPLE && 2862306a36Sopenharmony_ci ev->prim_type == LLC_SAP_EV_ACTIVATION_REQ ? 0 : 1; 2962306a36Sopenharmony_ci} 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ciint llc_sap_ev_rx_ui(struct llc_sap *sap, struct sk_buff *skb) 3262306a36Sopenharmony_ci{ 3362306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 3462306a36Sopenharmony_ci struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_CMD(pdu) && 3762306a36Sopenharmony_ci LLC_PDU_TYPE_IS_U(pdu) && 3862306a36Sopenharmony_ci LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_UI ? 0 : 1; 3962306a36Sopenharmony_ci} 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ciint llc_sap_ev_unitdata_req(struct llc_sap *sap, struct sk_buff *skb) 4262306a36Sopenharmony_ci{ 4362306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_PRIM && 4662306a36Sopenharmony_ci ev->prim == LLC_DATAUNIT_PRIM && 4762306a36Sopenharmony_ci ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci} 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ciint llc_sap_ev_xid_req(struct llc_sap *sap, struct sk_buff *skb) 5262306a36Sopenharmony_ci{ 5362306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_PRIM && 5662306a36Sopenharmony_ci ev->prim == LLC_XID_PRIM && 5762306a36Sopenharmony_ci ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 5862306a36Sopenharmony_ci} 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ciint llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct sk_buff *skb) 6162306a36Sopenharmony_ci{ 6262306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 6362306a36Sopenharmony_ci struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_CMD(pdu) && 6662306a36Sopenharmony_ci LLC_PDU_TYPE_IS_U(pdu) && 6762306a36Sopenharmony_ci LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_XID ? 0 : 1; 6862306a36Sopenharmony_ci} 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ciint llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct sk_buff *skb) 7162306a36Sopenharmony_ci{ 7262306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 7362306a36Sopenharmony_ci struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_RSP(pdu) && 7662306a36Sopenharmony_ci LLC_PDU_TYPE_IS_U(pdu) && 7762306a36Sopenharmony_ci LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_XID ? 0 : 1; 7862306a36Sopenharmony_ci} 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ciint llc_sap_ev_test_req(struct llc_sap *sap, struct sk_buff *skb) 8162306a36Sopenharmony_ci{ 8262306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_PRIM && 8562306a36Sopenharmony_ci ev->prim == LLC_TEST_PRIM && 8662306a36Sopenharmony_ci ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 8762306a36Sopenharmony_ci} 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ciint llc_sap_ev_rx_test_c(struct llc_sap *sap, struct sk_buff *skb) 9062306a36Sopenharmony_ci{ 9162306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 9262306a36Sopenharmony_ci struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_CMD(pdu) && 9562306a36Sopenharmony_ci LLC_PDU_TYPE_IS_U(pdu) && 9662306a36Sopenharmony_ci LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_TEST ? 0 : 1; 9762306a36Sopenharmony_ci} 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ciint llc_sap_ev_rx_test_r(struct llc_sap *sap, struct sk_buff *skb) 10062306a36Sopenharmony_ci{ 10162306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 10262306a36Sopenharmony_ci struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_RSP(pdu) && 10562306a36Sopenharmony_ci LLC_PDU_TYPE_IS_U(pdu) && 10662306a36Sopenharmony_ci LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_TEST ? 0 : 1; 10762306a36Sopenharmony_ci} 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ciint llc_sap_ev_deactivation_req(struct llc_sap *sap, struct sk_buff *skb) 11062306a36Sopenharmony_ci{ 11162306a36Sopenharmony_ci struct llc_sap_state_ev *ev = llc_sap_ev(skb); 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci return ev->type == LLC_SAP_EV_TYPE_SIMPLE && 11462306a36Sopenharmony_ci ev->prim_type == LLC_SAP_EV_DEACTIVATION_REQ ? 0 : 1; 11562306a36Sopenharmony_ci} 116