bt.h 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183
  1. /*
  2. * QEMU Bluetooth HCI helpers.
  3. *
  4. * Copyright (C) 2007 OpenMoko, Inc.
  5. * Written by Andrzej Zaborowski <andrew@openedhand.com>
  6. *
  7. * Useful definitions taken from BlueZ project's headers.
  8. * Copyright (C) 2000-2001 Qualcomm Incorporated
  9. * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
  10. * Copyright (C) 2002-2006 Marcel Holtmann <marcel@holtmann.org>
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  24. */
  25. /* BD Address */
  26. typedef struct {
  27. uint8_t b[6];
  28. } __attribute__((packed)) bdaddr_t;
  29. #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
  30. #define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
  31. #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
  32. /* Copy, swap, convert BD Address */
  33. static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
  34. {
  35. return memcmp(ba1, ba2, sizeof(bdaddr_t));
  36. }
  37. static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
  38. {
  39. memcpy(dst, src, sizeof(bdaddr_t));
  40. }
  41. #define BAINIT(orig) { .b = { \
  42. (orig)->b[0], (orig)->b[1], (orig)->b[2], \
  43. (orig)->b[3], (orig)->b[4], (orig)->b[5], \
  44. }, }
  45. /* The twisted structures of a bluetooth environment */
  46. struct bt_device_s;
  47. struct bt_scatternet_s;
  48. struct bt_piconet_s;
  49. struct bt_link_s;
  50. struct bt_scatternet_s {
  51. struct bt_device_s *slave;
  52. };
  53. struct bt_link_s {
  54. struct bt_device_s *slave, *host;
  55. uint16_t handle; /* Master (host) side handle */
  56. uint16_t acl_interval;
  57. enum {
  58. acl_active,
  59. acl_hold,
  60. acl_sniff,
  61. acl_parked,
  62. } acl_mode;
  63. };
  64. struct bt_device_s {
  65. int lt_addr;
  66. bdaddr_t bd_addr;
  67. int mtu;
  68. int setup;
  69. struct bt_scatternet_s *net;
  70. uint8_t key[16];
  71. int key_present;
  72. uint8_t class[3];
  73. uint8_t reject_reason;
  74. uint64_t lmp_caps;
  75. const char *lmp_name;
  76. void (*lmp_connection_request)(struct bt_link_s *link);
  77. void (*lmp_connection_complete)(struct bt_link_s *link);
  78. void (*lmp_disconnect_master)(struct bt_link_s *link);
  79. void (*lmp_disconnect_slave)(struct bt_link_s *link);
  80. void (*lmp_acl_data)(struct bt_link_s *link, const uint8_t *data,
  81. int start, int len);
  82. void (*lmp_acl_resp)(struct bt_link_s *link, const uint8_t *data,
  83. int start, int len);
  84. void (*lmp_mode_change)(struct bt_link_s *link);
  85. void (*handle_destroy)(struct bt_device_s *device);
  86. struct bt_device_s *next; /* Next in the piconet/scatternet */
  87. int inquiry_scan;
  88. int page_scan;
  89. uint16_t clkoff; /* Note: Always little-endian */
  90. };
  91. /* bt.c */
  92. void bt_device_init(struct bt_device_s *dev, struct bt_scatternet_s *net);
  93. void bt_device_done(struct bt_device_s *dev);
  94. /* bt-hci.c */
  95. struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net);
  96. /* bt-vhci.c */
  97. void bt_vhci_init(struct HCIInfo *info);
  98. /* bt-hci-csr.c */
  99. enum {
  100. csrhci_pin_reset,
  101. csrhci_pin_wakeup,
  102. __csrhci_pins,
  103. };
  104. qemu_irq *csrhci_pins_get(CharDriverState *chr);
  105. CharDriverState *uart_hci_init(qemu_irq wakeup);
  106. /* bt-l2cap.c */
  107. struct bt_l2cap_device_s;
  108. struct bt_l2cap_conn_params_s;
  109. struct bt_l2cap_psm_s;
  110. void bt_l2cap_device_init(struct bt_l2cap_device_s *dev,
  111. struct bt_scatternet_s *net);
  112. void bt_l2cap_device_done(struct bt_l2cap_device_s *dev);
  113. void bt_l2cap_psm_register(struct bt_l2cap_device_s *dev, int psm,
  114. int min_mtu, int (*new_channel)(struct bt_l2cap_device_s *dev,
  115. struct bt_l2cap_conn_params_s *params));
  116. struct bt_l2cap_device_s {
  117. struct bt_device_s device;
  118. struct bt_l2cap_psm_s *first_psm;
  119. };
  120. struct bt_l2cap_conn_params_s {
  121. /* Input */
  122. uint8_t *(*sdu_out)(struct bt_l2cap_conn_params_s *chan, int len);
  123. void (*sdu_submit)(struct bt_l2cap_conn_params_s *chan);
  124. int remote_mtu;
  125. /* Output */
  126. void *opaque;
  127. void (*sdu_in)(void *opaque, const uint8_t *data, int len);
  128. void (*close)(void *opaque);
  129. };
  130. enum bt_l2cap_psm_predef {
  131. BT_PSM_SDP = 0x0001,
  132. BT_PSM_RFCOMM = 0x0003,
  133. BT_PSM_TELEPHONY = 0x0005,
  134. BT_PSM_TCS = 0x0007,
  135. BT_PSM_BNEP = 0x000f,
  136. BT_PSM_HID_CTRL = 0x0011,
  137. BT_PSM_HID_INTR = 0x0013,
  138. BT_PSM_UPNP = 0x0015,
  139. BT_PSM_AVCTP = 0x0017,
  140. BT_PSM_AVDTP = 0x0019,
  141. };
  142. /* bt-sdp.c */
  143. void bt_l2cap_sdp_init(struct bt_l2cap_device_s *dev);
  144. /* bt-hid.c */
  145. struct bt_device_s *bt_mouse_init(struct bt_scatternet_s *net);
  146. struct bt_device_s *bt_tablet_init(struct bt_scatternet_s *net);
  147. struct bt_device_s *bt_keyboard_init(struct bt_scatternet_s *net);
  148. /* Link Management Protocol layer defines */
  149. #define LLID_ACLU_CONT 0x1
  150. #define LLID_ACLU_START 0x2
  151. #define LLID_ACLC 0x3
  152. enum lmp_pdu_type {
  153. LMP_NAME_REQ = 0x0001,
  154. LMP_NAME_RES = 0x0002,
  155. LMP_ACCEPTED = 0x0003,
  156. LMP_NOT_ACCEPTED = 0x0004,
  157. LMP_CLKOFFSET_REQ = 0x0005,
  158. LMP_CLKOFFSET_RES = 0x0006,
  159. LMP_DETACH = 0x0007,
  160. LMP_IN_RAND = 0x0008,
  161. LMP_COMB_KEY = 0x0009,
  162. LMP_UNIT_KEY = 0x000a,
  163. LMP_AU_RAND = 0x000b,
  164. LMP_SRES = 0x000c,
  165. LMP_TEMP_RAND = 0x000d,
  166. LMP_TEMP_KEY = 0x000e,
  167. LMP_CRYPT_MODE_REQ = 0x000f,
  168. LMP_CRYPT_KEY_SIZE_REQ = 0x0010,
  169. LMP_START_ENCRYPT_REQ = 0x0011,
  170. LMP_STOP_ENCRYPT_REQ = 0x0012,
  171. LMP_SWITCH_REQ = 0x0013,
  172. LMP_HOLD = 0x0014,
  173. LMP_HOLD_REQ = 0x0015,
  174. LMP_SNIFF_REQ = 0x0017,
  175. LMP_UNSNIFF_REQ = 0x0018,
  176. LMP_LMP_PARK_REQ = 0x0019,
  177. LMP_SET_BCAST_SCAN_WND = 0x001b,
  178. LMP_MODIFY_BEACON = 0x001c,
  179. LMP_UNPARK_BD_ADDR_REQ = 0x001d,
  180. LMP_UNPARK_PM_ADDR_REQ = 0x001e,
  181. LMP_INCR_POWER_REQ = 0x001f,
  182. LMP_DECR_POWER_REQ = 0x0020,
  183. LMP_MAX_POWER = 0x0021,
  184. LMP_MIN_POWER = 0x0022,
  185. LMP_AUTO_RATE = 0x0023,
  186. LMP_PREFERRED_RATE = 0x0024,
  187. LMP_VERSION_REQ = 0x0025,
  188. LMP_VERSION_RES = 0x0026,
  189. LMP_FEATURES_REQ = 0x0027,
  190. LMP_FEATURES_RES = 0x0028,
  191. LMP_QUALITY_OF_SERVICE = 0x0029,
  192. LMP_QOS_REQ = 0x002a,
  193. LMP_RM_SCO_LINK_REQ = 0x002b,
  194. LMP_SCO_LINK_REQ = 0x002c,
  195. LMP_MAX_SLOT = 0x002d,
  196. LMP_MAX_SLOT_REQ = 0x002e,
  197. LMP_TIMING_ACCURACY_REQ = 0x002f,
  198. LMP_TIMING_ACCURACY_RES = 0x0030,
  199. LMP_SETUP_COMPLETE = 0x0031,
  200. LMP_USE_SEMIPERM_KEY = 0x0032,
  201. LMP_HOST_CONNECTION_REQ = 0x0033,
  202. LMP_SLOT_OFFSET = 0x0034,
  203. LMP_PAGE_MODE_REQ = 0x0035,
  204. LMP_PAGE_SCAN_MODE_REQ = 0x0036,
  205. LMP_SUPERVISION_TIMEOUT = 0x0037,
  206. LMP_TEST_ACTIVATE = 0x0038,
  207. LMP_TEST_CONTROL = 0x0039,
  208. LMP_CRYPT_KEY_MASK_REQ = 0x003a,
  209. LMP_CRYPT_KEY_MASK_RES = 0x003b,
  210. LMP_SET_AFH = 0x003c,
  211. LMP_ACCEPTED_EXT = 0x7f01,
  212. LMP_NOT_ACCEPTED_EXT = 0x7f02,
  213. LMP_FEATURES_REQ_EXT = 0x7f03,
  214. LMP_FEATURES_RES_EXT = 0x7f04,
  215. LMP_PACKET_TYPE_TBL_REQ = 0x7f0b,
  216. LMP_ESCO_LINK_REQ = 0x7f0c,
  217. LMP_RM_ESCO_LINK_REQ = 0x7f0d,
  218. LMP_CHANNEL_CLASS_REQ = 0x7f10,
  219. LMP_CHANNEL_CLASS = 0x7f11,
  220. };
  221. /* Host Controller Interface layer defines */
  222. enum hci_packet_type {
  223. HCI_COMMAND_PKT = 0x01,
  224. HCI_ACLDATA_PKT = 0x02,
  225. HCI_SCODATA_PKT = 0x03,
  226. HCI_EVENT_PKT = 0x04,
  227. HCI_VENDOR_PKT = 0xff,
  228. };
  229. enum bt_packet_type {
  230. HCI_2DH1 = 1 << 1,
  231. HCI_3DH1 = 1 << 2,
  232. HCI_DM1 = 1 << 3,
  233. HCI_DH1 = 1 << 4,
  234. HCI_2DH3 = 1 << 8,
  235. HCI_3DH3 = 1 << 9,
  236. HCI_DM3 = 1 << 10,
  237. HCI_DH3 = 1 << 11,
  238. HCI_2DH5 = 1 << 12,
  239. HCI_3DH5 = 1 << 13,
  240. HCI_DM5 = 1 << 14,
  241. HCI_DH5 = 1 << 15,
  242. };
  243. enum sco_packet_type {
  244. HCI_HV1 = 1 << 5,
  245. HCI_HV2 = 1 << 6,
  246. HCI_HV3 = 1 << 7,
  247. };
  248. enum ev_packet_type {
  249. HCI_EV3 = 1 << 3,
  250. HCI_EV4 = 1 << 4,
  251. HCI_EV5 = 1 << 5,
  252. HCI_2EV3 = 1 << 6,
  253. HCI_3EV3 = 1 << 7,
  254. HCI_2EV5 = 1 << 8,
  255. HCI_3EV5 = 1 << 9,
  256. };
  257. enum hci_error_code {
  258. HCI_SUCCESS = 0x00,
  259. HCI_UNKNOWN_COMMAND = 0x01,
  260. HCI_NO_CONNECTION = 0x02,
  261. HCI_HARDWARE_FAILURE = 0x03,
  262. HCI_PAGE_TIMEOUT = 0x04,
  263. HCI_AUTHENTICATION_FAILURE = 0x05,
  264. HCI_PIN_OR_KEY_MISSING = 0x06,
  265. HCI_MEMORY_FULL = 0x07,
  266. HCI_CONNECTION_TIMEOUT = 0x08,
  267. HCI_MAX_NUMBER_OF_CONNECTIONS = 0x09,
  268. HCI_MAX_NUMBER_OF_SCO_CONNECTIONS = 0x0a,
  269. HCI_ACL_CONNECTION_EXISTS = 0x0b,
  270. HCI_COMMAND_DISALLOWED = 0x0c,
  271. HCI_REJECTED_LIMITED_RESOURCES = 0x0d,
  272. HCI_REJECTED_SECURITY = 0x0e,
  273. HCI_REJECTED_PERSONAL = 0x0f,
  274. HCI_HOST_TIMEOUT = 0x10,
  275. HCI_UNSUPPORTED_FEATURE = 0x11,
  276. HCI_INVALID_PARAMETERS = 0x12,
  277. HCI_OE_USER_ENDED_CONNECTION = 0x13,
  278. HCI_OE_LOW_RESOURCES = 0x14,
  279. HCI_OE_POWER_OFF = 0x15,
  280. HCI_CONNECTION_TERMINATED = 0x16,
  281. HCI_REPEATED_ATTEMPTS = 0x17,
  282. HCI_PAIRING_NOT_ALLOWED = 0x18,
  283. HCI_UNKNOWN_LMP_PDU = 0x19,
  284. HCI_UNSUPPORTED_REMOTE_FEATURE = 0x1a,
  285. HCI_SCO_OFFSET_REJECTED = 0x1b,
  286. HCI_SCO_INTERVAL_REJECTED = 0x1c,
  287. HCI_AIR_MODE_REJECTED = 0x1d,
  288. HCI_INVALID_LMP_PARAMETERS = 0x1e,
  289. HCI_UNSPECIFIED_ERROR = 0x1f,
  290. HCI_UNSUPPORTED_LMP_PARAMETER_VALUE = 0x20,
  291. HCI_ROLE_CHANGE_NOT_ALLOWED = 0x21,
  292. HCI_LMP_RESPONSE_TIMEOUT = 0x22,
  293. HCI_LMP_ERROR_TRANSACTION_COLLISION = 0x23,
  294. HCI_LMP_PDU_NOT_ALLOWED = 0x24,
  295. HCI_ENCRYPTION_MODE_NOT_ACCEPTED = 0x25,
  296. HCI_UNIT_LINK_KEY_USED = 0x26,
  297. HCI_QOS_NOT_SUPPORTED = 0x27,
  298. HCI_INSTANT_PASSED = 0x28,
  299. HCI_PAIRING_NOT_SUPPORTED = 0x29,
  300. HCI_TRANSACTION_COLLISION = 0x2a,
  301. HCI_QOS_UNACCEPTABLE_PARAMETER = 0x2c,
  302. HCI_QOS_REJECTED = 0x2d,
  303. HCI_CLASSIFICATION_NOT_SUPPORTED = 0x2e,
  304. HCI_INSUFFICIENT_SECURITY = 0x2f,
  305. HCI_PARAMETER_OUT_OF_RANGE = 0x30,
  306. HCI_ROLE_SWITCH_PENDING = 0x32,
  307. HCI_SLOT_VIOLATION = 0x34,
  308. HCI_ROLE_SWITCH_FAILED = 0x35,
  309. };
  310. enum acl_flag_bits {
  311. ACL_CONT = 1 << 0,
  312. ACL_START = 1 << 1,
  313. ACL_ACTIVE_BCAST = 1 << 2,
  314. ACL_PICO_BCAST = 1 << 3,
  315. };
  316. enum baseband_link_type {
  317. SCO_LINK = 0x00,
  318. ACL_LINK = 0x01,
  319. };
  320. enum lmp_feature_bits0 {
  321. LMP_3SLOT = 1 << 0,
  322. LMP_5SLOT = 1 << 1,
  323. LMP_ENCRYPT = 1 << 2,
  324. LMP_SOFFSET = 1 << 3,
  325. LMP_TACCURACY = 1 << 4,
  326. LMP_RSWITCH = 1 << 5,
  327. LMP_HOLD_MODE = 1 << 6,
  328. LMP_SNIFF_MODE = 1 << 7,
  329. };
  330. enum lmp_feature_bits1 {
  331. LMP_PARK = 1 << 0,
  332. LMP_RSSI = 1 << 1,
  333. LMP_QUALITY = 1 << 2,
  334. LMP_SCO = 1 << 3,
  335. LMP_HV2 = 1 << 4,
  336. LMP_HV3 = 1 << 5,
  337. LMP_ULAW = 1 << 6,
  338. LMP_ALAW = 1 << 7,
  339. };
  340. enum lmp_feature_bits2 {
  341. LMP_CVSD = 1 << 0,
  342. LMP_PSCHEME = 1 << 1,
  343. LMP_PCONTROL = 1 << 2,
  344. LMP_TRSP_SCO = 1 << 3,
  345. LMP_BCAST_ENC = 1 << 7,
  346. };
  347. enum lmp_feature_bits3 {
  348. LMP_EDR_ACL_2M = 1 << 1,
  349. LMP_EDR_ACL_3M = 1 << 2,
  350. LMP_ENH_ISCAN = 1 << 3,
  351. LMP_ILACE_ISCAN = 1 << 4,
  352. LMP_ILACE_PSCAN = 1 << 5,
  353. LMP_RSSI_INQ = 1 << 6,
  354. LMP_ESCO = 1 << 7,
  355. };
  356. enum lmp_feature_bits4 {
  357. LMP_EV4 = 1 << 0,
  358. LMP_EV5 = 1 << 1,
  359. LMP_AFH_CAP_SLV = 1 << 3,
  360. LMP_AFH_CLS_SLV = 1 << 4,
  361. LMP_EDR_3SLOT = 1 << 7,
  362. };
  363. enum lmp_feature_bits5 {
  364. LMP_EDR_5SLOT = 1 << 0,
  365. LMP_SNIFF_SUBR = 1 << 1,
  366. LMP_AFH_CAP_MST = 1 << 3,
  367. LMP_AFH_CLS_MST = 1 << 4,
  368. LMP_EDR_ESCO_2M = 1 << 5,
  369. LMP_EDR_ESCO_3M = 1 << 6,
  370. LMP_EDR_3S_ESCO = 1 << 7,
  371. };
  372. enum lmp_feature_bits6 {
  373. LMP_EXT_INQ = 1 << 0,
  374. };
  375. enum lmp_feature_bits7 {
  376. LMP_EXT_FEAT = 1 << 7,
  377. };
  378. enum hci_link_policy {
  379. HCI_LP_RSWITCH = 1 << 0,
  380. HCI_LP_HOLD = 1 << 1,
  381. HCI_LP_SNIFF = 1 << 2,
  382. HCI_LP_PARK = 1 << 3,
  383. };
  384. enum hci_link_mode {
  385. HCI_LM_ACCEPT = 1 << 15,
  386. HCI_LM_MASTER = 1 << 0,
  387. HCI_LM_AUTH = 1 << 1,
  388. HCI_LM_ENCRYPT = 1 << 2,
  389. HCI_LM_TRUSTED = 1 << 3,
  390. HCI_LM_RELIABLE = 1 << 4,
  391. HCI_LM_SECURE = 1 << 5,
  392. };
  393. /* HCI Commands */
  394. /* Link Control */
  395. #define OGF_LINK_CTL 0x01
  396. #define OCF_INQUIRY 0x0001
  397. typedef struct {
  398. uint8_t lap[3];
  399. uint8_t length; /* 1.28s units */
  400. uint8_t num_rsp;
  401. } __attribute__ ((packed)) inquiry_cp;
  402. #define INQUIRY_CP_SIZE 5
  403. typedef struct {
  404. uint8_t status;
  405. bdaddr_t bdaddr;
  406. } __attribute__ ((packed)) status_bdaddr_rp;
  407. #define STATUS_BDADDR_RP_SIZE 7
  408. #define OCF_INQUIRY_CANCEL 0x0002
  409. #define OCF_PERIODIC_INQUIRY 0x0003
  410. typedef struct {
  411. uint16_t max_period; /* 1.28s units */
  412. uint16_t min_period; /* 1.28s units */
  413. uint8_t lap[3];
  414. uint8_t length; /* 1.28s units */
  415. uint8_t num_rsp;
  416. } __attribute__ ((packed)) periodic_inquiry_cp;
  417. #define PERIODIC_INQUIRY_CP_SIZE 9
  418. #define OCF_EXIT_PERIODIC_INQUIRY 0x0004
  419. #define OCF_CREATE_CONN 0x0005
  420. typedef struct {
  421. bdaddr_t bdaddr;
  422. uint16_t pkt_type;
  423. uint8_t pscan_rep_mode;
  424. uint8_t pscan_mode;
  425. uint16_t clock_offset;
  426. uint8_t role_switch;
  427. } __attribute__ ((packed)) create_conn_cp;
  428. #define CREATE_CONN_CP_SIZE 13
  429. #define OCF_DISCONNECT 0x0006
  430. typedef struct {
  431. uint16_t handle;
  432. uint8_t reason;
  433. } __attribute__ ((packed)) disconnect_cp;
  434. #define DISCONNECT_CP_SIZE 3
  435. #define OCF_ADD_SCO 0x0007
  436. typedef struct {
  437. uint16_t handle;
  438. uint16_t pkt_type;
  439. } __attribute__ ((packed)) add_sco_cp;
  440. #define ADD_SCO_CP_SIZE 4
  441. #define OCF_CREATE_CONN_CANCEL 0x0008
  442. typedef struct {
  443. uint8_t status;
  444. bdaddr_t bdaddr;
  445. } __attribute__ ((packed)) create_conn_cancel_cp;
  446. #define CREATE_CONN_CANCEL_CP_SIZE 6
  447. typedef struct {
  448. uint8_t status;
  449. bdaddr_t bdaddr;
  450. } __attribute__ ((packed)) create_conn_cancel_rp;
  451. #define CREATE_CONN_CANCEL_RP_SIZE 7
  452. #define OCF_ACCEPT_CONN_REQ 0x0009
  453. typedef struct {
  454. bdaddr_t bdaddr;
  455. uint8_t role;
  456. } __attribute__ ((packed)) accept_conn_req_cp;
  457. #define ACCEPT_CONN_REQ_CP_SIZE 7
  458. #define OCF_REJECT_CONN_REQ 0x000A
  459. typedef struct {
  460. bdaddr_t bdaddr;
  461. uint8_t reason;
  462. } __attribute__ ((packed)) reject_conn_req_cp;
  463. #define REJECT_CONN_REQ_CP_SIZE 7
  464. #define OCF_LINK_KEY_REPLY 0x000B
  465. typedef struct {
  466. bdaddr_t bdaddr;
  467. uint8_t link_key[16];
  468. } __attribute__ ((packed)) link_key_reply_cp;
  469. #define LINK_KEY_REPLY_CP_SIZE 22
  470. #define OCF_LINK_KEY_NEG_REPLY 0x000C
  471. #define OCF_PIN_CODE_REPLY 0x000D
  472. typedef struct {
  473. bdaddr_t bdaddr;
  474. uint8_t pin_len;
  475. uint8_t pin_code[16];
  476. } __attribute__ ((packed)) pin_code_reply_cp;
  477. #define PIN_CODE_REPLY_CP_SIZE 23
  478. #define OCF_PIN_CODE_NEG_REPLY 0x000E
  479. #define OCF_SET_CONN_PTYPE 0x000F
  480. typedef struct {
  481. uint16_t handle;
  482. uint16_t pkt_type;
  483. } __attribute__ ((packed)) set_conn_ptype_cp;
  484. #define SET_CONN_PTYPE_CP_SIZE 4
  485. #define OCF_AUTH_REQUESTED 0x0011
  486. typedef struct {
  487. uint16_t handle;
  488. } __attribute__ ((packed)) auth_requested_cp;
  489. #define AUTH_REQUESTED_CP_SIZE 2
  490. #define OCF_SET_CONN_ENCRYPT 0x0013
  491. typedef struct {
  492. uint16_t handle;
  493. uint8_t encrypt;
  494. } __attribute__ ((packed)) set_conn_encrypt_cp;
  495. #define SET_CONN_ENCRYPT_CP_SIZE 3
  496. #define OCF_CHANGE_CONN_LINK_KEY 0x0015
  497. typedef struct {
  498. uint16_t handle;
  499. } __attribute__ ((packed)) change_conn_link_key_cp;
  500. #define CHANGE_CONN_LINK_KEY_CP_SIZE 2
  501. #define OCF_MASTER_LINK_KEY 0x0017
  502. typedef struct {
  503. uint8_t key_flag;
  504. } __attribute__ ((packed)) master_link_key_cp;
  505. #define MASTER_LINK_KEY_CP_SIZE 1
  506. #define OCF_REMOTE_NAME_REQ 0x0019
  507. typedef struct {
  508. bdaddr_t bdaddr;
  509. uint8_t pscan_rep_mode;
  510. uint8_t pscan_mode;
  511. uint16_t clock_offset;
  512. } __attribute__ ((packed)) remote_name_req_cp;
  513. #define REMOTE_NAME_REQ_CP_SIZE 10
  514. #define OCF_REMOTE_NAME_REQ_CANCEL 0x001A
  515. typedef struct {
  516. bdaddr_t bdaddr;
  517. } __attribute__ ((packed)) remote_name_req_cancel_cp;
  518. #define REMOTE_NAME_REQ_CANCEL_CP_SIZE 6
  519. typedef struct {
  520. uint8_t status;
  521. bdaddr_t bdaddr;
  522. } __attribute__ ((packed)) remote_name_req_cancel_rp;
  523. #define REMOTE_NAME_REQ_CANCEL_RP_SIZE 7
  524. #define OCF_READ_REMOTE_FEATURES 0x001B
  525. typedef struct {
  526. uint16_t handle;
  527. } __attribute__ ((packed)) read_remote_features_cp;
  528. #define READ_REMOTE_FEATURES_CP_SIZE 2
  529. #define OCF_READ_REMOTE_EXT_FEATURES 0x001C
  530. typedef struct {
  531. uint16_t handle;
  532. uint8_t page_num;
  533. } __attribute__ ((packed)) read_remote_ext_features_cp;
  534. #define READ_REMOTE_EXT_FEATURES_CP_SIZE 3
  535. #define OCF_READ_REMOTE_VERSION 0x001D
  536. typedef struct {
  537. uint16_t handle;
  538. } __attribute__ ((packed)) read_remote_version_cp;
  539. #define READ_REMOTE_VERSION_CP_SIZE 2
  540. #define OCF_READ_CLOCK_OFFSET 0x001F
  541. typedef struct {
  542. uint16_t handle;
  543. } __attribute__ ((packed)) read_clock_offset_cp;
  544. #define READ_CLOCK_OFFSET_CP_SIZE 2
  545. #define OCF_READ_LMP_HANDLE 0x0020
  546. typedef struct {
  547. uint16_t handle;
  548. } __attribute__ ((packed)) read_lmp_handle_cp;
  549. #define READ_LMP_HANDLE_CP_SIZE 2
  550. typedef struct {
  551. uint8_t status;
  552. uint16_t handle;
  553. uint8_t lmp_handle;
  554. uint32_t reserved;
  555. } __attribute__ ((packed)) read_lmp_handle_rp;
  556. #define READ_LMP_HANDLE_RP_SIZE 8
  557. #define OCF_SETUP_SYNC_CONN 0x0028
  558. typedef struct {
  559. uint16_t handle;
  560. uint32_t tx_bandwith;
  561. uint32_t rx_bandwith;
  562. uint16_t max_latency;
  563. uint16_t voice_setting;
  564. uint8_t retrans_effort;
  565. uint16_t pkt_type;
  566. } __attribute__ ((packed)) setup_sync_conn_cp;
  567. #define SETUP_SYNC_CONN_CP_SIZE 17
  568. #define OCF_ACCEPT_SYNC_CONN_REQ 0x0029
  569. typedef struct {
  570. bdaddr_t bdaddr;
  571. uint32_t tx_bandwith;
  572. uint32_t rx_bandwith;
  573. uint16_t max_latency;
  574. uint16_t voice_setting;
  575. uint8_t retrans_effort;
  576. uint16_t pkt_type;
  577. } __attribute__ ((packed)) accept_sync_conn_req_cp;
  578. #define ACCEPT_SYNC_CONN_REQ_CP_SIZE 21
  579. #define OCF_REJECT_SYNC_CONN_REQ 0x002A
  580. typedef struct {
  581. bdaddr_t bdaddr;
  582. uint8_t reason;
  583. } __attribute__ ((packed)) reject_sync_conn_req_cp;
  584. #define REJECT_SYNC_CONN_REQ_CP_SIZE 7
  585. /* Link Policy */
  586. #define OGF_LINK_POLICY 0x02
  587. #define OCF_HOLD_MODE 0x0001
  588. typedef struct {
  589. uint16_t handle;
  590. uint16_t max_interval;
  591. uint16_t min_interval;
  592. } __attribute__ ((packed)) hold_mode_cp;
  593. #define HOLD_MODE_CP_SIZE 6
  594. #define OCF_SNIFF_MODE 0x0003
  595. typedef struct {
  596. uint16_t handle;
  597. uint16_t max_interval;
  598. uint16_t min_interval;
  599. uint16_t attempt;
  600. uint16_t timeout;
  601. } __attribute__ ((packed)) sniff_mode_cp;
  602. #define SNIFF_MODE_CP_SIZE 10
  603. #define OCF_EXIT_SNIFF_MODE 0x0004
  604. typedef struct {
  605. uint16_t handle;
  606. } __attribute__ ((packed)) exit_sniff_mode_cp;
  607. #define EXIT_SNIFF_MODE_CP_SIZE 2
  608. #define OCF_PARK_MODE 0x0005
  609. typedef struct {
  610. uint16_t handle;
  611. uint16_t max_interval;
  612. uint16_t min_interval;
  613. } __attribute__ ((packed)) park_mode_cp;
  614. #define PARK_MODE_CP_SIZE 6
  615. #define OCF_EXIT_PARK_MODE 0x0006
  616. typedef struct {
  617. uint16_t handle;
  618. } __attribute__ ((packed)) exit_park_mode_cp;
  619. #define EXIT_PARK_MODE_CP_SIZE 2
  620. #define OCF_QOS_SETUP 0x0007
  621. typedef struct {
  622. uint8_t service_type; /* 1 = best effort */
  623. uint32_t token_rate; /* Byte per seconds */
  624. uint32_t peak_bandwidth; /* Byte per seconds */
  625. uint32_t latency; /* Microseconds */
  626. uint32_t delay_variation; /* Microseconds */
  627. } __attribute__ ((packed)) hci_qos;
  628. #define HCI_QOS_CP_SIZE 17
  629. typedef struct {
  630. uint16_t handle;
  631. uint8_t flags; /* Reserved */
  632. hci_qos qos;
  633. } __attribute__ ((packed)) qos_setup_cp;
  634. #define QOS_SETUP_CP_SIZE (3 + HCI_QOS_CP_SIZE)
  635. #define OCF_ROLE_DISCOVERY 0x0009
  636. typedef struct {
  637. uint16_t handle;
  638. } __attribute__ ((packed)) role_discovery_cp;
  639. #define ROLE_DISCOVERY_CP_SIZE 2
  640. typedef struct {
  641. uint8_t status;
  642. uint16_t handle;
  643. uint8_t role;
  644. } __attribute__ ((packed)) role_discovery_rp;
  645. #define ROLE_DISCOVERY_RP_SIZE 4
  646. #define OCF_SWITCH_ROLE 0x000B
  647. typedef struct {
  648. bdaddr_t bdaddr;
  649. uint8_t role;
  650. } __attribute__ ((packed)) switch_role_cp;
  651. #define SWITCH_ROLE_CP_SIZE 7
  652. #define OCF_READ_LINK_POLICY 0x000C
  653. typedef struct {
  654. uint16_t handle;
  655. } __attribute__ ((packed)) read_link_policy_cp;
  656. #define READ_LINK_POLICY_CP_SIZE 2
  657. typedef struct {
  658. uint8_t status;
  659. uint16_t handle;
  660. uint16_t policy;
  661. } __attribute__ ((packed)) read_link_policy_rp;
  662. #define READ_LINK_POLICY_RP_SIZE 5
  663. #define OCF_WRITE_LINK_POLICY 0x000D
  664. typedef struct {
  665. uint16_t handle;
  666. uint16_t policy;
  667. } __attribute__ ((packed)) write_link_policy_cp;
  668. #define WRITE_LINK_POLICY_CP_SIZE 4
  669. typedef struct {
  670. uint8_t status;
  671. uint16_t handle;
  672. } __attribute__ ((packed)) write_link_policy_rp;
  673. #define WRITE_LINK_POLICY_RP_SIZE 3
  674. #define OCF_READ_DEFAULT_LINK_POLICY 0x000E
  675. #define OCF_WRITE_DEFAULT_LINK_POLICY 0x000F
  676. #define OCF_FLOW_SPECIFICATION 0x0010
  677. #define OCF_SNIFF_SUBRATE 0x0011
  678. typedef struct {
  679. uint16_t handle;
  680. uint16_t max_remote_latency;
  681. uint16_t max_local_latency;
  682. uint16_t min_remote_timeout;
  683. uint16_t min_local_timeout;
  684. } __attribute__ ((packed)) sniff_subrate_cp;
  685. #define SNIFF_SUBRATE_CP_SIZE 10
  686. /* Host Controller and Baseband */
  687. #define OGF_HOST_CTL 0x03
  688. #define OCF_SET_EVENT_MASK 0x0001
  689. typedef struct {
  690. uint8_t mask[8];
  691. } __attribute__ ((packed)) set_event_mask_cp;
  692. #define SET_EVENT_MASK_CP_SIZE 8
  693. #define OCF_RESET 0x0003
  694. #define OCF_SET_EVENT_FLT 0x0005
  695. typedef struct {
  696. uint8_t flt_type;
  697. uint8_t cond_type;
  698. uint8_t condition[0];
  699. } __attribute__ ((packed)) set_event_flt_cp;
  700. #define SET_EVENT_FLT_CP_SIZE 2
  701. enum bt_filter_type {
  702. FLT_CLEAR_ALL = 0x00,
  703. FLT_INQ_RESULT = 0x01,
  704. FLT_CONN_SETUP = 0x02,
  705. };
  706. enum inq_result_cond_type {
  707. INQ_RESULT_RETURN_ALL = 0x00,
  708. INQ_RESULT_RETURN_CLASS = 0x01,
  709. INQ_RESULT_RETURN_BDADDR = 0x02,
  710. };
  711. enum conn_setup_cond_type {
  712. CONN_SETUP_ALLOW_ALL = 0x00,
  713. CONN_SETUP_ALLOW_CLASS = 0x01,
  714. CONN_SETUP_ALLOW_BDADDR = 0x02,
  715. };
  716. enum conn_setup_cond {
  717. CONN_SETUP_AUTO_OFF = 0x01,
  718. CONN_SETUP_AUTO_ON = 0x02,
  719. };
  720. #define OCF_FLUSH 0x0008
  721. typedef struct {
  722. uint16_t handle;
  723. } __attribute__ ((packed)) flush_cp;
  724. #define FLUSH_CP_SIZE 2
  725. typedef struct {
  726. uint8_t status;
  727. uint16_t handle;
  728. } __attribute__ ((packed)) flush_rp;
  729. #define FLUSH_RP_SIZE 3
  730. #define OCF_READ_PIN_TYPE 0x0009
  731. typedef struct {
  732. uint8_t status;
  733. uint8_t pin_type;
  734. } __attribute__ ((packed)) read_pin_type_rp;
  735. #define READ_PIN_TYPE_RP_SIZE 2
  736. #define OCF_WRITE_PIN_TYPE 0x000A
  737. typedef struct {
  738. uint8_t pin_type;
  739. } __attribute__ ((packed)) write_pin_type_cp;
  740. #define WRITE_PIN_TYPE_CP_SIZE 1
  741. #define OCF_CREATE_NEW_UNIT_KEY 0x000B
  742. #define OCF_READ_STORED_LINK_KEY 0x000D
  743. typedef struct {
  744. bdaddr_t bdaddr;
  745. uint8_t read_all;
  746. } __attribute__ ((packed)) read_stored_link_key_cp;
  747. #define READ_STORED_LINK_KEY_CP_SIZE 7
  748. typedef struct {
  749. uint8_t status;
  750. uint16_t max_keys;
  751. uint16_t num_keys;
  752. } __attribute__ ((packed)) read_stored_link_key_rp;
  753. #define READ_STORED_LINK_KEY_RP_SIZE 5
  754. #define OCF_WRITE_STORED_LINK_KEY 0x0011
  755. typedef struct {
  756. uint8_t num_keys;
  757. /* variable length part */
  758. } __attribute__ ((packed)) write_stored_link_key_cp;
  759. #define WRITE_STORED_LINK_KEY_CP_SIZE 1
  760. typedef struct {
  761. uint8_t status;
  762. uint8_t num_keys;
  763. } __attribute__ ((packed)) write_stored_link_key_rp;
  764. #define READ_WRITE_LINK_KEY_RP_SIZE 2
  765. #define OCF_DELETE_STORED_LINK_KEY 0x0012
  766. typedef struct {
  767. bdaddr_t bdaddr;
  768. uint8_t delete_all;
  769. } __attribute__ ((packed)) delete_stored_link_key_cp;
  770. #define DELETE_STORED_LINK_KEY_CP_SIZE 7
  771. typedef struct {
  772. uint8_t status;
  773. uint16_t num_keys;
  774. } __attribute__ ((packed)) delete_stored_link_key_rp;
  775. #define DELETE_STORED_LINK_KEY_RP_SIZE 3
  776. #define OCF_CHANGE_LOCAL_NAME 0x0013
  777. typedef struct {
  778. char name[248];
  779. } __attribute__ ((packed)) change_local_name_cp;
  780. #define CHANGE_LOCAL_NAME_CP_SIZE 248
  781. #define OCF_READ_LOCAL_NAME 0x0014
  782. typedef struct {
  783. uint8_t status;
  784. char name[248];
  785. } __attribute__ ((packed)) read_local_name_rp;
  786. #define READ_LOCAL_NAME_RP_SIZE 249
  787. #define OCF_READ_CONN_ACCEPT_TIMEOUT 0x0015
  788. typedef struct {
  789. uint8_t status;
  790. uint16_t timeout;
  791. } __attribute__ ((packed)) read_conn_accept_timeout_rp;
  792. #define READ_CONN_ACCEPT_TIMEOUT_RP_SIZE 3
  793. #define OCF_WRITE_CONN_ACCEPT_TIMEOUT 0x0016
  794. typedef struct {
  795. uint16_t timeout;
  796. } __attribute__ ((packed)) write_conn_accept_timeout_cp;
  797. #define WRITE_CONN_ACCEPT_TIMEOUT_CP_SIZE 2
  798. #define OCF_READ_PAGE_TIMEOUT 0x0017
  799. typedef struct {
  800. uint8_t status;
  801. uint16_t timeout;
  802. } __attribute__ ((packed)) read_page_timeout_rp;
  803. #define READ_PAGE_TIMEOUT_RP_SIZE 3
  804. #define OCF_WRITE_PAGE_TIMEOUT 0x0018
  805. typedef struct {
  806. uint16_t timeout;
  807. } __attribute__ ((packed)) write_page_timeout_cp;
  808. #define WRITE_PAGE_TIMEOUT_CP_SIZE 2
  809. #define OCF_READ_SCAN_ENABLE 0x0019
  810. typedef struct {
  811. uint8_t status;
  812. uint8_t enable;
  813. } __attribute__ ((packed)) read_scan_enable_rp;
  814. #define READ_SCAN_ENABLE_RP_SIZE 2
  815. #define OCF_WRITE_SCAN_ENABLE 0x001A
  816. typedef struct {
  817. uint8_t scan_enable;
  818. } __attribute__ ((packed)) write_scan_enable_cp;
  819. #define WRITE_SCAN_ENABLE_CP_SIZE 1
  820. enum scan_enable_bits {
  821. SCAN_DISABLED = 0,
  822. SCAN_INQUIRY = 1 << 0,
  823. SCAN_PAGE = 1 << 1,
  824. };
  825. #define OCF_READ_PAGE_ACTIVITY 0x001B
  826. typedef struct {
  827. uint8_t status;
  828. uint16_t interval;
  829. uint16_t window;
  830. } __attribute__ ((packed)) read_page_activity_rp;
  831. #define READ_PAGE_ACTIVITY_RP_SIZE 5
  832. #define OCF_WRITE_PAGE_ACTIVITY 0x001C
  833. typedef struct {
  834. uint16_t interval;
  835. uint16_t window;
  836. } __attribute__ ((packed)) write_page_activity_cp;
  837. #define WRITE_PAGE_ACTIVITY_CP_SIZE 4
  838. #define OCF_READ_INQ_ACTIVITY 0x001D
  839. typedef struct {
  840. uint8_t status;
  841. uint16_t interval;
  842. uint16_t window;
  843. } __attribute__ ((packed)) read_inq_activity_rp;
  844. #define READ_INQ_ACTIVITY_RP_SIZE 5
  845. #define OCF_WRITE_INQ_ACTIVITY 0x001E
  846. typedef struct {
  847. uint16_t interval;
  848. uint16_t window;
  849. } __attribute__ ((packed)) write_inq_activity_cp;
  850. #define WRITE_INQ_ACTIVITY_CP_SIZE 4
  851. #define OCF_READ_AUTH_ENABLE 0x001F
  852. #define OCF_WRITE_AUTH_ENABLE 0x0020
  853. #define AUTH_DISABLED 0x00
  854. #define AUTH_ENABLED 0x01
  855. #define OCF_READ_ENCRYPT_MODE 0x0021
  856. #define OCF_WRITE_ENCRYPT_MODE 0x0022
  857. #define ENCRYPT_DISABLED 0x00
  858. #define ENCRYPT_P2P 0x01
  859. #define ENCRYPT_BOTH 0x02
  860. #define OCF_READ_CLASS_OF_DEV 0x0023
  861. typedef struct {
  862. uint8_t status;
  863. uint8_t dev_class[3];
  864. } __attribute__ ((packed)) read_class_of_dev_rp;
  865. #define READ_CLASS_OF_DEV_RP_SIZE 4
  866. #define OCF_WRITE_CLASS_OF_DEV 0x0024
  867. typedef struct {
  868. uint8_t dev_class[3];
  869. } __attribute__ ((packed)) write_class_of_dev_cp;
  870. #define WRITE_CLASS_OF_DEV_CP_SIZE 3
  871. #define OCF_READ_VOICE_SETTING 0x0025
  872. typedef struct {
  873. uint8_t status;
  874. uint16_t voice_setting;
  875. } __attribute__ ((packed)) read_voice_setting_rp;
  876. #define READ_VOICE_SETTING_RP_SIZE 3
  877. #define OCF_WRITE_VOICE_SETTING 0x0026
  878. typedef struct {
  879. uint16_t voice_setting;
  880. } __attribute__ ((packed)) write_voice_setting_cp;
  881. #define WRITE_VOICE_SETTING_CP_SIZE 2
  882. #define OCF_READ_AUTOMATIC_FLUSH_TIMEOUT 0x0027
  883. #define OCF_WRITE_AUTOMATIC_FLUSH_TIMEOUT 0x0028
  884. #define OCF_READ_NUM_BROADCAST_RETRANS 0x0029
  885. #define OCF_WRITE_NUM_BROADCAST_RETRANS 0x002A
  886. #define OCF_READ_HOLD_MODE_ACTIVITY 0x002B
  887. #define OCF_WRITE_HOLD_MODE_ACTIVITY 0x002C
  888. #define OCF_READ_TRANSMIT_POWER_LEVEL 0x002D
  889. typedef struct {
  890. uint16_t handle;
  891. uint8_t type;
  892. } __attribute__ ((packed)) read_transmit_power_level_cp;
  893. #define READ_TRANSMIT_POWER_LEVEL_CP_SIZE 3
  894. typedef struct {
  895. uint8_t status;
  896. uint16_t handle;
  897. int8_t level;
  898. } __attribute__ ((packed)) read_transmit_power_level_rp;
  899. #define READ_TRANSMIT_POWER_LEVEL_RP_SIZE 4
  900. #define OCF_HOST_BUFFER_SIZE 0x0033
  901. typedef struct {
  902. uint16_t acl_mtu;
  903. uint8_t sco_mtu;
  904. uint16_t acl_max_pkt;
  905. uint16_t sco_max_pkt;
  906. } __attribute__ ((packed)) host_buffer_size_cp;
  907. #define HOST_BUFFER_SIZE_CP_SIZE 7
  908. #define OCF_HOST_NUMBER_OF_COMPLETED_PACKETS 0x0035
  909. #define OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036
  910. typedef struct {
  911. uint8_t status;
  912. uint16_t handle;
  913. uint16_t link_sup_to;
  914. } __attribute__ ((packed)) read_link_supervision_timeout_rp;
  915. #define READ_LINK_SUPERVISION_TIMEOUT_RP_SIZE 5
  916. #define OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037
  917. typedef struct {
  918. uint16_t handle;
  919. uint16_t link_sup_to;
  920. } __attribute__ ((packed)) write_link_supervision_timeout_cp;
  921. #define WRITE_LINK_SUPERVISION_TIMEOUT_CP_SIZE 4
  922. typedef struct {
  923. uint8_t status;
  924. uint16_t handle;
  925. } __attribute__ ((packed)) write_link_supervision_timeout_rp;
  926. #define WRITE_LINK_SUPERVISION_TIMEOUT_RP_SIZE 3
  927. #define OCF_READ_NUM_SUPPORTED_IAC 0x0038
  928. #define MAX_IAC_LAP 0x40
  929. #define OCF_READ_CURRENT_IAC_LAP 0x0039
  930. typedef struct {
  931. uint8_t status;
  932. uint8_t num_current_iac;
  933. uint8_t lap[MAX_IAC_LAP][3];
  934. } __attribute__ ((packed)) read_current_iac_lap_rp;
  935. #define READ_CURRENT_IAC_LAP_RP_SIZE 2+3*MAX_IAC_LAP
  936. #define OCF_WRITE_CURRENT_IAC_LAP 0x003A
  937. typedef struct {
  938. uint8_t num_current_iac;
  939. uint8_t lap[MAX_IAC_LAP][3];
  940. } __attribute__ ((packed)) write_current_iac_lap_cp;
  941. #define WRITE_CURRENT_IAC_LAP_CP_SIZE 1+3*MAX_IAC_LAP
  942. #define OCF_READ_PAGE_SCAN_PERIOD_MODE 0x003B
  943. #define OCF_WRITE_PAGE_SCAN_PERIOD_MODE 0x003C
  944. #define OCF_READ_PAGE_SCAN_MODE 0x003D
  945. #define OCF_WRITE_PAGE_SCAN_MODE 0x003E
  946. #define OCF_SET_AFH_CLASSIFICATION 0x003F
  947. typedef struct {
  948. uint8_t map[10];
  949. } __attribute__ ((packed)) set_afh_classification_cp;
  950. #define SET_AFH_CLASSIFICATION_CP_SIZE 10
  951. typedef struct {
  952. uint8_t status;
  953. } __attribute__ ((packed)) set_afh_classification_rp;
  954. #define SET_AFH_CLASSIFICATION_RP_SIZE 1
  955. #define OCF_READ_INQUIRY_SCAN_TYPE 0x0042
  956. typedef struct {
  957. uint8_t status;
  958. uint8_t type;
  959. } __attribute__ ((packed)) read_inquiry_scan_type_rp;
  960. #define READ_INQUIRY_SCAN_TYPE_RP_SIZE 2
  961. #define OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043
  962. typedef struct {
  963. uint8_t type;
  964. } __attribute__ ((packed)) write_inquiry_scan_type_cp;
  965. #define WRITE_INQUIRY_SCAN_TYPE_CP_SIZE 1
  966. typedef struct {
  967. uint8_t status;
  968. } __attribute__ ((packed)) write_inquiry_scan_type_rp;
  969. #define WRITE_INQUIRY_SCAN_TYPE_RP_SIZE 1
  970. #define OCF_READ_INQUIRY_MODE 0x0044
  971. typedef struct {
  972. uint8_t status;
  973. uint8_t mode;
  974. } __attribute__ ((packed)) read_inquiry_mode_rp;
  975. #define READ_INQUIRY_MODE_RP_SIZE 2
  976. #define OCF_WRITE_INQUIRY_MODE 0x0045
  977. typedef struct {
  978. uint8_t mode;
  979. } __attribute__ ((packed)) write_inquiry_mode_cp;
  980. #define WRITE_INQUIRY_MODE_CP_SIZE 1
  981. typedef struct {
  982. uint8_t status;
  983. } __attribute__ ((packed)) write_inquiry_mode_rp;
  984. #define WRITE_INQUIRY_MODE_RP_SIZE 1
  985. #define OCF_READ_PAGE_SCAN_TYPE 0x0046
  986. #define OCF_WRITE_PAGE_SCAN_TYPE 0x0047
  987. #define OCF_READ_AFH_MODE 0x0048
  988. typedef struct {
  989. uint8_t status;
  990. uint8_t mode;
  991. } __attribute__ ((packed)) read_afh_mode_rp;
  992. #define READ_AFH_MODE_RP_SIZE 2
  993. #define OCF_WRITE_AFH_MODE 0x0049
  994. typedef struct {
  995. uint8_t mode;
  996. } __attribute__ ((packed)) write_afh_mode_cp;
  997. #define WRITE_AFH_MODE_CP_SIZE 1
  998. typedef struct {
  999. uint8_t status;
  1000. } __attribute__ ((packed)) write_afh_mode_rp;
  1001. #define WRITE_AFH_MODE_RP_SIZE 1
  1002. #define OCF_READ_EXT_INQUIRY_RESPONSE 0x0051
  1003. typedef struct {
  1004. uint8_t status;
  1005. uint8_t fec;
  1006. uint8_t data[240];
  1007. } __attribute__ ((packed)) read_ext_inquiry_response_rp;
  1008. #define READ_EXT_INQUIRY_RESPONSE_RP_SIZE 242
  1009. #define OCF_WRITE_EXT_INQUIRY_RESPONSE 0x0052
  1010. typedef struct {
  1011. uint8_t fec;
  1012. uint8_t data[240];
  1013. } __attribute__ ((packed)) write_ext_inquiry_response_cp;
  1014. #define WRITE_EXT_INQUIRY_RESPONSE_CP_SIZE 241
  1015. typedef struct {
  1016. uint8_t status;
  1017. } __attribute__ ((packed)) write_ext_inquiry_response_rp;
  1018. #define WRITE_EXT_INQUIRY_RESPONSE_RP_SIZE 1
  1019. /* Informational Parameters */
  1020. #define OGF_INFO_PARAM 0x04
  1021. #define OCF_READ_LOCAL_VERSION 0x0001
  1022. typedef struct {
  1023. uint8_t status;
  1024. uint8_t hci_ver;
  1025. uint16_t hci_rev;
  1026. uint8_t lmp_ver;
  1027. uint16_t manufacturer;
  1028. uint16_t lmp_subver;
  1029. } __attribute__ ((packed)) read_local_version_rp;
  1030. #define READ_LOCAL_VERSION_RP_SIZE 9
  1031. #define OCF_READ_LOCAL_COMMANDS 0x0002
  1032. typedef struct {
  1033. uint8_t status;
  1034. uint8_t commands[64];
  1035. } __attribute__ ((packed)) read_local_commands_rp;
  1036. #define READ_LOCAL_COMMANDS_RP_SIZE 65
  1037. #define OCF_READ_LOCAL_FEATURES 0x0003
  1038. typedef struct {
  1039. uint8_t status;
  1040. uint8_t features[8];
  1041. } __attribute__ ((packed)) read_local_features_rp;
  1042. #define READ_LOCAL_FEATURES_RP_SIZE 9
  1043. #define OCF_READ_LOCAL_EXT_FEATURES 0x0004
  1044. typedef struct {
  1045. uint8_t page_num;
  1046. } __attribute__ ((packed)) read_local_ext_features_cp;
  1047. #define READ_LOCAL_EXT_FEATURES_CP_SIZE 1
  1048. typedef struct {
  1049. uint8_t status;
  1050. uint8_t page_num;
  1051. uint8_t max_page_num;
  1052. uint8_t features[8];
  1053. } __attribute__ ((packed)) read_local_ext_features_rp;
  1054. #define READ_LOCAL_EXT_FEATURES_RP_SIZE 11
  1055. #define OCF_READ_BUFFER_SIZE 0x0005
  1056. typedef struct {
  1057. uint8_t status;
  1058. uint16_t acl_mtu;
  1059. uint8_t sco_mtu;
  1060. uint16_t acl_max_pkt;
  1061. uint16_t sco_max_pkt;
  1062. } __attribute__ ((packed)) read_buffer_size_rp;
  1063. #define READ_BUFFER_SIZE_RP_SIZE 8
  1064. #define OCF_READ_COUNTRY_CODE 0x0007
  1065. typedef struct {
  1066. uint8_t status;
  1067. uint8_t country_code;
  1068. } __attribute__ ((packed)) read_country_code_rp;
  1069. #define READ_COUNTRY_CODE_RP_SIZE 2
  1070. #define OCF_READ_BD_ADDR 0x0009
  1071. typedef struct {
  1072. uint8_t status;
  1073. bdaddr_t bdaddr;
  1074. } __attribute__ ((packed)) read_bd_addr_rp;
  1075. #define READ_BD_ADDR_RP_SIZE 7
  1076. /* Status params */
  1077. #define OGF_STATUS_PARAM 0x05
  1078. #define OCF_READ_FAILED_CONTACT_COUNTER 0x0001
  1079. typedef struct {
  1080. uint8_t status;
  1081. uint16_t handle;
  1082. uint8_t counter;
  1083. } __attribute__ ((packed)) read_failed_contact_counter_rp;
  1084. #define READ_FAILED_CONTACT_COUNTER_RP_SIZE 4
  1085. #define OCF_RESET_FAILED_CONTACT_COUNTER 0x0002
  1086. typedef struct {
  1087. uint8_t status;
  1088. uint16_t handle;
  1089. } __attribute__ ((packed)) reset_failed_contact_counter_rp;
  1090. #define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 4
  1091. #define OCF_READ_LINK_QUALITY 0x0003
  1092. typedef struct {
  1093. uint16_t handle;
  1094. } __attribute__ ((packed)) read_link_quality_cp;
  1095. #define READ_LINK_QUALITY_CP_SIZE 4
  1096. typedef struct {
  1097. uint8_t status;
  1098. uint16_t handle;
  1099. uint8_t link_quality;
  1100. } __attribute__ ((packed)) read_link_quality_rp;
  1101. #define READ_LINK_QUALITY_RP_SIZE 4
  1102. #define OCF_READ_RSSI 0x0005
  1103. typedef struct {
  1104. uint8_t status;
  1105. uint16_t handle;
  1106. int8_t rssi;
  1107. } __attribute__ ((packed)) read_rssi_rp;
  1108. #define READ_RSSI_RP_SIZE 4
  1109. #define OCF_READ_AFH_MAP 0x0006
  1110. typedef struct {
  1111. uint8_t status;
  1112. uint16_t handle;
  1113. uint8_t mode;
  1114. uint8_t map[10];
  1115. } __attribute__ ((packed)) read_afh_map_rp;
  1116. #define READ_AFH_MAP_RP_SIZE 14
  1117. #define OCF_READ_CLOCK 0x0007
  1118. typedef struct {
  1119. uint16_t handle;
  1120. uint8_t which_clock;
  1121. } __attribute__ ((packed)) read_clock_cp;
  1122. #define READ_CLOCK_CP_SIZE 3
  1123. typedef struct {
  1124. uint8_t status;
  1125. uint16_t handle;
  1126. uint32_t clock;
  1127. uint16_t accuracy;
  1128. } __attribute__ ((packed)) read_clock_rp;
  1129. #define READ_CLOCK_RP_SIZE 9
  1130. /* Testing commands */
  1131. #define OGF_TESTING_CMD 0x3e
  1132. /* Vendor specific commands */
  1133. #define OGF_VENDOR_CMD 0x3f
  1134. /* HCI Events */
  1135. #define EVT_INQUIRY_COMPLETE 0x01
  1136. #define EVT_INQUIRY_RESULT 0x02
  1137. typedef struct {
  1138. uint8_t num_responses;
  1139. bdaddr_t bdaddr;
  1140. uint8_t pscan_rep_mode;
  1141. uint8_t pscan_period_mode;
  1142. uint8_t pscan_mode;
  1143. uint8_t dev_class[3];
  1144. uint16_t clock_offset;
  1145. } __attribute__ ((packed)) inquiry_info;
  1146. #define INQUIRY_INFO_SIZE 14
  1147. #define EVT_CONN_COMPLETE 0x03
  1148. typedef struct {
  1149. uint8_t status;
  1150. uint16_t handle;
  1151. bdaddr_t bdaddr;
  1152. uint8_t link_type;
  1153. uint8_t encr_mode;
  1154. } __attribute__ ((packed)) evt_conn_complete;
  1155. #define EVT_CONN_COMPLETE_SIZE 11
  1156. #define EVT_CONN_REQUEST 0x04
  1157. typedef struct {
  1158. bdaddr_t bdaddr;
  1159. uint8_t dev_class[3];
  1160. uint8_t link_type;
  1161. } __attribute__ ((packed)) evt_conn_request;
  1162. #define EVT_CONN_REQUEST_SIZE 10
  1163. #define EVT_DISCONN_COMPLETE 0x05
  1164. typedef struct {
  1165. uint8_t status;
  1166. uint16_t handle;
  1167. uint8_t reason;
  1168. } __attribute__ ((packed)) evt_disconn_complete;
  1169. #define EVT_DISCONN_COMPLETE_SIZE 4
  1170. #define EVT_AUTH_COMPLETE 0x06
  1171. typedef struct {
  1172. uint8_t status;
  1173. uint16_t handle;
  1174. } __attribute__ ((packed)) evt_auth_complete;
  1175. #define EVT_AUTH_COMPLETE_SIZE 3
  1176. #define EVT_REMOTE_NAME_REQ_COMPLETE 0x07
  1177. typedef struct {
  1178. uint8_t status;
  1179. bdaddr_t bdaddr;
  1180. char name[248];
  1181. } __attribute__ ((packed)) evt_remote_name_req_complete;
  1182. #define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
  1183. #define EVT_ENCRYPT_CHANGE 0x08
  1184. typedef struct {
  1185. uint8_t status;
  1186. uint16_t handle;
  1187. uint8_t encrypt;
  1188. } __attribute__ ((packed)) evt_encrypt_change;
  1189. #define EVT_ENCRYPT_CHANGE_SIZE 5
  1190. #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE 0x09
  1191. typedef struct {
  1192. uint8_t status;
  1193. uint16_t handle;
  1194. } __attribute__ ((packed)) evt_change_conn_link_key_complete;
  1195. #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE_SIZE 3
  1196. #define EVT_MASTER_LINK_KEY_COMPLETE 0x0A
  1197. typedef struct {
  1198. uint8_t status;
  1199. uint16_t handle;
  1200. uint8_t key_flag;
  1201. } __attribute__ ((packed)) evt_master_link_key_complete;
  1202. #define EVT_MASTER_LINK_KEY_COMPLETE_SIZE 4
  1203. #define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B
  1204. typedef struct {
  1205. uint8_t status;
  1206. uint16_t handle;
  1207. uint8_t features[8];
  1208. } __attribute__ ((packed)) evt_read_remote_features_complete;
  1209. #define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
  1210. #define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C
  1211. typedef struct {
  1212. uint8_t status;
  1213. uint16_t handle;
  1214. uint8_t lmp_ver;
  1215. uint16_t manufacturer;
  1216. uint16_t lmp_subver;
  1217. } __attribute__ ((packed)) evt_read_remote_version_complete;
  1218. #define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
  1219. #define EVT_QOS_SETUP_COMPLETE 0x0D
  1220. typedef struct {
  1221. uint8_t status;
  1222. uint16_t handle;
  1223. uint8_t flags; /* Reserved */
  1224. hci_qos qos;
  1225. } __attribute__ ((packed)) evt_qos_setup_complete;
  1226. #define EVT_QOS_SETUP_COMPLETE_SIZE (4 + HCI_QOS_CP_SIZE)
  1227. #define EVT_CMD_COMPLETE 0x0E
  1228. typedef struct {
  1229. uint8_t ncmd;
  1230. uint16_t opcode;
  1231. } __attribute__ ((packed)) evt_cmd_complete;
  1232. #define EVT_CMD_COMPLETE_SIZE 3
  1233. #define EVT_CMD_STATUS 0x0F
  1234. typedef struct {
  1235. uint8_t status;
  1236. uint8_t ncmd;
  1237. uint16_t opcode;
  1238. } __attribute__ ((packed)) evt_cmd_status;
  1239. #define EVT_CMD_STATUS_SIZE 4
  1240. #define EVT_HARDWARE_ERROR 0x10
  1241. typedef struct {
  1242. uint8_t code;
  1243. } __attribute__ ((packed)) evt_hardware_error;
  1244. #define EVT_HARDWARE_ERROR_SIZE 1
  1245. #define EVT_FLUSH_OCCURRED 0x11
  1246. typedef struct {
  1247. uint16_t handle;
  1248. } __attribute__ ((packed)) evt_flush_occurred;
  1249. #define EVT_FLUSH_OCCURRED_SIZE 2
  1250. #define EVT_ROLE_CHANGE 0x12
  1251. typedef struct {
  1252. uint8_t status;
  1253. bdaddr_t bdaddr;
  1254. uint8_t role;
  1255. } __attribute__ ((packed)) evt_role_change;
  1256. #define EVT_ROLE_CHANGE_SIZE 8
  1257. #define EVT_NUM_COMP_PKTS 0x13
  1258. typedef struct {
  1259. uint8_t num_hndl;
  1260. struct {
  1261. uint16_t handle;
  1262. uint16_t num_packets;
  1263. } connection[0];
  1264. } __attribute__ ((packed)) evt_num_comp_pkts;
  1265. #define EVT_NUM_COMP_PKTS_SIZE(num_hndl) (1 + 4 * (num_hndl))
  1266. #define EVT_MODE_CHANGE 0x14
  1267. typedef struct {
  1268. uint8_t status;
  1269. uint16_t handle;
  1270. uint8_t mode;
  1271. uint16_t interval;
  1272. } __attribute__ ((packed)) evt_mode_change;
  1273. #define EVT_MODE_CHANGE_SIZE 6
  1274. #define EVT_RETURN_LINK_KEYS 0x15
  1275. typedef struct {
  1276. uint8_t num_keys;
  1277. /* variable length part */
  1278. } __attribute__ ((packed)) evt_return_link_keys;
  1279. #define EVT_RETURN_LINK_KEYS_SIZE 1
  1280. #define EVT_PIN_CODE_REQ 0x16
  1281. typedef struct {
  1282. bdaddr_t bdaddr;
  1283. } __attribute__ ((packed)) evt_pin_code_req;
  1284. #define EVT_PIN_CODE_REQ_SIZE 6
  1285. #define EVT_LINK_KEY_REQ 0x17
  1286. typedef struct {
  1287. bdaddr_t bdaddr;
  1288. } __attribute__ ((packed)) evt_link_key_req;
  1289. #define EVT_LINK_KEY_REQ_SIZE 6
  1290. #define EVT_LINK_KEY_NOTIFY 0x18
  1291. typedef struct {
  1292. bdaddr_t bdaddr;
  1293. uint8_t link_key[16];
  1294. uint8_t key_type;
  1295. } __attribute__ ((packed)) evt_link_key_notify;
  1296. #define EVT_LINK_KEY_NOTIFY_SIZE 23
  1297. #define EVT_LOOPBACK_COMMAND 0x19
  1298. #define EVT_DATA_BUFFER_OVERFLOW 0x1A
  1299. typedef struct {
  1300. uint8_t link_type;
  1301. } __attribute__ ((packed)) evt_data_buffer_overflow;
  1302. #define EVT_DATA_BUFFER_OVERFLOW_SIZE 1
  1303. #define EVT_MAX_SLOTS_CHANGE 0x1B
  1304. typedef struct {
  1305. uint16_t handle;
  1306. uint8_t max_slots;
  1307. } __attribute__ ((packed)) evt_max_slots_change;
  1308. #define EVT_MAX_SLOTS_CHANGE_SIZE 3
  1309. #define EVT_READ_CLOCK_OFFSET_COMPLETE 0x1C
  1310. typedef struct {
  1311. uint8_t status;
  1312. uint16_t handle;
  1313. uint16_t clock_offset;
  1314. } __attribute__ ((packed)) evt_read_clock_offset_complete;
  1315. #define EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE 5
  1316. #define EVT_CONN_PTYPE_CHANGED 0x1D
  1317. typedef struct {
  1318. uint8_t status;
  1319. uint16_t handle;
  1320. uint16_t ptype;
  1321. } __attribute__ ((packed)) evt_conn_ptype_changed;
  1322. #define EVT_CONN_PTYPE_CHANGED_SIZE 5
  1323. #define EVT_QOS_VIOLATION 0x1E
  1324. typedef struct {
  1325. uint16_t handle;
  1326. } __attribute__ ((packed)) evt_qos_violation;
  1327. #define EVT_QOS_VIOLATION_SIZE 2
  1328. #define EVT_PSCAN_REP_MODE_CHANGE 0x20
  1329. typedef struct {
  1330. bdaddr_t bdaddr;
  1331. uint8_t pscan_rep_mode;
  1332. } __attribute__ ((packed)) evt_pscan_rep_mode_change;
  1333. #define EVT_PSCAN_REP_MODE_CHANGE_SIZE 7
  1334. #define EVT_FLOW_SPEC_COMPLETE 0x21
  1335. typedef struct {
  1336. uint8_t status;
  1337. uint16_t handle;
  1338. uint8_t flags;
  1339. uint8_t direction;
  1340. hci_qos qos;
  1341. } __attribute__ ((packed)) evt_flow_spec_complete;
  1342. #define EVT_FLOW_SPEC_COMPLETE_SIZE (5 + HCI_QOS_CP_SIZE)
  1343. #define EVT_INQUIRY_RESULT_WITH_RSSI 0x22
  1344. typedef struct {
  1345. uint8_t num_responses;
  1346. bdaddr_t bdaddr;
  1347. uint8_t pscan_rep_mode;
  1348. uint8_t pscan_period_mode;
  1349. uint8_t dev_class[3];
  1350. uint16_t clock_offset;
  1351. int8_t rssi;
  1352. } __attribute__ ((packed)) inquiry_info_with_rssi;
  1353. #define INQUIRY_INFO_WITH_RSSI_SIZE 15
  1354. typedef struct {
  1355. uint8_t num_responses;
  1356. bdaddr_t bdaddr;
  1357. uint8_t pscan_rep_mode;
  1358. uint8_t pscan_period_mode;
  1359. uint8_t pscan_mode;
  1360. uint8_t dev_class[3];
  1361. uint16_t clock_offset;
  1362. int8_t rssi;
  1363. } __attribute__ ((packed)) inquiry_info_with_rssi_and_pscan_mode;
  1364. #define INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE 16
  1365. #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE 0x23
  1366. typedef struct {
  1367. uint8_t status;
  1368. uint16_t handle;
  1369. uint8_t page_num;
  1370. uint8_t max_page_num;
  1371. uint8_t features[8];
  1372. } __attribute__ ((packed)) evt_read_remote_ext_features_complete;
  1373. #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE_SIZE 13
  1374. #define EVT_SYNC_CONN_COMPLETE 0x2C
  1375. typedef struct {
  1376. uint8_t status;
  1377. uint16_t handle;
  1378. bdaddr_t bdaddr;
  1379. uint8_t link_type;
  1380. uint8_t trans_interval;
  1381. uint8_t retrans_window;
  1382. uint16_t rx_pkt_len;
  1383. uint16_t tx_pkt_len;
  1384. uint8_t air_mode;
  1385. } __attribute__ ((packed)) evt_sync_conn_complete;
  1386. #define EVT_SYNC_CONN_COMPLETE_SIZE 17
  1387. #define EVT_SYNC_CONN_CHANGED 0x2D
  1388. typedef struct {
  1389. uint8_t status;
  1390. uint16_t handle;
  1391. uint8_t trans_interval;
  1392. uint8_t retrans_window;
  1393. uint16_t rx_pkt_len;
  1394. uint16_t tx_pkt_len;
  1395. } __attribute__ ((packed)) evt_sync_conn_changed;
  1396. #define EVT_SYNC_CONN_CHANGED_SIZE 9
  1397. #define EVT_SNIFF_SUBRATE 0x2E
  1398. typedef struct {
  1399. uint8_t status;
  1400. uint16_t handle;
  1401. uint16_t max_remote_latency;
  1402. uint16_t max_local_latency;
  1403. uint16_t min_remote_timeout;
  1404. uint16_t min_local_timeout;
  1405. } __attribute__ ((packed)) evt_sniff_subrate;
  1406. #define EVT_SNIFF_SUBRATE_SIZE 11
  1407. #define EVT_EXTENDED_INQUIRY_RESULT 0x2F
  1408. typedef struct {
  1409. bdaddr_t bdaddr;
  1410. uint8_t pscan_rep_mode;
  1411. uint8_t pscan_period_mode;
  1412. uint8_t dev_class[3];
  1413. uint16_t clock_offset;
  1414. int8_t rssi;
  1415. uint8_t data[240];
  1416. } __attribute__ ((packed)) extended_inquiry_info;
  1417. #define EXTENDED_INQUIRY_INFO_SIZE 254
  1418. #define EVT_TESTING 0xFE
  1419. #define EVT_VENDOR 0xFF
  1420. /* Command opcode pack/unpack */
  1421. #define cmd_opcode_pack(ogf, ocf) (uint16_t)((ocf & 0x03ff)|(ogf << 10))
  1422. #define cmd_opcode_ogf(op) (op >> 10)
  1423. #define cmd_opcode_ocf(op) (op & 0x03ff)
  1424. /* ACL handle and flags pack/unpack */
  1425. #define acl_handle_pack(h, f) (uint16_t)(((h) & 0x0fff)|((f) << 12))
  1426. #define acl_handle(h) ((h) & 0x0fff)
  1427. #define acl_flags(h) ((h) >> 12)
  1428. /* HCI Packet structures */
  1429. #define HCI_COMMAND_HDR_SIZE 3
  1430. #define HCI_EVENT_HDR_SIZE 2
  1431. #define HCI_ACL_HDR_SIZE 4
  1432. #define HCI_SCO_HDR_SIZE 3
  1433. struct hci_command_hdr {
  1434. uint16_t opcode; /* OCF & OGF */
  1435. uint8_t plen;
  1436. } __attribute__ ((packed));
  1437. struct hci_event_hdr {
  1438. uint8_t evt;
  1439. uint8_t plen;
  1440. } __attribute__ ((packed));
  1441. struct hci_acl_hdr {
  1442. uint16_t handle; /* Handle & Flags(PB, BC) */
  1443. uint16_t dlen;
  1444. } __attribute__ ((packed));
  1445. struct hci_sco_hdr {
  1446. uint16_t handle;
  1447. uint8_t dlen;
  1448. } __attribute__ ((packed));
  1449. /* L2CAP layer defines */
  1450. enum bt_l2cap_lm_bits {
  1451. L2CAP_LM_MASTER = 1 << 0,
  1452. L2CAP_LM_AUTH = 1 << 1,
  1453. L2CAP_LM_ENCRYPT = 1 << 2,
  1454. L2CAP_LM_TRUSTED = 1 << 3,
  1455. L2CAP_LM_RELIABLE = 1 << 4,
  1456. L2CAP_LM_SECURE = 1 << 5,
  1457. };
  1458. enum bt_l2cap_cid_predef {
  1459. L2CAP_CID_INVALID = 0x0000,
  1460. L2CAP_CID_SIGNALLING= 0x0001,
  1461. L2CAP_CID_GROUP = 0x0002,
  1462. L2CAP_CID_ALLOC = 0x0040,
  1463. };
  1464. /* L2CAP command codes */
  1465. enum bt_l2cap_cmd {
  1466. L2CAP_COMMAND_REJ = 1,
  1467. L2CAP_CONN_REQ,
  1468. L2CAP_CONN_RSP,
  1469. L2CAP_CONF_REQ,
  1470. L2CAP_CONF_RSP,
  1471. L2CAP_DISCONN_REQ,
  1472. L2CAP_DISCONN_RSP,
  1473. L2CAP_ECHO_REQ,
  1474. L2CAP_ECHO_RSP,
  1475. L2CAP_INFO_REQ,
  1476. L2CAP_INFO_RSP,
  1477. };
  1478. enum bt_l2cap_sar_bits {
  1479. L2CAP_SAR_NO_SEG = 0,
  1480. L2CAP_SAR_START,
  1481. L2CAP_SAR_END,
  1482. L2CAP_SAR_CONT,
  1483. };
  1484. /* L2CAP structures */
  1485. typedef struct {
  1486. uint16_t len;
  1487. uint16_t cid;
  1488. uint8_t data[0];
  1489. } __attribute__ ((packed)) l2cap_hdr;
  1490. #define L2CAP_HDR_SIZE 4
  1491. typedef struct {
  1492. uint8_t code;
  1493. uint8_t ident;
  1494. uint16_t len;
  1495. } __attribute__ ((packed)) l2cap_cmd_hdr;
  1496. #define L2CAP_CMD_HDR_SIZE 4
  1497. typedef struct {
  1498. uint16_t reason;
  1499. } __attribute__ ((packed)) l2cap_cmd_rej;
  1500. #define L2CAP_CMD_REJ_SIZE 2
  1501. typedef struct {
  1502. uint16_t dcid;
  1503. uint16_t scid;
  1504. } __attribute__ ((packed)) l2cap_cmd_rej_cid;
  1505. #define L2CAP_CMD_REJ_CID_SIZE 4
  1506. /* reject reason */
  1507. enum bt_l2cap_rej_reason {
  1508. L2CAP_REJ_CMD_NOT_UNDERSTOOD = 0,
  1509. L2CAP_REJ_SIG_TOOBIG,
  1510. L2CAP_REJ_CID_INVAL,
  1511. };
  1512. typedef struct {
  1513. uint16_t psm;
  1514. uint16_t scid;
  1515. } __attribute__ ((packed)) l2cap_conn_req;
  1516. #define L2CAP_CONN_REQ_SIZE 4
  1517. typedef struct {
  1518. uint16_t dcid;
  1519. uint16_t scid;
  1520. uint16_t result;
  1521. uint16_t status;
  1522. } __attribute__ ((packed)) l2cap_conn_rsp;
  1523. #define L2CAP_CONN_RSP_SIZE 8
  1524. /* connect result */
  1525. enum bt_l2cap_conn_res {
  1526. L2CAP_CR_SUCCESS = 0,
  1527. L2CAP_CR_PEND,
  1528. L2CAP_CR_BAD_PSM,
  1529. L2CAP_CR_SEC_BLOCK,
  1530. L2CAP_CR_NO_MEM,
  1531. };
  1532. /* connect status */
  1533. enum bt_l2cap_conn_stat {
  1534. L2CAP_CS_NO_INFO = 0,
  1535. L2CAP_CS_AUTHEN_PEND,
  1536. L2CAP_CS_AUTHOR_PEND,
  1537. };
  1538. typedef struct {
  1539. uint16_t dcid;
  1540. uint16_t flags;
  1541. uint8_t data[0];
  1542. } __attribute__ ((packed)) l2cap_conf_req;
  1543. #define L2CAP_CONF_REQ_SIZE(datalen) (4 + (datalen))
  1544. typedef struct {
  1545. uint16_t scid;
  1546. uint16_t flags;
  1547. uint16_t result;
  1548. uint8_t data[0];
  1549. } __attribute__ ((packed)) l2cap_conf_rsp;
  1550. #define L2CAP_CONF_RSP_SIZE(datalen) (6 + datalen)
  1551. enum bt_l2cap_conf_res {
  1552. L2CAP_CONF_SUCCESS = 0,
  1553. L2CAP_CONF_UNACCEPT,
  1554. L2CAP_CONF_REJECT,
  1555. L2CAP_CONF_UNKNOWN,
  1556. };
  1557. typedef struct {
  1558. uint8_t type;
  1559. uint8_t len;
  1560. uint8_t val[0];
  1561. } __attribute__ ((packed)) l2cap_conf_opt;
  1562. #define L2CAP_CONF_OPT_SIZE 2
  1563. enum bt_l2cap_conf_val {
  1564. L2CAP_CONF_MTU = 1,
  1565. L2CAP_CONF_FLUSH_TO,
  1566. L2CAP_CONF_QOS,
  1567. L2CAP_CONF_RFC,
  1568. L2CAP_CONF_RFC_MODE = L2CAP_CONF_RFC,
  1569. };
  1570. typedef struct {
  1571. uint8_t flags;
  1572. uint8_t service_type;
  1573. uint32_t token_rate;
  1574. uint32_t token_bucket_size;
  1575. uint32_t peak_bandwidth;
  1576. uint32_t latency;
  1577. uint32_t delay_variation;
  1578. } __attribute__ ((packed)) l2cap_conf_opt_qos;
  1579. #define L2CAP_CONF_OPT_QOS_SIZE 22
  1580. enum bt_l2cap_conf_opt_qos_st {
  1581. L2CAP_CONF_QOS_NO_TRAFFIC = 0x00,
  1582. L2CAP_CONF_QOS_BEST_EFFORT,
  1583. L2CAP_CONF_QOS_GUARANTEED,
  1584. };
  1585. #define L2CAP_CONF_QOS_WILDCARD 0xffffffff
  1586. enum bt_l2cap_mode {
  1587. L2CAP_MODE_BASIC = 0,
  1588. L2CAP_MODE_RETRANS = 1,
  1589. L2CAP_MODE_FLOWCTL = 2,
  1590. };
  1591. typedef struct {
  1592. uint16_t dcid;
  1593. uint16_t scid;
  1594. } __attribute__ ((packed)) l2cap_disconn_req;
  1595. #define L2CAP_DISCONN_REQ_SIZE 4
  1596. typedef struct {
  1597. uint16_t dcid;
  1598. uint16_t scid;
  1599. } __attribute__ ((packed)) l2cap_disconn_rsp;
  1600. #define L2CAP_DISCONN_RSP_SIZE 4
  1601. typedef struct {
  1602. uint16_t type;
  1603. } __attribute__ ((packed)) l2cap_info_req;
  1604. #define L2CAP_INFO_REQ_SIZE 2
  1605. typedef struct {
  1606. uint16_t type;
  1607. uint16_t result;
  1608. uint8_t data[0];
  1609. } __attribute__ ((packed)) l2cap_info_rsp;
  1610. #define L2CAP_INFO_RSP_SIZE 4
  1611. /* info type */
  1612. enum bt_l2cap_info_type {
  1613. L2CAP_IT_CL_MTU = 1,
  1614. L2CAP_IT_FEAT_MASK,
  1615. };
  1616. /* info result */
  1617. enum bt_l2cap_info_result {
  1618. L2CAP_IR_SUCCESS = 0,
  1619. L2CAP_IR_NOTSUPP,
  1620. };
  1621. /* Service Discovery Protocol defines */
  1622. /* Note that all multibyte values in lower layer protocols (above in this file)
  1623. * are little-endian while SDP is big-endian. */
  1624. /* Protocol UUIDs */
  1625. enum sdp_proto_uuid {
  1626. SDP_UUID = 0x0001,
  1627. UDP_UUID = 0x0002,
  1628. RFCOMM_UUID = 0x0003,
  1629. TCP_UUID = 0x0004,
  1630. TCS_BIN_UUID = 0x0005,
  1631. TCS_AT_UUID = 0x0006,
  1632. OBEX_UUID = 0x0008,
  1633. IP_UUID = 0x0009,
  1634. FTP_UUID = 0x000a,
  1635. HTTP_UUID = 0x000c,
  1636. WSP_UUID = 0x000e,
  1637. BNEP_UUID = 0x000f,
  1638. UPNP_UUID = 0x0010,
  1639. HIDP_UUID = 0x0011,
  1640. HCRP_CTRL_UUID = 0x0012,
  1641. HCRP_DATA_UUID = 0x0014,
  1642. HCRP_NOTE_UUID = 0x0016,
  1643. AVCTP_UUID = 0x0017,
  1644. AVDTP_UUID = 0x0019,
  1645. CMTP_UUID = 0x001b,
  1646. UDI_UUID = 0x001d,
  1647. MCAP_CTRL_UUID = 0x001e,
  1648. MCAP_DATA_UUID = 0x001f,
  1649. L2CAP_UUID = 0x0100,
  1650. };
  1651. /*
  1652. * Service class identifiers of standard services and service groups
  1653. */
  1654. enum service_class_id {
  1655. SDP_SERVER_SVCLASS_ID = 0x1000,
  1656. BROWSE_GRP_DESC_SVCLASS_ID = 0x1001,
  1657. PUBLIC_BROWSE_GROUP = 0x1002,
  1658. SERIAL_PORT_SVCLASS_ID = 0x1101,
  1659. LAN_ACCESS_SVCLASS_ID = 0x1102,
  1660. DIALUP_NET_SVCLASS_ID = 0x1103,
  1661. IRMC_SYNC_SVCLASS_ID = 0x1104,
  1662. OBEX_OBJPUSH_SVCLASS_ID = 0x1105,
  1663. OBEX_FILETRANS_SVCLASS_ID = 0x1106,
  1664. IRMC_SYNC_CMD_SVCLASS_ID = 0x1107,
  1665. HEADSET_SVCLASS_ID = 0x1108,
  1666. CORDLESS_TELEPHONY_SVCLASS_ID = 0x1109,
  1667. AUDIO_SOURCE_SVCLASS_ID = 0x110a,
  1668. AUDIO_SINK_SVCLASS_ID = 0x110b,
  1669. AV_REMOTE_TARGET_SVCLASS_ID = 0x110c,
  1670. ADVANCED_AUDIO_SVCLASS_ID = 0x110d,
  1671. AV_REMOTE_SVCLASS_ID = 0x110e,
  1672. VIDEO_CONF_SVCLASS_ID = 0x110f,
  1673. INTERCOM_SVCLASS_ID = 0x1110,
  1674. FAX_SVCLASS_ID = 0x1111,
  1675. HEADSET_AGW_SVCLASS_ID = 0x1112,
  1676. WAP_SVCLASS_ID = 0x1113,
  1677. WAP_CLIENT_SVCLASS_ID = 0x1114,
  1678. PANU_SVCLASS_ID = 0x1115,
  1679. NAP_SVCLASS_ID = 0x1116,
  1680. GN_SVCLASS_ID = 0x1117,
  1681. DIRECT_PRINTING_SVCLASS_ID = 0x1118,
  1682. REFERENCE_PRINTING_SVCLASS_ID = 0x1119,
  1683. IMAGING_SVCLASS_ID = 0x111a,
  1684. IMAGING_RESPONDER_SVCLASS_ID = 0x111b,
  1685. IMAGING_ARCHIVE_SVCLASS_ID = 0x111c,
  1686. IMAGING_REFOBJS_SVCLASS_ID = 0x111d,
  1687. HANDSFREE_SVCLASS_ID = 0x111e,
  1688. HANDSFREE_AGW_SVCLASS_ID = 0x111f,
  1689. DIRECT_PRT_REFOBJS_SVCLASS_ID = 0x1120,
  1690. REFLECTED_UI_SVCLASS_ID = 0x1121,
  1691. BASIC_PRINTING_SVCLASS_ID = 0x1122,
  1692. PRINTING_STATUS_SVCLASS_ID = 0x1123,
  1693. HID_SVCLASS_ID = 0x1124,
  1694. HCR_SVCLASS_ID = 0x1125,
  1695. HCR_PRINT_SVCLASS_ID = 0x1126,
  1696. HCR_SCAN_SVCLASS_ID = 0x1127,
  1697. CIP_SVCLASS_ID = 0x1128,
  1698. VIDEO_CONF_GW_SVCLASS_ID = 0x1129,
  1699. UDI_MT_SVCLASS_ID = 0x112a,
  1700. UDI_TA_SVCLASS_ID = 0x112b,
  1701. AV_SVCLASS_ID = 0x112c,
  1702. SAP_SVCLASS_ID = 0x112d,
  1703. PBAP_PCE_SVCLASS_ID = 0x112e,
  1704. PBAP_PSE_SVCLASS_ID = 0x112f,
  1705. PBAP_SVCLASS_ID = 0x1130,
  1706. PNP_INFO_SVCLASS_ID = 0x1200,
  1707. GENERIC_NETWORKING_SVCLASS_ID = 0x1201,
  1708. GENERIC_FILETRANS_SVCLASS_ID = 0x1202,
  1709. GENERIC_AUDIO_SVCLASS_ID = 0x1203,
  1710. GENERIC_TELEPHONY_SVCLASS_ID = 0x1204,
  1711. UPNP_SVCLASS_ID = 0x1205,
  1712. UPNP_IP_SVCLASS_ID = 0x1206,
  1713. UPNP_PAN_SVCLASS_ID = 0x1300,
  1714. UPNP_LAP_SVCLASS_ID = 0x1301,
  1715. UPNP_L2CAP_SVCLASS_ID = 0x1302,
  1716. VIDEO_SOURCE_SVCLASS_ID = 0x1303,
  1717. VIDEO_SINK_SVCLASS_ID = 0x1304,
  1718. VIDEO_DISTRIBUTION_SVCLASS_ID = 0x1305,
  1719. MDP_SVCLASS_ID = 0x1400,
  1720. MDP_SOURCE_SVCLASS_ID = 0x1401,
  1721. MDP_SINK_SVCLASS_ID = 0x1402,
  1722. APPLE_AGENT_SVCLASS_ID = 0x2112,
  1723. };
  1724. /*
  1725. * Standard profile descriptor identifiers; note these
  1726. * may be identical to some of the service classes defined above
  1727. */
  1728. #define SDP_SERVER_PROFILE_ID SDP_SERVER_SVCLASS_ID
  1729. #define BROWSE_GRP_DESC_PROFILE_ID BROWSE_GRP_DESC_SVCLASS_ID
  1730. #define SERIAL_PORT_PROFILE_ID SERIAL_PORT_SVCLASS_ID
  1731. #define LAN_ACCESS_PROFILE_ID LAN_ACCESS_SVCLASS_ID
  1732. #define DIALUP_NET_PROFILE_ID DIALUP_NET_SVCLASS_ID
  1733. #define IRMC_SYNC_PROFILE_ID IRMC_SYNC_SVCLASS_ID
  1734. #define OBEX_OBJPUSH_PROFILE_ID OBEX_OBJPUSH_SVCLASS_ID
  1735. #define OBEX_FILETRANS_PROFILE_ID OBEX_FILETRANS_SVCLASS_ID
  1736. #define IRMC_SYNC_CMD_PROFILE_ID IRMC_SYNC_CMD_SVCLASS_ID
  1737. #define HEADSET_PROFILE_ID HEADSET_SVCLASS_ID
  1738. #define CORDLESS_TELEPHONY_PROFILE_ID CORDLESS_TELEPHONY_SVCLASS_ID
  1739. #define AUDIO_SOURCE_PROFILE_ID AUDIO_SOURCE_SVCLASS_ID
  1740. #define AUDIO_SINK_PROFILE_ID AUDIO_SINK_SVCLASS_ID
  1741. #define AV_REMOTE_TARGET_PROFILE_ID AV_REMOTE_TARGET_SVCLASS_ID
  1742. #define ADVANCED_AUDIO_PROFILE_ID ADVANCED_AUDIO_SVCLASS_ID
  1743. #define AV_REMOTE_PROFILE_ID AV_REMOTE_SVCLASS_ID
  1744. #define VIDEO_CONF_PROFILE_ID VIDEO_CONF_SVCLASS_ID
  1745. #define INTERCOM_PROFILE_ID INTERCOM_SVCLASS_ID
  1746. #define FAX_PROFILE_ID FAX_SVCLASS_ID
  1747. #define HEADSET_AGW_PROFILE_ID HEADSET_AGW_SVCLASS_ID
  1748. #define WAP_PROFILE_ID WAP_SVCLASS_ID
  1749. #define WAP_CLIENT_PROFILE_ID WAP_CLIENT_SVCLASS_ID
  1750. #define PANU_PROFILE_ID PANU_SVCLASS_ID
  1751. #define NAP_PROFILE_ID NAP_SVCLASS_ID
  1752. #define GN_PROFILE_ID GN_SVCLASS_ID
  1753. #define DIRECT_PRINTING_PROFILE_ID DIRECT_PRINTING_SVCLASS_ID
  1754. #define REFERENCE_PRINTING_PROFILE_ID REFERENCE_PRINTING_SVCLASS_ID
  1755. #define IMAGING_PROFILE_ID IMAGING_SVCLASS_ID
  1756. #define IMAGING_RESPONDER_PROFILE_ID IMAGING_RESPONDER_SVCLASS_ID
  1757. #define IMAGING_ARCHIVE_PROFILE_ID IMAGING_ARCHIVE_SVCLASS_ID
  1758. #define IMAGING_REFOBJS_PROFILE_ID IMAGING_REFOBJS_SVCLASS_ID
  1759. #define HANDSFREE_PROFILE_ID HANDSFREE_SVCLASS_ID
  1760. #define HANDSFREE_AGW_PROFILE_ID HANDSFREE_AGW_SVCLASS_ID
  1761. #define DIRECT_PRT_REFOBJS_PROFILE_ID DIRECT_PRT_REFOBJS_SVCLASS_ID
  1762. #define REFLECTED_UI_PROFILE_ID REFLECTED_UI_SVCLASS_ID
  1763. #define BASIC_PRINTING_PROFILE_ID BASIC_PRINTING_SVCLASS_ID
  1764. #define PRINTING_STATUS_PROFILE_ID PRINTING_STATUS_SVCLASS_ID
  1765. #define HID_PROFILE_ID HID_SVCLASS_ID
  1766. #define HCR_PROFILE_ID HCR_SCAN_SVCLASS_ID
  1767. #define HCR_PRINT_PROFILE_ID HCR_PRINT_SVCLASS_ID
  1768. #define HCR_SCAN_PROFILE_ID HCR_SCAN_SVCLASS_ID
  1769. #define CIP_PROFILE_ID CIP_SVCLASS_ID
  1770. #define VIDEO_CONF_GW_PROFILE_ID VIDEO_CONF_GW_SVCLASS_ID
  1771. #define UDI_MT_PROFILE_ID UDI_MT_SVCLASS_ID
  1772. #define UDI_TA_PROFILE_ID UDI_TA_SVCLASS_ID
  1773. #define AV_PROFILE_ID AV_SVCLASS_ID
  1774. #define SAP_PROFILE_ID SAP_SVCLASS_ID
  1775. #define PBAP_PCE_PROFILE_ID PBAP_PCE_SVCLASS_ID
  1776. #define PBAP_PSE_PROFILE_ID PBAP_PSE_SVCLASS_ID
  1777. #define PBAP_PROFILE_ID PBAP_SVCLASS_ID
  1778. #define PNP_INFO_PROFILE_ID PNP_INFO_SVCLASS_ID
  1779. #define GENERIC_NETWORKING_PROFILE_ID GENERIC_NETWORKING_SVCLASS_ID
  1780. #define GENERIC_FILETRANS_PROFILE_ID GENERIC_FILETRANS_SVCLASS_ID
  1781. #define GENERIC_AUDIO_PROFILE_ID GENERIC_AUDIO_SVCLASS_ID
  1782. #define GENERIC_TELEPHONY_PROFILE_ID GENERIC_TELEPHONY_SVCLASS_ID
  1783. #define UPNP_PROFILE_ID UPNP_SVCLASS_ID
  1784. #define UPNP_IP_PROFILE_ID UPNP_IP_SVCLASS_ID
  1785. #define UPNP_PAN_PROFILE_ID UPNP_PAN_SVCLASS_ID
  1786. #define UPNP_LAP_PROFILE_ID UPNP_LAP_SVCLASS_ID
  1787. #define UPNP_L2CAP_PROFILE_ID UPNP_L2CAP_SVCLASS_ID
  1788. #define VIDEO_SOURCE_PROFILE_ID VIDEO_SOURCE_SVCLASS_ID
  1789. #define VIDEO_SINK_PROFILE_ID VIDEO_SINK_SVCLASS_ID
  1790. #define VIDEO_DISTRIBUTION_PROFILE_ID VIDEO_DISTRIBUTION_SVCLASS_ID
  1791. #define MDP_PROFILE_ID MDP_SVCLASS_ID
  1792. #define MDP_SOURCE_PROFILE_ID MDP_SROUCE_SVCLASS_ID
  1793. #define MDP_SINK_PROFILE_ID MDP_SINK_SVCLASS_ID
  1794. #define APPLE_AGENT_PROFILE_ID APPLE_AGENT_SVCLASS_ID
  1795. /* Data Representation */
  1796. enum bt_sdp_data_type {
  1797. SDP_DTYPE_NIL = 0 << 3,
  1798. SDP_DTYPE_UINT = 1 << 3,
  1799. SDP_DTYPE_SINT = 2 << 3,
  1800. SDP_DTYPE_UUID = 3 << 3,
  1801. SDP_DTYPE_STRING = 4 << 3,
  1802. SDP_DTYPE_BOOL = 5 << 3,
  1803. SDP_DTYPE_SEQ = 6 << 3,
  1804. SDP_DTYPE_ALT = 7 << 3,
  1805. SDP_DTYPE_URL = 8 << 3,
  1806. };
  1807. enum bt_sdp_data_size {
  1808. SDP_DSIZE_1 = 0,
  1809. SDP_DSIZE_2,
  1810. SDP_DSIZE_4,
  1811. SDP_DSIZE_8,
  1812. SDP_DSIZE_16,
  1813. SDP_DSIZE_NEXT1,
  1814. SDP_DSIZE_NEXT2,
  1815. SDP_DSIZE_NEXT4,
  1816. SDP_DSIZE_MASK = SDP_DSIZE_NEXT4,
  1817. };
  1818. enum bt_sdp_cmd {
  1819. SDP_ERROR_RSP = 0x01,
  1820. SDP_SVC_SEARCH_REQ = 0x02,
  1821. SDP_SVC_SEARCH_RSP = 0x03,
  1822. SDP_SVC_ATTR_REQ = 0x04,
  1823. SDP_SVC_ATTR_RSP = 0x05,
  1824. SDP_SVC_SEARCH_ATTR_REQ = 0x06,
  1825. SDP_SVC_SEARCH_ATTR_RSP = 0x07,
  1826. };
  1827. enum bt_sdp_errorcode {
  1828. SDP_INVALID_VERSION = 0x0001,
  1829. SDP_INVALID_RECORD_HANDLE = 0x0002,
  1830. SDP_INVALID_SYNTAX = 0x0003,
  1831. SDP_INVALID_PDU_SIZE = 0x0004,
  1832. SDP_INVALID_CSTATE = 0x0005,
  1833. };
  1834. /*
  1835. * String identifiers are based on the SDP spec stating that
  1836. * "base attribute id of the primary (universal) language must be 0x0100"
  1837. *
  1838. * Other languages should have their own offset; e.g.:
  1839. * #define XXXLangBase yyyy
  1840. * #define AttrServiceName_XXX 0x0000+XXXLangBase
  1841. */
  1842. #define SDP_PRIMARY_LANG_BASE 0x0100
  1843. enum bt_sdp_attribute_id {
  1844. SDP_ATTR_RECORD_HANDLE = 0x0000,
  1845. SDP_ATTR_SVCLASS_ID_LIST = 0x0001,
  1846. SDP_ATTR_RECORD_STATE = 0x0002,
  1847. SDP_ATTR_SERVICE_ID = 0x0003,
  1848. SDP_ATTR_PROTO_DESC_LIST = 0x0004,
  1849. SDP_ATTR_BROWSE_GRP_LIST = 0x0005,
  1850. SDP_ATTR_LANG_BASE_ATTR_ID_LIST = 0x0006,
  1851. SDP_ATTR_SVCINFO_TTL = 0x0007,
  1852. SDP_ATTR_SERVICE_AVAILABILITY = 0x0008,
  1853. SDP_ATTR_PFILE_DESC_LIST = 0x0009,
  1854. SDP_ATTR_DOC_URL = 0x000a,
  1855. SDP_ATTR_CLNT_EXEC_URL = 0x000b,
  1856. SDP_ATTR_ICON_URL = 0x000c,
  1857. SDP_ATTR_ADD_PROTO_DESC_LIST = 0x000d,
  1858. SDP_ATTR_SVCNAME_PRIMARY = SDP_PRIMARY_LANG_BASE + 0,
  1859. SDP_ATTR_SVCDESC_PRIMARY = SDP_PRIMARY_LANG_BASE + 1,
  1860. SDP_ATTR_SVCPROV_PRIMARY = SDP_PRIMARY_LANG_BASE + 2,
  1861. SDP_ATTR_GROUP_ID = 0x0200,
  1862. SDP_ATTR_IP_SUBNET = 0x0200,
  1863. /* SDP */
  1864. SDP_ATTR_VERSION_NUM_LIST = 0x0200,
  1865. SDP_ATTR_SVCDB_STATE = 0x0201,
  1866. SDP_ATTR_SERVICE_VERSION = 0x0300,
  1867. SDP_ATTR_EXTERNAL_NETWORK = 0x0301,
  1868. SDP_ATTR_SUPPORTED_DATA_STORES_LIST = 0x0301,
  1869. SDP_ATTR_FAX_CLASS1_SUPPORT = 0x0302,
  1870. SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL = 0x0302,
  1871. SDP_ATTR_FAX_CLASS20_SUPPORT = 0x0303,
  1872. SDP_ATTR_SUPPORTED_FORMATS_LIST = 0x0303,
  1873. SDP_ATTR_FAX_CLASS2_SUPPORT = 0x0304,
  1874. SDP_ATTR_AUDIO_FEEDBACK_SUPPORT = 0x0305,
  1875. SDP_ATTR_NETWORK_ADDRESS = 0x0306,
  1876. SDP_ATTR_WAP_GATEWAY = 0x0307,
  1877. SDP_ATTR_HOMEPAGE_URL = 0x0308,
  1878. SDP_ATTR_WAP_STACK_TYPE = 0x0309,
  1879. SDP_ATTR_SECURITY_DESC = 0x030a,
  1880. SDP_ATTR_NET_ACCESS_TYPE = 0x030b,
  1881. SDP_ATTR_MAX_NET_ACCESSRATE = 0x030c,
  1882. SDP_ATTR_IP4_SUBNET = 0x030d,
  1883. SDP_ATTR_IP6_SUBNET = 0x030e,
  1884. SDP_ATTR_SUPPORTED_CAPABILITIES = 0x0310,
  1885. SDP_ATTR_SUPPORTED_FEATURES = 0x0311,
  1886. SDP_ATTR_SUPPORTED_FUNCTIONS = 0x0312,
  1887. SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY = 0x0313,
  1888. SDP_ATTR_SUPPORTED_REPOSITORIES = 0x0314,
  1889. /* PnP Information */
  1890. SDP_ATTR_SPECIFICATION_ID = 0x0200,
  1891. SDP_ATTR_VENDOR_ID = 0x0201,
  1892. SDP_ATTR_PRODUCT_ID = 0x0202,
  1893. SDP_ATTR_VERSION = 0x0203,
  1894. SDP_ATTR_PRIMARY_RECORD = 0x0204,
  1895. SDP_ATTR_VENDOR_ID_SOURCE = 0x0205,
  1896. /* BT HID */
  1897. SDP_ATTR_DEVICE_RELEASE_NUMBER = 0x0200,
  1898. SDP_ATTR_PARSER_VERSION = 0x0201,
  1899. SDP_ATTR_DEVICE_SUBCLASS = 0x0202,
  1900. SDP_ATTR_COUNTRY_CODE = 0x0203,
  1901. SDP_ATTR_VIRTUAL_CABLE = 0x0204,
  1902. SDP_ATTR_RECONNECT_INITIATE = 0x0205,
  1903. SDP_ATTR_DESCRIPTOR_LIST = 0x0206,
  1904. SDP_ATTR_LANG_ID_BASE_LIST = 0x0207,
  1905. SDP_ATTR_SDP_DISABLE = 0x0208,
  1906. SDP_ATTR_BATTERY_POWER = 0x0209,
  1907. SDP_ATTR_REMOTE_WAKEUP = 0x020a,
  1908. SDP_ATTR_PROFILE_VERSION = 0x020b,
  1909. SDP_ATTR_SUPERVISION_TIMEOUT = 0x020c,
  1910. SDP_ATTR_NORMALLY_CONNECTABLE = 0x020d,
  1911. SDP_ATTR_BOOT_DEVICE = 0x020e,
  1912. };