llc_s_ev.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. int llc_sap_ev_activation_req(struct llc_sap *sap, struct sk_buff *skb)
  23. {
  24. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  25. return ev->type == LLC_SAP_EV_TYPE_SIMPLE &&
  26. ev->prim_type == LLC_SAP_EV_ACTIVATION_REQ ? 0 : 1;
  27. }
  28. int llc_sap_ev_rx_ui(struct llc_sap *sap, struct sk_buff *skb)
  29. {
  30. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  31. struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
  32. return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_CMD(pdu) &&
  33. LLC_PDU_TYPE_IS_U(pdu) &&
  34. LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_UI ? 0 : 1;
  35. }
  36. int llc_sap_ev_unitdata_req(struct llc_sap *sap, struct sk_buff *skb)
  37. {
  38. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  39. return ev->type == LLC_SAP_EV_TYPE_PRIM &&
  40. ev->prim == LLC_DATAUNIT_PRIM &&
  41. ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
  42. }
  43. int llc_sap_ev_xid_req(struct llc_sap *sap, struct sk_buff *skb)
  44. {
  45. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  46. return ev->type == LLC_SAP_EV_TYPE_PRIM &&
  47. ev->prim == LLC_XID_PRIM &&
  48. ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
  49. }
  50. int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct sk_buff *skb)
  51. {
  52. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  53. struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
  54. return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_CMD(pdu) &&
  55. LLC_PDU_TYPE_IS_U(pdu) &&
  56. LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_XID ? 0 : 1;
  57. }
  58. int llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct sk_buff *skb)
  59. {
  60. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  61. struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
  62. return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_RSP(pdu) &&
  63. LLC_PDU_TYPE_IS_U(pdu) &&
  64. LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_XID ? 0 : 1;
  65. }
  66. int llc_sap_ev_test_req(struct llc_sap *sap, struct sk_buff *skb)
  67. {
  68. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  69. return ev->type == LLC_SAP_EV_TYPE_PRIM &&
  70. ev->prim == LLC_TEST_PRIM &&
  71. ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
  72. }
  73. int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct sk_buff *skb)
  74. {
  75. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  76. struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
  77. return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_CMD(pdu) &&
  78. LLC_PDU_TYPE_IS_U(pdu) &&
  79. LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_TEST ? 0 : 1;
  80. }
  81. int llc_sap_ev_rx_test_r(struct llc_sap *sap, struct sk_buff *skb)
  82. {
  83. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  84. struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
  85. return ev->type == LLC_SAP_EV_TYPE_PDU && LLC_PDU_IS_RSP(pdu) &&
  86. LLC_PDU_TYPE_IS_U(pdu) &&
  87. LLC_U_PDU_RSP(pdu) == LLC_1_PDU_CMD_TEST ? 0 : 1;
  88. }
  89. int llc_sap_ev_deactivation_req(struct llc_sap *sap, struct sk_buff *skb)
  90. {
  91. struct llc_sap_state_ev *ev = llc_sap_ev(skb);
  92. return ev->type == LLC_SAP_EV_TYPE_SIMPLE &&
  93. ev->prim_type == LLC_SAP_EV_DEACTIVATION_REQ ? 0 : 1;
  94. }