Lines Matching +full:byte +full:- +full:order
5 * 2001-2003 by Arnaldo Carvalho de Melo <[email protected]>
20 #define LLC_PDU_LEN_U 3 /* header and 1 control byte */
21 /* header and 1 control byte and XID info */
25 #define LLC_NULL_SAP 0x00 /* not network-layer visible */
38 ((pdu->dsap & LLC_PDU_GROUP_DSAP_MASK) ? 0 : 1)
40 (!(pdu->dsap & LLC_PDU_GROUP_DSAP_MASK) ? 0 : 1)
46 #define LLC_PDU_IS_CMD(pdu) ((pdu->ssap & LLC_PDU_RSP) ? 0 : 1)
47 #define LLC_PDU_IS_RSP(pdu) ((pdu->ssap & LLC_PDU_RSP) ? 1 : 0)
49 /* Get PDU type from 2 lowest-order bits of control field first byte */
50 #define LLC_PDU_TYPE_I_MASK 0x01 /* 16-bit control field */
52 #define LLC_PDU_TYPE_U_MASK 0x03 /* 8-bit control field */
61 ((!(pdu->ctrl_1 & LLC_PDU_TYPE_I_MASK)) ? 1 : 0)
64 (((pdu->ctrl_1 & LLC_PDU_TYPE_U_MASK) == LLC_PDU_TYPE_U) ? 1 : 0)
67 (((pdu->ctrl_1 & LLC_PDU_TYPE_S_MASK) == LLC_PDU_TYPE_S) ? 1 : 0)
69 /* U-format PDU control field masks */
71 #define LLC_U_PF_IS_1(pdu) ((pdu->ctrl_1 & LLC_U_PF_BIT_MASK) ? 1 : 0)
72 #define LLC_U_PF_IS_0(pdu) ((!(pdu->ctrl_1 & LLC_U_PF_BIT_MASK)) ? 1 : 0)
75 #define LLC_U_PDU_CMD(pdu) (pdu->ctrl_1 & LLC_U_PDU_CMD_MASK)
76 #define LLC_U_PDU_RSP(pdu) (pdu->ctrl_1 & LLC_U_PDU_CMD_MASK)
92 /* LLC format identifier (byte 1) */
93 #define LLC_XID_FMT_ID 0x81 /* first byte must be this */
95 /* LLC types/classes identifier (byte 2) */
97 #define LLC_XID_CLASS_MASK 0x1F /* AND with byte to get below */
104 #define LLC_XID_NNULL_TYPE_1 0x01 /* if non-NULL LSAP...use these */
112 /* Sender Receive Window (byte 3) */
115 #define LLC_XID_MIN_RW 0x02 /* lowest-order bit always zero */
121 /* I-PDU masks ('ctrl' is I-PDU control word) */
122 #define LLC_I_GET_NS(pdu) (u8)((pdu->ctrl_1 & 0xFE) >> 1)
123 #define LLC_I_GET_NR(pdu) (u8)((pdu->ctrl_2 & 0xFE) >> 1)
127 #define LLC_I_PF_IS_0(pdu) ((!(pdu->ctrl_2 & LLC_I_PF_BIT_MASK)) ? 1 : 0)
128 #define LLC_I_PF_IS_1(pdu) ((pdu->ctrl_2 & LLC_I_PF_BIT_MASK) ? 1 : 0)
130 /* S-PDU supervisory commands and responses */
133 #define LLC_S_PDU_CMD(pdu) (pdu->ctrl_1 & LLC_S_PDU_CMD_MASK)
134 #define LLC_S_PDU_RSP(pdu) (pdu->ctrl_1 & LLC_S_PDU_CMD_MASK)
144 #define LLC_S_PF_IS_0(pdu) ((!(pdu->ctrl_2 & LLC_S_PF_BIT_MASK)) ? 1 : 0)
145 #define LLC_S_PF_IS_1(pdu) ((pdu->ctrl_2 & LLC_S_PF_BIT_MASK) ? 1 : 0)
147 #define PDU_SUPV_GET_Nr(pdu) ((pdu->ctrl_2 & 0xFE) >> 1)
155 * info is pointer to FRMR info field structure; 'rej_ctrl' is byte pointer
156 * (if U-PDU) or word pointer to rejected PDU control field
159 info->rej_pdu_ctrl = ((*((u8 *) rej_ctrl) & \
165 * Info is pointer to FRMR info field structure; 'vs' is a byte containing
166 * send state variable value in low-order 7 bits (insure the lowest-order
169 #define FRMR_INFO_SET_Vs(info,vs) (info->curr_ssv = (((u8) vs) << 1))
170 #define FRMR_INFO_SET_Vr(info,vr) (info->curr_rsv = (((u8) vr) << 1))
173 * Info is pointer to FRMR info field structure; 'cr' is a byte containing
174 * the C/R bit value in the low-order bit
176 #define FRMR_INFO_SET_C_R_BIT(info, cr) (info->curr_rsv |= (((u8) cr) & 0x01))
180 * structure; 'ind' is a byte containing the bit value to set in the
181 * lowest-order bit)
184 (info->ind_bits = ((info->ind_bits & 0xFE) | (((u8) ind) & 0x01)))
187 (info->ind_bits = ( (info->ind_bits & 0xFD) | (((u8) ind) & 0x02)))
190 (info->ind_bits = ( (info->ind_bits & 0xFB) | (((u8) ind) & 0x04)))
193 (info->ind_bits = ( (info->ind_bits & 0xF7) | (((u8) ind) & 0x08)))
196 (info->ind_bits = ( (info->ind_bits & 0xEF) | (((u8) ind) & 0x10)))
198 /* Sequence-numbered PDU format (4 bytes in length) */
211 /* Un-numbered PDU format (3 bytes in length) */
224 * llc_pdu_header_init - initializes pdu header
251 pdu->dsap = dsap; in llc_pdu_header_init()
252 pdu->ssap = ssap; in llc_pdu_header_init()
253 pdu->ssap |= cr; in llc_pdu_header_init()
257 * llc_pdu_decode_sa - extracts, source address (MAC) of input frame
259 * @sa: pointer to source address (6 byte array).
265 memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN); in llc_pdu_decode_sa()
269 * llc_pdu_decode_da - extracts dest address of input frame
271 * @da: pointer to destination address (6 byte array).
277 memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN); in llc_pdu_decode_da()
281 * llc_pdu_decode_ssap - extracts source SAP of input frame
290 *ssap = llc_pdu_un_hdr(skb)->ssap & 0xFE; in llc_pdu_decode_ssap()
294 * llc_pdu_decode_dsap - extracts dest SAP of input frame
303 *dsap = llc_pdu_un_hdr(skb)->dsap & 0xFE; in llc_pdu_decode_dsap()
307 * llc_pdu_init_as_ui_cmd - sets LLC header as UI PDU
310 * This function sets third byte of LLC header as a UI PDU.
316 pdu->ctrl_1 = LLC_PDU_TYPE_U; in llc_pdu_init_as_ui_cmd()
317 pdu->ctrl_1 |= LLC_1_PDU_CMD_UI; in llc_pdu_init_as_ui_cmd()
321 * llc_pdu_init_as_test_cmd - sets PDU as TEST
330 pdu->ctrl_1 = LLC_PDU_TYPE_U; in llc_pdu_init_as_test_cmd()
331 pdu->ctrl_1 |= LLC_1_PDU_CMD_TEST; in llc_pdu_init_as_test_cmd()
332 pdu->ctrl_1 |= LLC_U_PF_BIT_MASK; in llc_pdu_init_as_test_cmd()
336 * llc_pdu_init_as_test_rsp - build TEST response PDU
347 pdu->ctrl_1 = LLC_PDU_TYPE_U; in llc_pdu_init_as_test_rsp()
348 pdu->ctrl_1 |= LLC_1_PDU_CMD_TEST; in llc_pdu_init_as_test_rsp()
349 pdu->ctrl_1 |= LLC_U_PF_BIT_MASK; in llc_pdu_init_as_test_rsp()
350 if (ev_skb->protocol == htons(ETH_P_802_2)) { in llc_pdu_init_as_test_rsp()
354 dsize = ntohs(eth_hdr(ev_skb)->h_proto) - 3; in llc_pdu_init_as_test_rsp()
363 u8 type; /* different if NULL/non-NULL LSAP */
368 * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID
382 pdu->ctrl_1 = LLC_PDU_TYPE_U; in llc_pdu_init_as_xid_cmd()
383 pdu->ctrl_1 |= LLC_1_PDU_CMD_XID; in llc_pdu_init_as_xid_cmd()
384 pdu->ctrl_1 |= LLC_U_PF_BIT_MASK; in llc_pdu_init_as_xid_cmd()
385 xid_info = (struct llc_xid_info *)(((u8 *)&pdu->ctrl_1) + 1); in llc_pdu_init_as_xid_cmd()
386 xid_info->fmt_id = LLC_XID_FMT_ID; /* 0x81 */ in llc_pdu_init_as_xid_cmd()
387 xid_info->type = svcs_supported; in llc_pdu_init_as_xid_cmd()
388 xid_info->rw = rx_window << 1; /* size of receive window */ in llc_pdu_init_as_xid_cmd()
396 * llc_pdu_init_as_xid_rsp - builds XID response PDU
409 pdu->ctrl_1 = LLC_PDU_TYPE_U; in llc_pdu_init_as_xid_rsp()
410 pdu->ctrl_1 |= LLC_1_PDU_CMD_XID; in llc_pdu_init_as_xid_rsp()
411 pdu->ctrl_1 |= LLC_U_PF_BIT_MASK; in llc_pdu_init_as_xid_rsp()
413 xid_info = (struct llc_xid_info *)(((u8 *)&pdu->ctrl_1) + 1); in llc_pdu_init_as_xid_rsp()
414 xid_info->fmt_id = LLC_XID_FMT_ID; in llc_pdu_init_as_xid_rsp()
415 xid_info->type = svcs_supported; in llc_pdu_init_as_xid_rsp()
416 xid_info->rw = rx_window << 1; in llc_pdu_init_as_xid_rsp()
422 u16 rej_pdu_ctrl; /* bits 1-8 if U-PDU */