15 #include <linux/if_ether.h>
18 #define LLC_PDU_LEN_I 4
19 #define LLC_PDU_LEN_S 4
20 #define LLC_PDU_LEN_U 3
22 #define LLC_GLOBAL_SAP 0xFF
23 #define LLC_NULL_SAP 0x00
24 #define LLC_MGMT_INDIV 0x02
25 #define LLC_MGMT_GRP 0x03
26 #define LLC_RDE_SAP 0xA6
29 #define LLC_ISO_RESERVED_SAP 0x02
30 #define LLC_SAP_GROUP_DSAP 0x01
31 #define LLC_SAP_RESP_SSAP 0x01
34 #define LLC_PDU_GROUP_DSAP_MASK 0x01
35 #define LLC_PDU_IS_GROUP_DSAP(pdu) \
36 ((pdu->dsap & LLC_PDU_GROUP_DSAP_MASK) ? 0 : 1)
37 #define LLC_PDU_IS_INDIV_DSAP(pdu) \
38 (!(pdu->dsap & LLC_PDU_GROUP_DSAP_MASK) ? 0 : 1)
41 #define LLC_PDU_CMD_RSP_MASK 0x01
44 #define LLC_PDU_IS_CMD(pdu) ((pdu->ssap & LLC_PDU_RSP) ? 0 : 1)
45 #define LLC_PDU_IS_RSP(pdu) ((pdu->ssap & LLC_PDU_RSP) ? 1 : 0)
48 #define LLC_PDU_TYPE_I_MASK 0x01
49 #define LLC_PDU_TYPE_S_MASK 0x03
50 #define LLC_PDU_TYPE_U_MASK 0x03
51 #define LLC_PDU_TYPE_MASK 0x03
53 #define LLC_PDU_TYPE_I 0
54 #define LLC_PDU_TYPE_S 1
55 #define LLC_PDU_TYPE_U 3
57 #define LLC_PDU_TYPE_IS_I(pdu) \
58 ((!(pdu->ctrl_1 & LLC_PDU_TYPE_I_MASK)) ? 1 : 0)
60 #define LLC_PDU_TYPE_IS_U(pdu) \
61 (((pdu->ctrl_1 & LLC_PDU_TYPE_U_MASK) == LLC_PDU_TYPE_U) ? 1 : 0)
63 #define LLC_PDU_TYPE_IS_S(pdu) \
64 (((pdu->ctrl_1 & LLC_PDU_TYPE_S_MASK) == LLC_PDU_TYPE_S) ? 1 : 0)
67 #define LLC_U_PF_BIT_MASK 0x10
68 #define LLC_U_PF_IS_1(pdu) ((pdu->ctrl_1 & LLC_U_PF_BIT_MASK) ? 1 : 0)
69 #define LLC_U_PF_IS_0(pdu) ((!(pdu->ctrl_1 & LLC_U_PF_BIT_MASK)) ? 1 : 0)
71 #define LLC_U_PDU_CMD_MASK 0xEC
72 #define LLC_U_PDU_CMD(pdu) (pdu->ctrl_1 & LLC_U_PDU_CMD_MASK)
73 #define LLC_U_PDU_RSP(pdu) (pdu->ctrl_1 & LLC_U_PDU_CMD_MASK)
75 #define LLC_1_PDU_CMD_UI 0x00
76 #define LLC_1_PDU_CMD_XID 0xAC
77 #define LLC_1_PDU_CMD_TEST 0xE0
79 #define LLC_2_PDU_CMD_SABME 0x6C
80 #define LLC_2_PDU_CMD_DISC 0x40
81 #define LLC_2_PDU_RSP_UA 0x60
82 #define LLC_2_PDU_RSP_DM 0x0C
83 #define LLC_2_PDU_RSP_FRMR 0x84
90 #define LLC_XID_FMT_ID 0x81
93 #define LLC_XID_CLASS_ZEROS_MASK 0xE0
94 #define LLC_XID_CLASS_MASK 0x1F
96 #define LLC_XID_NULL_CLASS_1 0x01
97 #define LLC_XID_NULL_CLASS_2 0x03
98 #define LLC_XID_NULL_CLASS_3 0x05
99 #define LLC_XID_NULL_CLASS_4 0x07
101 #define LLC_XID_NNULL_TYPE_1 0x01
102 #define LLC_XID_NNULL_TYPE_2 0x02
103 #define LLC_XID_NNULL_TYPE_3 0x04
104 #define LLC_XID_NNULL_TYPE_1_2 0x03
105 #define LLC_XID_NNULL_TYPE_1_3 0x05
106 #define LLC_XID_NNULL_TYPE_2_3 0x06
107 #define LLC_XID_NNULL_ALL 0x07
110 #define LLC_XID_RW_MASK 0xFE
112 #define LLC_XID_MIN_RW 0x02
116 #define LLC_2_SEQ_NBR_MODULO ((u8) 128)
119 #define LLC_I_GET_NS(pdu) (u8)((pdu->ctrl_1 & 0xFE) >> 1)
120 #define LLC_I_GET_NR(pdu) (u8)((pdu->ctrl_2 & 0xFE) >> 1)
122 #define LLC_I_PF_BIT_MASK 0x01
124 #define LLC_I_PF_IS_0(pdu) ((!(pdu->ctrl_2 & LLC_I_PF_BIT_MASK)) ? 1 : 0)
125 #define LLC_I_PF_IS_1(pdu) ((pdu->ctrl_2 & LLC_I_PF_BIT_MASK) ? 1 : 0)
129 #define LLC_S_PDU_CMD_MASK 0x0C
130 #define LLC_S_PDU_CMD(pdu) (pdu->ctrl_1 & LLC_S_PDU_CMD_MASK)
131 #define LLC_S_PDU_RSP(pdu) (pdu->ctrl_1 & LLC_S_PDU_CMD_MASK)
133 #define LLC_2_PDU_CMD_RR 0x00
134 #define LLC_2_PDU_RSP_RR 0x00
135 #define LLC_2_PDU_CMD_REJ 0x08
136 #define LLC_2_PDU_RSP_REJ 0x08
137 #define LLC_2_PDU_CMD_RNR 0x04
138 #define LLC_2_PDU_RSP_RNR 0x04
140 #define LLC_S_PF_BIT_MASK 0x01
141 #define LLC_S_PF_IS_0(pdu) ((!(pdu->ctrl_2 & LLC_S_PF_BIT_MASK)) ? 1 : 0)
142 #define LLC_S_PF_IS_1(pdu) ((pdu->ctrl_2 & LLC_S_PF_BIT_MASK) ? 1 : 0)
144 #define PDU_SUPV_GET_Nr(pdu) ((pdu->ctrl_2 & 0xFE) >> 1)
145 #define PDU_GET_NEXT_Vr(sn) (++sn & ~LLC_2_SEQ_NBR_MODULO)
149 #define FRMR_INFO_LENGTH 5
155 #define FRMR_INFO_SET_REJ_CNTRL(info,rej_ctrl) \
156 info->rej_pdu_ctrl = ((*((u8 *) rej_ctrl) & \
157 LLC_PDU_TYPE_U) != LLC_PDU_TYPE_U ? \
158 (u16)*((u16 *) rej_ctrl) : \
159 (((u16) *((u8 *) rej_ctrl)) & 0x00FF))
166 #define FRMR_INFO_SET_Vs(info,vs) (info->curr_ssv = (((u8) vs) << 1))
167 #define FRMR_INFO_SET_Vr(info,vr) (info->curr_rsv = (((u8) vr) << 1))
173 #define FRMR_INFO_SET_C_R_BIT(info, cr) (info->curr_rsv |= (((u8) cr) & 0x01))
180 #define FRMR_INFO_SET_INVALID_PDU_CTRL_IND(info, ind) \
181 (info->ind_bits = ((info->ind_bits & 0xFE) | (((u8) ind) & 0x01)))
183 #define FRMR_INFO_SET_INVALID_PDU_INFO_IND(info, ind) \
184 (info->ind_bits = ( (info->ind_bits & 0xFD) | (((u8) ind) & 0x02)))
186 #define FRMR_INFO_SET_PDU_INFO_2LONG_IND(info, ind) \
187 (info->ind_bits = ( (info->ind_bits & 0xFB) | (((u8) ind) & 0x04)))
189 #define FRMR_INFO_SET_PDU_INVALID_Nr_IND(info, ind) \
190 (info->ind_bits = ( (info->ind_bits & 0xF7) | (((u8) ind) & 0x08)))
192 #define FRMR_INFO_SET_PDU_INVALID_Ns_IND(info, ind) \
193 (info->ind_bits = ( (info->ind_bits & 0xEF) | (((u8) ind) & 0x10)))
205 return (
struct llc_pdu_sn *)skb_network_header(skb);
217 return (
struct llc_pdu_un *)skb_network_header(skb);
237 skb_reset_network_header(skb);
238 pdu = llc_pdu_un_hdr(skb);
264 static inline void llc_pdu_decode_da(
struct sk_buff *skb,
u8 *
da)
278 static inline void llc_pdu_decode_ssap(
struct sk_buff *skb,
u8 *
ssap)
280 *ssap = llc_pdu_un_hdr(skb)->ssap & 0xFE;
291 static inline void llc_pdu_decode_dsap(
struct sk_buff *skb,
u8 *
dsap)
293 *dsap = llc_pdu_un_hdr(skb)->dsap & 0xFE;
302 static inline void llc_pdu_init_as_ui_cmd(
struct sk_buff *skb)
316 static inline void llc_pdu_init_as_test_cmd(
struct sk_buff *skb)
332 static inline void llc_pdu_init_as_test_rsp(
struct sk_buff *skb,
341 struct llc_pdu_un *ev_pdu = llc_pdu_un_hdr(ev_skb);
345 memcpy(((
u8 *)pdu) + 3, ((
u8 *)ev_pdu) + 3, dsize);
364 static inline void llc_pdu_init_as_xid_cmd(
struct sk_buff *skb,
365 u8 svcs_supported,
u8 rx_window)
375 xid_info->
type = svcs_supported;
376 xid_info->
rw = rx_window << 1;
388 static inline void llc_pdu_init_as_xid_rsp(
struct sk_buff *skb,
389 u8 svcs_supported,
u8 rx_window)
400 xid_info->
type = svcs_supported;
401 xid_info->
rw = rx_window << 1;