^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #ifndef LLC_PDU_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #define LLC_PDU_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 1997 by Procom Technology,Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * This program can be redistributed or modified under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * GNU General Public License as published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is distributed without any warranty or implied warranty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * of merchantability or fitness for a particular purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * See the GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/if_ether.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /* Lengths of frame formats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define LLC_PDU_LEN_I 4 /* header and 2 control bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define LLC_PDU_LEN_S 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define LLC_PDU_LEN_U 3 /* header and 1 control byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /* header and 1 control byte and XID info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define LLC_PDU_LEN_U_XID (LLC_PDU_LEN_U + sizeof(struct llc_xid_info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /* Known SAP addresses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define LLC_GLOBAL_SAP 0xFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define LLC_NULL_SAP 0x00 /* not network-layer visible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define LLC_MGMT_INDIV 0x02 /* station LLC mgmt indiv addr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define LLC_MGMT_GRP 0x03 /* station LLC mgmt group addr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define LLC_RDE_SAP 0xA6 /* route ... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* SAP field bit masks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define LLC_ISO_RESERVED_SAP 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define LLC_SAP_GROUP_DSAP 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define LLC_SAP_RESP_SSAP 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /* Group/individual DSAP indicator is DSAP field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define LLC_PDU_GROUP_DSAP_MASK 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define LLC_PDU_IS_GROUP_DSAP(pdu) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) ((pdu->dsap & LLC_PDU_GROUP_DSAP_MASK) ? 0 : 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define LLC_PDU_IS_INDIV_DSAP(pdu) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) (!(pdu->dsap & LLC_PDU_GROUP_DSAP_MASK) ? 0 : 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* Command/response PDU indicator in SSAP field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define LLC_PDU_CMD_RSP_MASK 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define LLC_PDU_CMD 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define LLC_PDU_RSP 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define LLC_PDU_IS_CMD(pdu) ((pdu->ssap & LLC_PDU_RSP) ? 0 : 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define LLC_PDU_IS_RSP(pdu) ((pdu->ssap & LLC_PDU_RSP) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* Get PDU type from 2 lowest-order bits of control field first byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define LLC_PDU_TYPE_I_MASK 0x01 /* 16-bit control field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define LLC_PDU_TYPE_S_MASK 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define LLC_PDU_TYPE_U_MASK 0x03 /* 8-bit control field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define LLC_PDU_TYPE_MASK 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define LLC_PDU_TYPE_I 0 /* first bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define LLC_PDU_TYPE_S 1 /* first two bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define LLC_PDU_TYPE_U 3 /* first two bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define LLC_PDU_TYPE_U_XID 4 /* private type for detecting XID commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define LLC_PDU_TYPE_IS_I(pdu) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ((!(pdu->ctrl_1 & LLC_PDU_TYPE_I_MASK)) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define LLC_PDU_TYPE_IS_U(pdu) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) (((pdu->ctrl_1 & LLC_PDU_TYPE_U_MASK) == LLC_PDU_TYPE_U) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define LLC_PDU_TYPE_IS_S(pdu) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) (((pdu->ctrl_1 & LLC_PDU_TYPE_S_MASK) == LLC_PDU_TYPE_S) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /* U-format PDU control field masks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define LLC_U_PF_BIT_MASK 0x10 /* P/F bit mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define LLC_U_PF_IS_1(pdu) ((pdu->ctrl_1 & LLC_U_PF_BIT_MASK) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define LLC_U_PF_IS_0(pdu) ((!(pdu->ctrl_1 & LLC_U_PF_BIT_MASK)) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define LLC_U_PDU_CMD_MASK 0xEC /* cmd/rsp mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define LLC_U_PDU_CMD(pdu) (pdu->ctrl_1 & LLC_U_PDU_CMD_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define LLC_U_PDU_RSP(pdu) (pdu->ctrl_1 & LLC_U_PDU_CMD_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define LLC_1_PDU_CMD_UI 0x00 /* Type 1 cmds/rsps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define LLC_1_PDU_CMD_XID 0xAC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define LLC_1_PDU_CMD_TEST 0xE0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define LLC_2_PDU_CMD_SABME 0x6C /* Type 2 cmds/rsps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define LLC_2_PDU_CMD_DISC 0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define LLC_2_PDU_RSP_UA 0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define LLC_2_PDU_RSP_DM 0x0C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define LLC_2_PDU_RSP_FRMR 0x84
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* Type 1 operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /* XID information field bit masks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /* LLC format identifier (byte 1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define LLC_XID_FMT_ID 0x81 /* first byte must be this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* LLC types/classes identifier (byte 2) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define LLC_XID_CLASS_ZEROS_MASK 0xE0 /* these must be zeros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define LLC_XID_CLASS_MASK 0x1F /* AND with byte to get below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define LLC_XID_NULL_CLASS_1 0x01 /* if NULL LSAP...use these */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define LLC_XID_NULL_CLASS_2 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define LLC_XID_NULL_CLASS_3 0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define LLC_XID_NULL_CLASS_4 0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define LLC_XID_NNULL_TYPE_1 0x01 /* if non-NULL LSAP...use these */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define LLC_XID_NNULL_TYPE_2 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define LLC_XID_NNULL_TYPE_3 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define LLC_XID_NNULL_TYPE_1_2 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define LLC_XID_NNULL_TYPE_1_3 0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define LLC_XID_NNULL_TYPE_2_3 0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define LLC_XID_NNULL_ALL 0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /* Sender Receive Window (byte 3) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define LLC_XID_RW_MASK 0xFE /* AND with value to get below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define LLC_XID_MIN_RW 0x02 /* lowest-order bit always zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /* Type 2 operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define LLC_2_SEQ_NBR_MODULO ((u8) 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* I-PDU masks ('ctrl' is I-PDU control word) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define LLC_I_GET_NS(pdu) (u8)((pdu->ctrl_1 & 0xFE) >> 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define LLC_I_GET_NR(pdu) (u8)((pdu->ctrl_2 & 0xFE) >> 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define LLC_I_PF_BIT_MASK 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define LLC_I_PF_IS_0(pdu) ((!(pdu->ctrl_2 & LLC_I_PF_BIT_MASK)) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define LLC_I_PF_IS_1(pdu) ((pdu->ctrl_2 & LLC_I_PF_BIT_MASK) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* S-PDU supervisory commands and responses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define LLC_S_PDU_CMD_MASK 0x0C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define LLC_S_PDU_CMD(pdu) (pdu->ctrl_1 & LLC_S_PDU_CMD_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #define LLC_S_PDU_RSP(pdu) (pdu->ctrl_1 & LLC_S_PDU_CMD_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define LLC_2_PDU_CMD_RR 0x00 /* rx ready cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define LLC_2_PDU_RSP_RR 0x00 /* rx ready rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #define LLC_2_PDU_CMD_REJ 0x08 /* reject PDU cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define LLC_2_PDU_RSP_REJ 0x08 /* reject PDU rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define LLC_2_PDU_CMD_RNR 0x04 /* rx not ready cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #define LLC_2_PDU_RSP_RNR 0x04 /* rx not ready rsp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define LLC_S_PF_BIT_MASK 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #define LLC_S_PF_IS_0(pdu) ((!(pdu->ctrl_2 & LLC_S_PF_BIT_MASK)) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #define LLC_S_PF_IS_1(pdu) ((pdu->ctrl_2 & LLC_S_PF_BIT_MASK) ? 1 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #define PDU_SUPV_GET_Nr(pdu) ((pdu->ctrl_2 & 0xFE) >> 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define PDU_GET_NEXT_Vr(sn) (((sn) + 1) & ~LLC_2_SEQ_NBR_MODULO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* FRMR information field macros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define FRMR_INFO_LENGTH 5 /* 5 bytes of information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * info is pointer to FRMR info field structure; 'rej_ctrl' is byte pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * (if U-PDU) or word pointer to rejected PDU control field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #define FRMR_INFO_SET_REJ_CNTRL(info,rej_ctrl) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) info->rej_pdu_ctrl = ((*((u8 *) rej_ctrl) & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) LLC_PDU_TYPE_U) != LLC_PDU_TYPE_U ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) (u16)*((u16 *) rej_ctrl) : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) (((u16) *((u8 *) rej_ctrl)) & 0x00FF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * Info is pointer to FRMR info field structure; 'vs' is a byte containing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * send state variable value in low-order 7 bits (insure the lowest-order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * bit remains zero (0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #define FRMR_INFO_SET_Vs(info,vs) (info->curr_ssv = (((u8) vs) << 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #define FRMR_INFO_SET_Vr(info,vr) (info->curr_rsv = (((u8) vr) << 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * Info is pointer to FRMR info field structure; 'cr' is a byte containing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * the C/R bit value in the low-order bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #define FRMR_INFO_SET_C_R_BIT(info, cr) (info->curr_rsv |= (((u8) cr) & 0x01))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * In the remaining five macros, 'info' is pointer to FRMR info field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * structure; 'ind' is a byte containing the bit value to set in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * lowest-order bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #define FRMR_INFO_SET_INVALID_PDU_CTRL_IND(info, ind) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) (info->ind_bits = ((info->ind_bits & 0xFE) | (((u8) ind) & 0x01)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #define FRMR_INFO_SET_INVALID_PDU_INFO_IND(info, ind) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) (info->ind_bits = ( (info->ind_bits & 0xFD) | (((u8) ind) & 0x02)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #define FRMR_INFO_SET_PDU_INFO_2LONG_IND(info, ind) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) (info->ind_bits = ( (info->ind_bits & 0xFB) | (((u8) ind) & 0x04)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #define FRMR_INFO_SET_PDU_INVALID_Nr_IND(info, ind) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) (info->ind_bits = ( (info->ind_bits & 0xF7) | (((u8) ind) & 0x08)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #define FRMR_INFO_SET_PDU_INVALID_Ns_IND(info, ind) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) (info->ind_bits = ( (info->ind_bits & 0xEF) | (((u8) ind) & 0x10)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) /* Sequence-numbered PDU format (4 bytes in length) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct llc_pdu_sn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) u8 dsap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) u8 ssap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) u8 ctrl_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) u8 ctrl_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return (struct llc_pdu_sn *)skb_network_header(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /* Un-numbered PDU format (3 bytes in length) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct llc_pdu_un {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) u8 dsap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) u8 ssap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) u8 ctrl_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return (struct llc_pdu_un *)skb_network_header(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * llc_pdu_header_init - initializes pdu header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * @skb: input skb that header must be set into it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * @type: type of PDU (U, I or S).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * @ssap: source sap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * @dsap: destination sap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * @cr: command/response bit (0 or 1).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * This function sets DSAP, SSAP and command/Response bit in LLC header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static inline void llc_pdu_header_init(struct sk_buff *skb, u8 type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) u8 ssap, u8 dsap, u8 cr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) int hlen = 4; /* default value for I and S types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) struct llc_pdu_un *pdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) case LLC_PDU_TYPE_U:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) hlen = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) case LLC_PDU_TYPE_U_XID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) hlen = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) skb_push(skb, hlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) skb_reset_network_header(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) pdu->dsap = dsap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) pdu->ssap = ssap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) pdu->ssap |= cr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * llc_pdu_decode_sa - extracs source address (MAC) of input frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * @skb: input skb that source address must be extracted from it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * @sa: pointer to source address (6 byte array).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * This function extracts source address(MAC) of input frame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if (skb->protocol == htons(ETH_P_802_2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * llc_pdu_decode_da - extracts dest address of input frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * @skb: input skb that destination address must be extracted from it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) * @sa: pointer to destination address (6 byte array).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * This function extracts destination address(MAC) of input frame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) static inline void llc_pdu_decode_da(struct sk_buff *skb, u8 *da)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) if (skb->protocol == htons(ETH_P_802_2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * llc_pdu_decode_ssap - extracts source SAP of input frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * @skb: input skb that source SAP must be extracted from it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) * @ssap: source SAP (output argument).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * This function extracts source SAP of input frame. Right bit of SSAP is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * command/response bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static inline void llc_pdu_decode_ssap(struct sk_buff *skb, u8 *ssap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) *ssap = llc_pdu_un_hdr(skb)->ssap & 0xFE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * llc_pdu_decode_dsap - extracts dest SAP of input frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * @skb: input skb that destination SAP must be extracted from it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) * @dsap: destination SAP (output argument).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * This function extracts destination SAP of input frame. right bit of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * DSAP designates individual/group SAP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) static inline void llc_pdu_decode_dsap(struct sk_buff *skb, u8 *dsap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) *dsap = llc_pdu_un_hdr(skb)->dsap & 0xFE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * llc_pdu_init_as_ui_cmd - sets LLC header as UI PDU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * @skb: input skb that header must be set into it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * This function sets third byte of LLC header as a UI PDU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) static inline void llc_pdu_init_as_ui_cmd(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) pdu->ctrl_1 = LLC_PDU_TYPE_U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) pdu->ctrl_1 |= LLC_1_PDU_CMD_UI;
^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) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * llc_pdu_init_as_test_cmd - sets PDU as TEST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * @skb - Address of the skb to build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * Sets a PDU as TEST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) static inline void llc_pdu_init_as_test_cmd(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) pdu->ctrl_1 = LLC_PDU_TYPE_U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) pdu->ctrl_1 |= LLC_1_PDU_CMD_TEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) pdu->ctrl_1 |= LLC_U_PF_BIT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) * llc_pdu_init_as_test_rsp - build TEST response PDU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * @skb: Address of the skb to build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * @ev_skb: The received TEST command PDU frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) * Builds a pdu frame as a TEST response.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) static inline void llc_pdu_init_as_test_rsp(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) struct sk_buff *ev_skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) pdu->ctrl_1 = LLC_PDU_TYPE_U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) pdu->ctrl_1 |= LLC_1_PDU_CMD_TEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) pdu->ctrl_1 |= LLC_U_PF_BIT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) if (ev_skb->protocol == htons(ETH_P_802_2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) struct llc_pdu_un *ev_pdu = llc_pdu_un_hdr(ev_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) int dsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) dsize = ntohs(eth_hdr(ev_skb)->h_proto) - 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) memcpy(((u8 *)pdu) + 3, ((u8 *)ev_pdu) + 3, dsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) skb_put(skb, dsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) /* LLC Type 1 XID command/response information fields format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) struct llc_xid_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) u8 fmt_id; /* always 0x81 for LLC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) u8 type; /* different if NULL/non-NULL LSAP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) u8 rw; /* sender receive window */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) * @skb: input skb that header must be set into it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * This function sets third,fourth,fifth and sixth bytes of LLC header as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * a XID PDU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) static inline void llc_pdu_init_as_xid_cmd(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) u8 svcs_supported, u8 rx_window)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) struct llc_xid_info *xid_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) pdu->ctrl_1 = LLC_PDU_TYPE_U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) pdu->ctrl_1 |= LLC_1_PDU_CMD_XID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) pdu->ctrl_1 |= LLC_U_PF_BIT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) xid_info = (struct llc_xid_info *)(((u8 *)&pdu->ctrl_1) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) xid_info->fmt_id = LLC_XID_FMT_ID; /* 0x81 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) xid_info->type = svcs_supported;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) xid_info->rw = rx_window << 1; /* size of receive window */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) /* no need to push/put since llc_pdu_header_init() has already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) * pushed 3 + 3 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) * llc_pdu_init_as_xid_rsp - builds XID response PDU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) * @skb: Address of the skb to build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * @svcs_supported: The class of the LLC (I or II)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) * @rx_window: The size of the receive window of the LLC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) * Builds a pdu frame as an XID response.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) static inline void llc_pdu_init_as_xid_rsp(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) u8 svcs_supported, u8 rx_window)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) struct llc_xid_info *xid_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) pdu->ctrl_1 = LLC_PDU_TYPE_U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) pdu->ctrl_1 |= LLC_1_PDU_CMD_XID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) pdu->ctrl_1 |= LLC_U_PF_BIT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) xid_info = (struct llc_xid_info *)(((u8 *)&pdu->ctrl_1) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) xid_info->fmt_id = LLC_XID_FMT_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) xid_info->type = svcs_supported;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) xid_info->rw = rx_window << 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) skb_put(skb, sizeof(struct llc_xid_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) /* LLC Type 2 FRMR response information field format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) struct llc_frmr_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) u16 rej_pdu_ctrl; /* bits 1-8 if U-PDU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) u8 curr_ssv; /* current send state variable val */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) u8 curr_rsv; /* current receive state variable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) u8 ind_bits; /* indicator bits set with macro */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) void llc_pdu_decode_pf_bit(struct sk_buff *skb, u8 *pf_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) void llc_pdu_init_as_disc_cmd(struct sk_buff *skb, u8 p_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) void llc_pdu_init_as_i_cmd(struct sk_buff *skb, u8 p_bit, u8 ns, u8 nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) void llc_pdu_init_as_rej_cmd(struct sk_buff *skb, u8 p_bit, u8 nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) void llc_pdu_init_as_rnr_cmd(struct sk_buff *skb, u8 p_bit, u8 nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) void llc_pdu_init_as_rr_cmd(struct sk_buff *skb, u8 p_bit, u8 nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) void llc_pdu_init_as_sabme_cmd(struct sk_buff *skb, u8 p_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) void llc_pdu_init_as_dm_rsp(struct sk_buff *skb, u8 f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) void llc_pdu_init_as_frmr_rsp(struct sk_buff *skb, struct llc_pdu_sn *prev_pdu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) u8 f_bit, u8 vs, u8 vr, u8 vzyxw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) void llc_pdu_init_as_rr_rsp(struct sk_buff *skb, u8 f_bit, u8 nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) void llc_pdu_init_as_rej_rsp(struct sk_buff *skb, u8 f_bit, u8 nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) void llc_pdu_init_as_rnr_rsp(struct sk_buff *skb, u8 f_bit, u8 nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) void llc_pdu_init_as_ua_rsp(struct sk_buff *skb, u8 f_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) #endif /* LLC_PDU_H */