bt.h 59 KB

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