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