capi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /*
  2. CMTP implementation for Linux Bluetooth stack (BlueZ).
  3. Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License version 2 as
  6. published by the Free Software Foundation;
  7. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
  10. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
  11. CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
  12. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
  16. COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
  17. SOFTWARE IS DISCLAIMED.
  18. */
  19. #include <linux/module.h>
  20. #include <linux/proc_fs.h>
  21. #include <linux/seq_file.h>
  22. #include <linux/types.h>
  23. #include <linux/errno.h>
  24. #include <linux/kernel.h>
  25. #include <linux/sched.h>
  26. #include <linux/slab.h>
  27. #include <linux/poll.h>
  28. #include <linux/fcntl.h>
  29. #include <linux/skbuff.h>
  30. #include <linux/socket.h>
  31. #include <linux/ioctl.h>
  32. #include <linux/file.h>
  33. #include <linux/wait.h>
  34. #include <linux/kthread.h>
  35. #include <net/sock.h>
  36. #include <linux/isdn/capilli.h>
  37. #include <linux/isdn/capicmd.h>
  38. #include <linux/isdn/capiutil.h>
  39. #include "cmtp.h"
  40. #define CAPI_INTEROPERABILITY 0x20
  41. #define CAPI_INTEROPERABILITY_REQ CAPICMD(CAPI_INTEROPERABILITY, CAPI_REQ)
  42. #define CAPI_INTEROPERABILITY_CONF CAPICMD(CAPI_INTEROPERABILITY, CAPI_CONF)
  43. #define CAPI_INTEROPERABILITY_IND CAPICMD(CAPI_INTEROPERABILITY, CAPI_IND)
  44. #define CAPI_INTEROPERABILITY_RESP CAPICMD(CAPI_INTEROPERABILITY, CAPI_RESP)
  45. #define CAPI_INTEROPERABILITY_REQ_LEN (CAPI_MSG_BASELEN + 2)
  46. #define CAPI_INTEROPERABILITY_CONF_LEN (CAPI_MSG_BASELEN + 4)
  47. #define CAPI_INTEROPERABILITY_IND_LEN (CAPI_MSG_BASELEN + 2)
  48. #define CAPI_INTEROPERABILITY_RESP_LEN (CAPI_MSG_BASELEN + 2)
  49. #define CAPI_FUNCTION_REGISTER 0
  50. #define CAPI_FUNCTION_RELEASE 1
  51. #define CAPI_FUNCTION_GET_PROFILE 2
  52. #define CAPI_FUNCTION_GET_MANUFACTURER 3
  53. #define CAPI_FUNCTION_GET_VERSION 4
  54. #define CAPI_FUNCTION_GET_SERIAL_NUMBER 5
  55. #define CAPI_FUNCTION_MANUFACTURER 6
  56. #define CAPI_FUNCTION_LOOPBACK 7
  57. #define CMTP_MSGNUM 1
  58. #define CMTP_APPLID 2
  59. #define CMTP_MAPPING 3
  60. static struct cmtp_application *cmtp_application_add(struct cmtp_session *session, __u16 appl)
  61. {
  62. struct cmtp_application *app = kzalloc(sizeof(*app), GFP_KERNEL);
  63. BT_DBG("session %p application %p appl %d", session, app, appl);
  64. if (!app)
  65. return NULL;
  66. app->state = BT_OPEN;
  67. app->appl = appl;
  68. list_add_tail(&app->list, &session->applications);
  69. return app;
  70. }
  71. static void cmtp_application_del(struct cmtp_session *session, struct cmtp_application *app)
  72. {
  73. BT_DBG("session %p application %p", session, app);
  74. if (app) {
  75. list_del(&app->list);
  76. kfree(app);
  77. }
  78. }
  79. static struct cmtp_application *cmtp_application_get(struct cmtp_session *session, int pattern, __u16 value)
  80. {
  81. struct cmtp_application *app;
  82. struct list_head *p, *n;
  83. list_for_each_safe(p, n, &session->applications) {
  84. app = list_entry(p, struct cmtp_application, list);
  85. switch (pattern) {
  86. case CMTP_MSGNUM:
  87. if (app->msgnum == value)
  88. return app;
  89. break;
  90. case CMTP_APPLID:
  91. if (app->appl == value)
  92. return app;
  93. break;
  94. case CMTP_MAPPING:
  95. if (app->mapping == value)
  96. return app;
  97. break;
  98. }
  99. }
  100. return NULL;
  101. }
  102. static int cmtp_msgnum_get(struct cmtp_session *session)
  103. {
  104. session->msgnum++;
  105. if ((session->msgnum & 0xff) > 200)
  106. session->msgnum = CMTP_INITIAL_MSGNUM + 1;
  107. return session->msgnum;
  108. }
  109. static void cmtp_send_capimsg(struct cmtp_session *session, struct sk_buff *skb)
  110. {
  111. struct cmtp_scb *scb = (void *) skb->cb;
  112. BT_DBG("session %p skb %p len %d", session, skb, skb->len);
  113. scb->id = -1;
  114. scb->data = (CAPIMSG_COMMAND(skb->data) == CAPI_DATA_B3);
  115. skb_queue_tail(&session->transmit, skb);
  116. wake_up_interruptible(sk_sleep(session->sock->sk));
  117. }
  118. static void cmtp_send_interopmsg(struct cmtp_session *session,
  119. __u8 subcmd, __u16 appl, __u16 msgnum,
  120. __u16 function, unsigned char *buf, int len)
  121. {
  122. struct sk_buff *skb;
  123. unsigned char *s;
  124. BT_DBG("session %p subcmd 0x%02x appl %d msgnum %d", session, subcmd, appl, msgnum);
  125. skb = alloc_skb(CAPI_MSG_BASELEN + 6 + len, GFP_ATOMIC);
  126. if (!skb) {
  127. BT_ERR("Can't allocate memory for interoperability packet");
  128. return;
  129. }
  130. s = skb_put(skb, CAPI_MSG_BASELEN + 6 + len);
  131. capimsg_setu16(s, 0, CAPI_MSG_BASELEN + 6 + len);
  132. capimsg_setu16(s, 2, appl);
  133. capimsg_setu8 (s, 4, CAPI_INTEROPERABILITY);
  134. capimsg_setu8 (s, 5, subcmd);
  135. capimsg_setu16(s, 6, msgnum);
  136. /* Interoperability selector (Bluetooth Device Management) */
  137. capimsg_setu16(s, 8, 0x0001);
  138. capimsg_setu8 (s, 10, 3 + len);
  139. capimsg_setu16(s, 11, function);
  140. capimsg_setu8 (s, 13, len);
  141. if (len > 0)
  142. memcpy(s + 14, buf, len);
  143. cmtp_send_capimsg(session, skb);
  144. }
  145. static void cmtp_recv_interopmsg(struct cmtp_session *session, struct sk_buff *skb)
  146. {
  147. struct capi_ctr *ctrl = &session->ctrl;
  148. struct cmtp_application *application;
  149. __u16 appl, msgnum, func, info;
  150. __u32 controller;
  151. BT_DBG("session %p skb %p len %d", session, skb, skb->len);
  152. switch (CAPIMSG_SUBCOMMAND(skb->data)) {
  153. case CAPI_CONF:
  154. if (skb->len < CAPI_MSG_BASELEN + 10)
  155. break;
  156. func = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 5);
  157. info = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 8);
  158. switch (func) {
  159. case CAPI_FUNCTION_REGISTER:
  160. msgnum = CAPIMSG_MSGID(skb->data);
  161. application = cmtp_application_get(session, CMTP_MSGNUM, msgnum);
  162. if (application) {
  163. application->state = BT_CONNECTED;
  164. application->msgnum = 0;
  165. application->mapping = CAPIMSG_APPID(skb->data);
  166. wake_up_interruptible(&session->wait);
  167. }
  168. break;
  169. case CAPI_FUNCTION_RELEASE:
  170. appl = CAPIMSG_APPID(skb->data);
  171. application = cmtp_application_get(session, CMTP_MAPPING, appl);
  172. if (application) {
  173. application->state = BT_CLOSED;
  174. application->msgnum = 0;
  175. wake_up_interruptible(&session->wait);
  176. }
  177. break;
  178. case CAPI_FUNCTION_GET_PROFILE:
  179. if (skb->len < CAPI_MSG_BASELEN + 11 + sizeof(capi_profile))
  180. break;
  181. controller = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 11);
  182. msgnum = CAPIMSG_MSGID(skb->data);
  183. if (!info && (msgnum == CMTP_INITIAL_MSGNUM)) {
  184. session->ncontroller = controller;
  185. wake_up_interruptible(&session->wait);
  186. break;
  187. }
  188. if (!info && ctrl) {
  189. memcpy(&ctrl->profile,
  190. skb->data + CAPI_MSG_BASELEN + 11,
  191. sizeof(capi_profile));
  192. session->state = BT_CONNECTED;
  193. capi_ctr_ready(ctrl);
  194. }
  195. break;
  196. case CAPI_FUNCTION_GET_MANUFACTURER:
  197. if (skb->len < CAPI_MSG_BASELEN + 15)
  198. break;
  199. controller = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 10);
  200. if (!info && ctrl) {
  201. int len = min_t(uint, CAPI_MANUFACTURER_LEN,
  202. skb->data[CAPI_MSG_BASELEN + 14]);
  203. memset(ctrl->manu, 0, CAPI_MANUFACTURER_LEN);
  204. strncpy(ctrl->manu,
  205. skb->data + CAPI_MSG_BASELEN + 15, len);
  206. }
  207. break;
  208. case CAPI_FUNCTION_GET_VERSION:
  209. if (skb->len < CAPI_MSG_BASELEN + 32)
  210. break;
  211. controller = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 12);
  212. if (!info && ctrl) {
  213. ctrl->version.majorversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 16);
  214. ctrl->version.minorversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 20);
  215. ctrl->version.majormanuversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 24);
  216. ctrl->version.minormanuversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 28);
  217. }
  218. break;
  219. case CAPI_FUNCTION_GET_SERIAL_NUMBER:
  220. if (skb->len < CAPI_MSG_BASELEN + 17)
  221. break;
  222. controller = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 12);
  223. if (!info && ctrl) {
  224. int len = min_t(uint, CAPI_SERIAL_LEN,
  225. skb->data[CAPI_MSG_BASELEN + 16]);
  226. memset(ctrl->serial, 0, CAPI_SERIAL_LEN);
  227. strncpy(ctrl->serial,
  228. skb->data + CAPI_MSG_BASELEN + 17, len);
  229. }
  230. break;
  231. }
  232. break;
  233. case CAPI_IND:
  234. if (skb->len < CAPI_MSG_BASELEN + 6)
  235. break;
  236. func = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 3);
  237. if (func == CAPI_FUNCTION_LOOPBACK) {
  238. int len = min_t(uint, skb->len - CAPI_MSG_BASELEN - 6,
  239. skb->data[CAPI_MSG_BASELEN + 5]);
  240. appl = CAPIMSG_APPID(skb->data);
  241. msgnum = CAPIMSG_MSGID(skb->data);
  242. cmtp_send_interopmsg(session, CAPI_RESP, appl, msgnum, func,
  243. skb->data + CAPI_MSG_BASELEN + 6, len);
  244. }
  245. break;
  246. }
  247. kfree_skb(skb);
  248. }
  249. void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb)
  250. {
  251. struct capi_ctr *ctrl = &session->ctrl;
  252. struct cmtp_application *application;
  253. __u16 appl;
  254. __u32 contr;
  255. BT_DBG("session %p skb %p len %d", session, skb, skb->len);
  256. if (skb->len < CAPI_MSG_BASELEN)
  257. return;
  258. if (CAPIMSG_COMMAND(skb->data) == CAPI_INTEROPERABILITY) {
  259. cmtp_recv_interopmsg(session, skb);
  260. return;
  261. }
  262. if (session->flags & (1 << CMTP_LOOPBACK)) {
  263. kfree_skb(skb);
  264. return;
  265. }
  266. appl = CAPIMSG_APPID(skb->data);
  267. contr = CAPIMSG_CONTROL(skb->data);
  268. application = cmtp_application_get(session, CMTP_MAPPING, appl);
  269. if (application) {
  270. appl = application->appl;
  271. CAPIMSG_SETAPPID(skb->data, appl);
  272. } else {
  273. BT_ERR("Can't find application with id %d", appl);
  274. kfree_skb(skb);
  275. return;
  276. }
  277. if ((contr & 0x7f) == 0x01) {
  278. contr = (contr & 0xffffff80) | session->num;
  279. CAPIMSG_SETCONTROL(skb->data, contr);
  280. }
  281. if (!ctrl) {
  282. BT_ERR("Can't find controller %d for message", session->num);
  283. kfree_skb(skb);
  284. return;
  285. }
  286. capi_ctr_handle_message(ctrl, appl, skb);
  287. }
  288. static int cmtp_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
  289. {
  290. BT_DBG("ctrl %p data %p", ctrl, data);
  291. return 0;
  292. }
  293. static void cmtp_reset_ctr(struct capi_ctr *ctrl)
  294. {
  295. struct cmtp_session *session = ctrl->driverdata;
  296. BT_DBG("ctrl %p", ctrl);
  297. capi_ctr_down(ctrl);
  298. kthread_stop(session->task);
  299. }
  300. static void cmtp_register_appl(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp)
  301. {
  302. DECLARE_WAITQUEUE(wait, current);
  303. struct cmtp_session *session = ctrl->driverdata;
  304. struct cmtp_application *application;
  305. unsigned long timeo = CMTP_INTEROP_TIMEOUT;
  306. unsigned char buf[8];
  307. int err = 0, nconn, want = rp->level3cnt;
  308. BT_DBG("ctrl %p appl %d level3cnt %d datablkcnt %d datablklen %d",
  309. ctrl, appl, rp->level3cnt, rp->datablkcnt, rp->datablklen);
  310. application = cmtp_application_add(session, appl);
  311. if (!application) {
  312. BT_ERR("Can't allocate memory for new application");
  313. return;
  314. }
  315. if (want < 0)
  316. nconn = ctrl->profile.nbchannel * -want;
  317. else
  318. nconn = want;
  319. if (nconn == 0)
  320. nconn = ctrl->profile.nbchannel;
  321. capimsg_setu16(buf, 0, nconn);
  322. capimsg_setu16(buf, 2, rp->datablkcnt);
  323. capimsg_setu16(buf, 4, rp->datablklen);
  324. application->state = BT_CONFIG;
  325. application->msgnum = cmtp_msgnum_get(session);
  326. cmtp_send_interopmsg(session, CAPI_REQ, 0x0000, application->msgnum,
  327. CAPI_FUNCTION_REGISTER, buf, 6);
  328. add_wait_queue(&session->wait, &wait);
  329. while (1) {
  330. set_current_state(TASK_INTERRUPTIBLE);
  331. if (!timeo) {
  332. err = -EAGAIN;
  333. break;
  334. }
  335. if (application->state == BT_CLOSED) {
  336. err = -application->err;
  337. break;
  338. }
  339. if (application->state == BT_CONNECTED)
  340. break;
  341. if (signal_pending(current)) {
  342. err = -EINTR;
  343. break;
  344. }
  345. timeo = schedule_timeout(timeo);
  346. }
  347. set_current_state(TASK_RUNNING);
  348. remove_wait_queue(&session->wait, &wait);
  349. if (err) {
  350. cmtp_application_del(session, application);
  351. return;
  352. }
  353. }
  354. static void cmtp_release_appl(struct capi_ctr *ctrl, __u16 appl)
  355. {
  356. struct cmtp_session *session = ctrl->driverdata;
  357. struct cmtp_application *application;
  358. BT_DBG("ctrl %p appl %d", ctrl, appl);
  359. application = cmtp_application_get(session, CMTP_APPLID, appl);
  360. if (!application) {
  361. BT_ERR("Can't find application");
  362. return;
  363. }
  364. application->msgnum = cmtp_msgnum_get(session);
  365. cmtp_send_interopmsg(session, CAPI_REQ, application->mapping, application->msgnum,
  366. CAPI_FUNCTION_RELEASE, NULL, 0);
  367. wait_event_interruptible_timeout(session->wait,
  368. (application->state == BT_CLOSED), CMTP_INTEROP_TIMEOUT);
  369. cmtp_application_del(session, application);
  370. }
  371. static u16 cmtp_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
  372. {
  373. struct cmtp_session *session = ctrl->driverdata;
  374. struct cmtp_application *application;
  375. __u16 appl;
  376. __u32 contr;
  377. BT_DBG("ctrl %p skb %p", ctrl, skb);
  378. appl = CAPIMSG_APPID(skb->data);
  379. contr = CAPIMSG_CONTROL(skb->data);
  380. application = cmtp_application_get(session, CMTP_APPLID, appl);
  381. if ((!application) || (application->state != BT_CONNECTED)) {
  382. BT_ERR("Can't find application with id %d", appl);
  383. return CAPI_ILLAPPNR;
  384. }
  385. CAPIMSG_SETAPPID(skb->data, application->mapping);
  386. if ((contr & 0x7f) == session->num) {
  387. contr = (contr & 0xffffff80) | 0x01;
  388. CAPIMSG_SETCONTROL(skb->data, contr);
  389. }
  390. cmtp_send_capimsg(session, skb);
  391. return CAPI_NOERROR;
  392. }
  393. static char *cmtp_procinfo(struct capi_ctr *ctrl)
  394. {
  395. return "CAPI Message Transport Protocol";
  396. }
  397. static int cmtp_proc_show(struct seq_file *m, void *v)
  398. {
  399. struct capi_ctr *ctrl = m->private;
  400. struct cmtp_session *session = ctrl->driverdata;
  401. struct cmtp_application *app;
  402. struct list_head *p, *n;
  403. seq_printf(m, "%s\n\n", cmtp_procinfo(ctrl));
  404. seq_printf(m, "addr %s\n", session->name);
  405. seq_printf(m, "ctrl %d\n", session->num);
  406. list_for_each_safe(p, n, &session->applications) {
  407. app = list_entry(p, struct cmtp_application, list);
  408. seq_printf(m, "appl %d -> %d\n", app->appl, app->mapping);
  409. }
  410. return 0;
  411. }
  412. static int cmtp_proc_open(struct inode *inode, struct file *file)
  413. {
  414. return single_open(file, cmtp_proc_show, PDE(inode)->data);
  415. }
  416. static const struct file_operations cmtp_proc_fops = {
  417. .owner = THIS_MODULE,
  418. .open = cmtp_proc_open,
  419. .read = seq_read,
  420. .llseek = seq_lseek,
  421. .release = single_release,
  422. };
  423. int cmtp_attach_device(struct cmtp_session *session)
  424. {
  425. unsigned char buf[4];
  426. long ret;
  427. BT_DBG("session %p", session);
  428. capimsg_setu32(buf, 0, 0);
  429. cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, CMTP_INITIAL_MSGNUM,
  430. CAPI_FUNCTION_GET_PROFILE, buf, 4);
  431. ret = wait_event_interruptible_timeout(session->wait,
  432. session->ncontroller, CMTP_INTEROP_TIMEOUT);
  433. BT_INFO("Found %d CAPI controller(s) on device %s", session->ncontroller, session->name);
  434. if (!ret)
  435. return -ETIMEDOUT;
  436. if (!session->ncontroller)
  437. return -ENODEV;
  438. if (session->ncontroller > 1)
  439. BT_INFO("Setting up only CAPI controller 1");
  440. session->ctrl.owner = THIS_MODULE;
  441. session->ctrl.driverdata = session;
  442. strcpy(session->ctrl.name, session->name);
  443. session->ctrl.driver_name = "cmtp";
  444. session->ctrl.load_firmware = cmtp_load_firmware;
  445. session->ctrl.reset_ctr = cmtp_reset_ctr;
  446. session->ctrl.register_appl = cmtp_register_appl;
  447. session->ctrl.release_appl = cmtp_release_appl;
  448. session->ctrl.send_message = cmtp_send_message;
  449. session->ctrl.procinfo = cmtp_procinfo;
  450. session->ctrl.proc_fops = &cmtp_proc_fops;
  451. if (attach_capi_ctr(&session->ctrl) < 0) {
  452. BT_ERR("Can't attach new controller");
  453. return -EBUSY;
  454. }
  455. session->num = session->ctrl.cnr;
  456. BT_DBG("session %p num %d", session, session->num);
  457. capimsg_setu32(buf, 0, 1);
  458. cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, cmtp_msgnum_get(session),
  459. CAPI_FUNCTION_GET_MANUFACTURER, buf, 4);
  460. cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, cmtp_msgnum_get(session),
  461. CAPI_FUNCTION_GET_VERSION, buf, 4);
  462. cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, cmtp_msgnum_get(session),
  463. CAPI_FUNCTION_GET_SERIAL_NUMBER, buf, 4);
  464. cmtp_send_interopmsg(session, CAPI_REQ, 0xffff, cmtp_msgnum_get(session),
  465. CAPI_FUNCTION_GET_PROFILE, buf, 4);
  466. return 0;
  467. }
  468. void cmtp_detach_device(struct cmtp_session *session)
  469. {
  470. BT_DBG("session %p", session);
  471. detach_capi_ctr(&session->ctrl);
  472. }