• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2010-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This file contains the LLCP definitions
22  *
23  ******************************************************************************/
24 #ifndef LLCP_DEFS_H
25 #define LLCP_DEFS_H
26 
27 /*
28 ** LLCP PDU Descriptions
29 */
30 
31 #define LLCP_PDU_HEADER_SIZE    2       /* DSAP:PTYPE:SSAP excluding Sequence */
32 
33 #define LLCP_GET_DSAP(u16)  (((u16) & 0xFC00) >> 10)
34 #define LLCP_GET_PTYPE(u16) (((u16) & 0x03C0) >> 6)
35 #define LLCP_GET_SSAP(u16)  (((u16) & 0x003F))
36 
37 #define LLCP_GET_PDU_HEADER(dsap, ptype, ssap) (((UINT16) (dsap) << 10) | ((UINT16) (ptype) << 6) | (UINT16) (ssap))
38 
39 #define LLCP_GET_NS(u8) ((UINT8)(u8) >> 4)
40 #define LLCP_GET_NR(u8) ((UINT8)(u8) & 0x0F)
41 #define LLCP_GET_SEQUENCE(NS, NR) (((UINT8) (NS) << 4) | (UINT8) (NR))
42 #define LLCP_SEQUENCE_SIZE      1
43 
44 #define LLCP_PDU_SYMM_TYPE      0
45 #define LLCP_PDU_PAX_TYPE       1
46 #define LLCP_PDU_AGF_TYPE       2
47 #define LLCP_PDU_UI_TYPE        3
48 #define LLCP_PDU_CONNECT_TYPE   4
49 #define LLCP_PDU_DISC_TYPE      5
50 #define LLCP_PDU_CC_TYPE        6
51 #define LLCP_PDU_DM_TYPE        7
52 #define LLCP_PDU_FRMR_TYPE      8
53 #define LLCP_PDU_SNL_TYPE       9
54 #define LLCP_PDU_RESERVED_1010  10
55 #define LLCP_PDU_RESERVED_1011  11
56 #define LLCP_PDU_I_TYPE         12
57 #define LLCP_PDU_RR_TYPE        13
58 #define LLCP_PDU_RNR_TYPE       14
59 #define LLCP_PDU_RESERVED_1111  15
60 
61 #define LLCP_PDU_SYMM_SIZE      2
62 #define LLCP_PDU_DISC_SIZE      2
63 #define LLCP_PDU_DM_SIZE        3
64 #define LLCP_PDU_FRMR_SIZE      6
65 #define LLCP_PDU_RR_SIZE        3
66 #define LLCP_PDU_RNR_SIZE       3
67 #define LLCP_PDU_AGF_LEN_SIZE   2       /* 2 bytes of length in AGF PDU */
68 
69 #define LLCP_SAP_DM_REASON_RESP_DISC            0x00
70 #define LLCP_SAP_DM_REASON_NO_ACTIVE_CONNECTION 0x01
71 #define LLCP_SAP_DM_REASON_NO_SERVICE           0x02
72 #define LLCP_SAP_DM_REASON_APP_REJECTED         0x03
73 #define LLCP_SAP_DM_REASON_PERM_REJECT_THIS     0x10
74 #define LLCP_SAP_DM_REASON_PERM_REJECT_ANY      0x11
75 #define LLCP_SAP_DM_REASON_TEMP_REJECT_THIS     0x20
76 #define LLCP_SAP_DM_REASON_TEMP_REJECT_ANY      0x21
77 
78 #define LLCP_FRMR_W_ERROR_FLAG  0x08    /* Well-formedness Error */
79 #define LLCP_FRMR_I_ERROR_FLAG  0x04    /* Information Field Error */
80 #define LLCP_FRMR_R_ERROR_FLAG  0x02    /* Receive Sequence Error */
81 #define LLCP_FRMR_S_ERROR_FLAG  0x01    /* Send Sequence Error */
82 
83 #define LLCP_GET_FRMR_W_ERROR_FLAG(u8) (((UINT8) (u8) >> 7) & 0x01)
84 #define LLCP_GET_FRMR_I_ERROR_FLAG(u8) (((UINT8) (u8) >> 6) & 0x01)
85 #define LLCP_GET_FRMR_R_ERROR_FLAG(u8) (((UINT8) (u8) >> 5) & 0x01)
86 #define LLCP_GET_FRMR_S_ERROR_FLAG(u8) (((UINT8) (u8) >> 4) & 0x01)
87 #define LLCP_GET_FRMR_PTYPE(u8)        ((UINT8) (u8) & 0x0F)
88 #define LLCP_GET_FRMR_VS(u16)          (((UINT16) (u16) >> 12) & 0x000F)
89 #define LLCP_GET_FRMR_VR(u16)          (((UINT16) (u16) >>  8) & 0x000F)
90 #define LLCP_GET_FRMR_VSA(u16)         (((UINT16) (u16) >>  4) & 0x000F)
91 #define LLCP_GET_FRMR_VRA(u16)         (((UINT16) (u16) >>  0) & 0x000F)
92 
93 /*
94 ** LLCP Parameter Descriptions
95 */
96 
97 /* Version */
98 #define LLCP_VERSION_TYPE   0x01
99 #define LLCP_VERSION_LEN    0x01
100 #define LLCP_GET_MAJOR_VERSION(u8)     (((UINT8) (u8) >> 4) & 0x0F)
101 #define LLCP_GET_MINOR_VERSION(u8)     ((UINT8) (u8) & 0x0F)
102 #define LLCP_MIN_MAJOR_VERSION      0x01
103 #define LLCP_MIN_SNL_MAJOR_VERSION  0x01
104 #define LLCP_MIN_SNL_MINOR_VERSION  0x01
105 
106 /* LLCP Version 1.1 */
107 #define LLCP_VERSION_MAJOR  0x01
108 #define LLCP_VERSION_MINOR  0x01
109 #define LLCP_VERSION_VALUE  ((LLCP_VERSION_MAJOR << 4) | LLCP_VERSION_MINOR)
110 
111 /* Maximum Information Unit Extension */
112 #define LLCP_MIUX_TYPE      0x02
113 #define LLCP_MIUX_LEN       0x02
114 #define LLCP_MIUX_MASK      0x07FF  /* MIUX bit 10:0 */
115 #define LLCP_DEFAULT_MIU    128     /* if local LLC doesn't receive MIUX */
116 #define LLCP_MAX_MIU        2175    /* 2047 (11bits) + 128 */
117 
118 /* Well-Known Service */
119 #define LLCP_WKS_TYPE       0x03
120 #define LLCP_WKS_LEN        0x02
121 
122 /* Well-Known Service Bitmap */
123 #define LLCP_WKS_MASK_LM    0x0001  /* Link Management */
124 #define LLCP_WKS_MASK_SDP   0x0002  /* Service Discovery "urn:nfc:sn:sdp" */
125 #define LLCP_WKS_MASK_IP    0x0004  /* IP over LLCP Binding "urn:nfc:sn:ip" */
126 #define LLCP_WKS_MASK_OBEX  0x0008  /* OBEX over LLCP Binding "urn:nfc:sn:obex" */
127 #define LLCP_WKS_MASK_SNEP  0x0010  /* Simple NDEP Exchange Protocol "urn:nfc:sn:snep" */
128 
129 /* Well-Known Service Access Points */
130 #define LLCP_SAP_LM         0x00    /* Link Management */
131 #define LLCP_SAP_SDP        0x01    /* Service Discovery "urn:nfc:sn:sdp" */
132 #define LLCP_SAP_IP         0x02    /* IP over LLCP Binding "urn:nfc:sn:ip" */
133 #define LLCP_SAP_OBEX       0x03    /* OBEX over LLCP Binding "urn:nfc:sn:obex" */
134 #define LLCP_SAP_SNEP       0x04    /* Simple NDEP Exchange Protocol "urn:nfc:sn:snep" */
135 
136 /* Link Timeout, LTO */
137 #define LLCP_LTO_TYPE       0x04
138 #define LLCP_LTO_LEN        0x01
139 #define LLCP_DEFAULT_LTO_IN_MS    100     /* default 100ms. It should be sufficiently larget than RWT */
140 #define LLCP_LTO_UNIT       10      /* 10 ms */
141 #define LLCP_MAX_LTO_IN_MS  2550    /* 2550 ms; 8bits * 10ms */
142 
143 /* Receive Window Size, RW */
144 #define LLCP_RW_TYPE        0x05
145 #define LLCP_RW_LEN         0x01
146 #define LLCP_DEFAULT_RW     1       /* if local LLC doesn't receive RW */
147 
148 /* Service Name, SN */
149 #define LLCP_SN_TYPE        0x06
150 
151 /* Option, OPT */
152 #define LLCP_OPT_TYPE       0x07
153 #define LLCP_OPT_LEN        0x01
154 #define LLCP_GET_OPT_LSC(u8) ((UINT8) (u8) & 0x03)
155 
156 /* Service Discovery Request, SDREQ */
157 #define LLCP_SDREQ_TYPE     0x08
158 #define LLCP_SDREQ_MIN_LEN  0x03    /* type(1 byte), length(1 byte), TID(1 byte) */
159 
160 /* Service Discovery Response, SDRES */
161 #define LLCP_SDRES_TYPE     0x09
162 #define LLCP_SDRES_LEN      0x02
163 
164 /* Link Service Class */
165 #define LLCP_LSC_UNKNOWN    0x00
166 #define LLCP_LSC_1          0x01
167 #define LLCP_LSC_2          0x02
168 #define LLCP_LSC_3          0x03
169 
170 #define LLCP_MAGIC_NUMBER_LEN       3
171 #define LLCP_MAGIC_NUMBER_BYTE0     0x46
172 #define LLCP_MAGIC_NUMBER_BYTE1     0x66
173 #define LLCP_MAGIC_NUMBER_BYTE2     0x6D
174 
175 #define LLCP_SEQ_MODULO             16
176 
177 #define LLCP_NUM_SAPS               64
178 #define LLCP_LOWER_BOUND_WK_SAP     0x00
179 #define LLCP_UPPER_BOUND_WK_SAP     0x0F
180 #define LLCP_LOWER_BOUND_SDP_SAP    0x10
181 #define LLCP_UPPER_BOUND_SDP_SAP    0x1F
182 #define LLCP_LOWER_BOUND_LOCAL_SAP  0x20
183 #define LLCP_UPPER_BOUND_LOCAL_SAP  0x3F
184 
185 /* Max Payload */
186 #define LLCP_NCI_MAX_PAYL_SIZE      254 /* Maximum Payload size, Length Reduction LRi/LRt */
187 #define LLCP_NFC_DEP_HEADER_SIZE      3 /* Data exchange protocol header, 3 bytes */
188 #define LLCP_MAX_PAYLOAD_SIZE       (LLCP_NCI_MAX_PAYL_SIZE - LLCP_NFC_DEP_HEADER_SIZE)
189 
190 #define LLCP_MAX_GEN_BYTES          48
191 
192 #endif  /* LLCP_DEFS_H */
193