• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2010-2014 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) \
38   (((uint16_t)(dsap) << 10) | ((uint16_t)(ptype) << 6) | (uint16_t)(ssap))
39 
40 #define LLCP_GET_NS(u8) ((uint8_t)(u8) >> 4)
41 #define LLCP_GET_NR(u8) ((uint8_t)(u8)&0x0F)
42 #define LLCP_GET_SEQUENCE(NS, NR) (((uint8_t)(NS) << 4) | (uint8_t)(NR))
43 #define LLCP_SEQUENCE_SIZE 1
44 
45 #define LLCP_PDU_SYMM_TYPE 0
46 #define LLCP_PDU_PAX_TYPE 1
47 #define LLCP_PDU_AGF_TYPE 2
48 #define LLCP_PDU_UI_TYPE 3
49 #define LLCP_PDU_CONNECT_TYPE 4
50 #define LLCP_PDU_DISC_TYPE 5
51 #define LLCP_PDU_CC_TYPE 6
52 #define LLCP_PDU_DM_TYPE 7
53 #define LLCP_PDU_FRMR_TYPE 8
54 #define LLCP_PDU_SNL_TYPE 9
55 #define LLCP_PDU_I_TYPE 12
56 #define LLCP_PDU_RR_TYPE 13
57 #define LLCP_PDU_RNR_TYPE 14
58 
59 #define LLCP_PDU_SYMM_SIZE 2
60 #define LLCP_PDU_DISC_SIZE 2
61 #define LLCP_PDU_DM_SIZE 3
62 #define LLCP_PDU_FRMR_SIZE 6
63 #define LLCP_PDU_RR_SIZE 3
64 #define LLCP_PDU_RNR_SIZE 3
65 #define LLCP_PDU_AGF_LEN_SIZE 2 /* 2 bytes of length in AGF PDU */
66 
67 #define LLCP_SAP_DM_REASON_RESP_DISC 0x00
68 #define LLCP_SAP_DM_REASON_NO_ACTIVE_CONNECTION 0x01
69 #define LLCP_SAP_DM_REASON_NO_SERVICE 0x02
70 #define LLCP_SAP_DM_REASON_APP_REJECTED 0x03
71 #define LLCP_SAP_DM_REASON_PERM_REJECT_THIS 0x10
72 #define LLCP_SAP_DM_REASON_PERM_REJECT_ANY 0x11
73 #define LLCP_SAP_DM_REASON_TEMP_REJECT_THIS 0x20
74 #define LLCP_SAP_DM_REASON_TEMP_REJECT_ANY 0x21
75 
76 #define LLCP_FRMR_W_ERROR_FLAG 0x08 /* Well-formedness Error */
77 #define LLCP_FRMR_I_ERROR_FLAG 0x04 /* Information Field Error */
78 #define LLCP_FRMR_R_ERROR_FLAG 0x02 /* Receive Sequence Error */
79 #define LLCP_FRMR_S_ERROR_FLAG 0x01 /* Send Sequence Error */
80 
81 /*
82 ** LLCP Parameter Descriptions
83 */
84 
85 /* Version */
86 #define LLCP_VERSION_TYPE 0x01
87 #define LLCP_VERSION_LEN 0x01
88 #define LLCP_GET_MAJOR_VERSION(u8) (((uint8_t)(u8) >> 4) & 0x0F)
89 #define LLCP_GET_MINOR_VERSION(u8) ((uint8_t)(u8)&0x0F)
90 #define LLCP_MIN_MAJOR_VERSION 0x01
91 #define LLCP_MIN_SNL_MAJOR_VERSION 0x01
92 #define LLCP_MIN_SNL_MINOR_VERSION 0x01
93 
94 /* LLCP Version 1.2 */
95 #define LLCP_VERSION_MAJOR 0x01
96 #define LLCP_VERSION_MINOR 0x02
97 #define LLCP_VERSION_VALUE ((LLCP_VERSION_MAJOR << 4) | LLCP_VERSION_MINOR)
98 
99 /* Maximum Information Unit Extension */
100 #define LLCP_MIUX_TYPE 0x02
101 #define LLCP_MIUX_LEN 0x02
102 #define LLCP_MIUX_MASK 0x07FF /* MIUX bit 10:0 */
103 #define LLCP_DEFAULT_MIU 128  /* if local LLC doesn't receive MIUX */
104 #define LLCP_MAX_MIU 2175     /* 2047 (11bits) + 128 */
105 
106 /* Well-Known Service */
107 #define LLCP_WKS_TYPE 0x03
108 #define LLCP_WKS_LEN 0x02
109 
110 /* Well-Known Service Bitmap */
111 #define LLCP_WKS_MASK_LM 0x0001  /* Link Management */
112 
113 /* Well-Known Service Access Points */
114 #define LLCP_SAP_LM 0x00  /* Link Management */
115 #define LLCP_SAP_SDP 0x01 /* Service Discovery "urn:nfc:sn:sdp" */
116 
117 /* Link Timeout, LTO */
118 #define LLCP_LTO_TYPE 0x04
119 #define LLCP_LTO_LEN 0x01
120 /* default 100ms. It should be sufficiently larget than RWT */
121 #define LLCP_DEFAULT_LTO_IN_MS 100
122 #define LLCP_LTO_UNIT 10        /* 10 ms */
123 #define LLCP_MAX_LTO_IN_MS 2550 /* 2550 ms; 8bits * 10ms */
124 
125 /* Receive Window Size, RW */
126 #define LLCP_RW_TYPE 0x05
127 #define LLCP_RW_LEN 0x01
128 #define LLCP_DEFAULT_RW 1 /* if local LLC doesn't receive RW */
129 
130 /* Service Name, SN */
131 #define LLCP_SN_TYPE 0x06
132 
133 /* Option, OPT */
134 #define LLCP_OPT_TYPE 0x07
135 #define LLCP_OPT_LEN 0x01
136 
137 /* Service Discovery Request, SDREQ */
138 #define LLCP_SDREQ_TYPE 0x08
139 /* type(1 byte), length(1 byte), TID(1 byte) */
140 #define LLCP_SDREQ_MIN_LEN 0x03
141 
142 /* Service Discovery Response, SDRES */
143 #define LLCP_SDRES_TYPE 0x09
144 #define LLCP_SDRES_LEN 0x02
145 
146 /* Link Service Class */
147 #define LLCP_LSC_UNKNOWN 0x00
148 #define LLCP_LSC_1 0x01
149 #define LLCP_LSC_2 0x02
150 #define LLCP_LSC_3 0x03
151 
152 #define LLCP_MAGIC_NUMBER_LEN 3
153 #define LLCP_MAGIC_NUMBER_BYTE0 0x46
154 #define LLCP_MAGIC_NUMBER_BYTE1 0x66
155 #define LLCP_MAGIC_NUMBER_BYTE2 0x6D
156 
157 #define LLCP_SEQ_MODULO 16
158 
159 #define LLCP_NUM_SAPS 64
160 #define LLCP_UPPER_BOUND_WK_SAP 0x0F
161 #define LLCP_LOWER_BOUND_SDP_SAP 0x10
162 #define LLCP_UPPER_BOUND_SDP_SAP 0x1F
163 #define LLCP_LOWER_BOUND_LOCAL_SAP 0x20
164 #define LLCP_UPPER_BOUND_LOCAL_SAP 0x3F
165 
166 /* Max Payload */
167 /* Maximum Payload size, Length Reduction LRi/LRt */
168 #define LLCP_NCI_MAX_PAYL_SIZE 254
169 
170 #define LLCP_MAX_GEN_BYTES 48
171 
172 #endif /* LLCP_DEFS_H */
173