test-avdtp.c 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2012 Intel Corporation. All rights reserved.
  7. *
  8. *
  9. */
  10. #ifdef HAVE_CONFIG_H
  11. #include <config.h>
  12. #endif
  13. #include <unistd.h>
  14. #include <stdlib.h>
  15. #include <stdbool.h>
  16. #include <inttypes.h>
  17. #include <string.h>
  18. #include <fcntl.h>
  19. #include <sys/socket.h>
  20. #include <glib.h>
  21. #include "src/shared/util.h"
  22. #include "src/shared/queue.h"
  23. #include "src/shared/tester.h"
  24. #include "src/log.h"
  25. #include "android/avdtp.h"
  26. #define MAX_SEID 0x3E
  27. struct test_pdu {
  28. bool valid;
  29. bool fragmented;
  30. uint8_t *data;
  31. size_t size;
  32. };
  33. struct test_data {
  34. char *test_name;
  35. struct test_pdu *pdu_list;
  36. };
  37. #define data(args...) ((const unsigned char[]) { args })
  38. #define raw_pdu(args...) \
  39. { \
  40. .valid = true, \
  41. .data = g_memdup(data(args), sizeof(data(args))), \
  42. .size = sizeof(data(args)), \
  43. }
  44. #define frg_pdu(args...) \
  45. { \
  46. .valid = true, \
  47. .fragmented = true, \
  48. .data = g_memdup(data(args), sizeof(data(args))), \
  49. .size = sizeof(data(args)), \
  50. }
  51. #define define_test(name, function, args...) \
  52. do { \
  53. const struct test_pdu pdus[] = { \
  54. args, { } \
  55. }; \
  56. static struct test_data data; \
  57. data.test_name = g_strdup(name); \
  58. data.pdu_list = g_memdup(pdus, sizeof(pdus)); \
  59. tester_add(name, &data, NULL, function, NULL); \
  60. } while (0)
  61. struct context {
  62. struct avdtp *session;
  63. struct avdtp_local_sep *sep;
  64. struct avdtp_stream *stream;
  65. struct queue *lseps;
  66. guint source;
  67. guint process;
  68. int fd;
  69. int mtu;
  70. gboolean pending_open;
  71. gboolean pending_suspend;
  72. unsigned int pdu_offset;
  73. const struct test_data *data;
  74. };
  75. static void test_free(gconstpointer user_data)
  76. {
  77. const struct test_data *data = user_data;
  78. struct test_pdu *pdu;
  79. int i;
  80. for (i = 0; (pdu = &data->pdu_list[i]) && pdu->valid; i++)
  81. g_free(pdu->data);
  82. g_free(data->test_name);
  83. g_free(data->pdu_list);
  84. }
  85. static void unregister_sep(void *data)
  86. {
  87. struct avdtp_local_sep *sep = data;
  88. /* Removed from the queue by caller */
  89. avdtp_unregister_sep(NULL, sep);
  90. }
  91. static void destroy_context(struct context *context)
  92. {
  93. if (context->source > 0)
  94. g_source_remove(context->source);
  95. avdtp_unref(context->session);
  96. test_free(context->data);
  97. queue_destroy(context->lseps, unregister_sep);
  98. g_free(context);
  99. }
  100. static gboolean context_quit(gpointer user_data)
  101. {
  102. struct context *context = user_data;
  103. if (context->process > 0)
  104. g_source_remove(context->process);
  105. destroy_context(context);
  106. tester_test_passed();
  107. return FALSE;
  108. }
  109. static gboolean send_pdu(gpointer user_data)
  110. {
  111. struct context *context = user_data;
  112. const struct test_pdu *pdu;
  113. ssize_t len;
  114. pdu = &context->data->pdu_list[context->pdu_offset++];
  115. len = write(context->fd, pdu->data, pdu->size);
  116. tester_monitor('<', 0x0000, 0x0019, pdu->data, len);
  117. g_assert_cmpint(len, ==, pdu->size);
  118. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-02-C"))
  119. g_timeout_add_seconds(1, context_quit, context);
  120. if (pdu->fragmented)
  121. return send_pdu(user_data);
  122. context->process = 0;
  123. return FALSE;
  124. }
  125. static void context_process(struct context *context)
  126. {
  127. if (!context->data->pdu_list[context->pdu_offset].valid) {
  128. context_quit(context);
  129. return;
  130. }
  131. context->process = g_idle_add(send_pdu, context);
  132. }
  133. static gboolean transport_open(struct avdtp_stream *stream)
  134. {
  135. int fd;
  136. fd = open("/dev/null", O_RDWR, 0);
  137. if (fd < 0)
  138. g_assert_not_reached();
  139. return avdtp_stream_set_transport(stream, fd, 672, 672);
  140. }
  141. static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
  142. gpointer user_data)
  143. {
  144. struct context *context = user_data;
  145. const struct test_pdu *pdu;
  146. unsigned char buf[512];
  147. ssize_t len;
  148. int fd;
  149. pdu = &context->data->pdu_list[context->pdu_offset++];
  150. if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
  151. context->source = 0;
  152. return FALSE;
  153. }
  154. fd = g_io_channel_unix_get_fd(channel);
  155. len = read(fd, buf, sizeof(buf));
  156. g_assert(len > 0);
  157. tester_monitor('>', 0x0000, 0x0019, buf, len);
  158. g_assert_cmpint(len, ==, pdu->size);
  159. g_assert(memcmp(buf, pdu->data, pdu->size) == 0);
  160. if (context->pending_open) {
  161. context->pending_open = FALSE;
  162. g_assert(transport_open(context->stream));
  163. }
  164. if (context->pending_suspend) {
  165. int ret;
  166. context->pending_suspend = FALSE;
  167. ret = avdtp_suspend(context->session, context->stream);
  168. g_assert_cmpint(ret, ==, 0);
  169. }
  170. if (!pdu->fragmented)
  171. context_process(context);
  172. return TRUE;
  173. }
  174. static struct context *context_new(uint16_t version, uint16_t imtu,
  175. uint16_t omtu, gconstpointer data)
  176. {
  177. struct context *context = g_new0(struct context, 1);
  178. GIOChannel *channel;
  179. int err, sv[2];
  180. err = socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sv);
  181. g_assert(err == 0);
  182. context->lseps = queue_new();
  183. g_assert(context->lseps);
  184. context->session = avdtp_new(sv[0], imtu, omtu, version,
  185. context->lseps);
  186. g_assert(context->session != NULL);
  187. channel = g_io_channel_unix_new(sv[1]);
  188. g_io_channel_set_close_on_unref(channel, TRUE);
  189. g_io_channel_set_encoding(channel, NULL, NULL);
  190. g_io_channel_set_buffered(channel, FALSE);
  191. context->source = g_io_add_watch(channel,
  192. G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
  193. test_handler, context);
  194. g_assert(context->source > 0);
  195. g_io_channel_unref(channel);
  196. context->fd = sv[1];
  197. context->data = data;
  198. return context;
  199. }
  200. static struct context *create_context(uint16_t version, gconstpointer data)
  201. {
  202. return context_new(version, 672, 672, data);
  203. }
  204. static gboolean sep_getcap_ind(struct avdtp *session,
  205. struct avdtp_local_sep *sep,
  206. GSList **caps, uint8_t *err,
  207. void *user_data)
  208. {
  209. struct avdtp_service_capability *media_transport, *media_codec;
  210. struct avdtp_media_codec_capability *codec_caps;
  211. uint8_t cap[4] = { 0xff, 0xff, 2, 64 };
  212. *caps = NULL;
  213. media_transport = avdtp_service_cap_new(AVDTP_MEDIA_TRANSPORT,
  214. NULL, 0);
  215. *caps = g_slist_append(*caps, media_transport);
  216. codec_caps = g_malloc0(sizeof(*codec_caps) + sizeof(cap));
  217. codec_caps->media_type = AVDTP_MEDIA_TYPE_AUDIO;
  218. codec_caps->media_codec_type = 0x00;
  219. memcpy(codec_caps->data, cap, sizeof(cap));
  220. media_codec = avdtp_service_cap_new(AVDTP_MEDIA_CODEC, codec_caps,
  221. sizeof(*codec_caps) + sizeof(cap));
  222. *caps = g_slist_append(*caps, media_codec);
  223. g_free(codec_caps);
  224. return TRUE;
  225. }
  226. static gboolean sep_open_ind(struct avdtp *session, struct avdtp_local_sep *sep,
  227. struct avdtp_stream *stream, uint8_t *err,
  228. void *user_data)
  229. {
  230. struct context *context = user_data;
  231. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-18-C")) {
  232. *err = 0xc0;
  233. return FALSE;
  234. }
  235. context->pending_open = TRUE;
  236. context->stream = stream;
  237. return TRUE;
  238. }
  239. static gboolean sep_setconf_ind(struct avdtp *session,
  240. struct avdtp_local_sep *sep,
  241. struct avdtp_stream *stream,
  242. GSList *caps,
  243. avdtp_set_configuration_cb cb,
  244. void *user_data)
  245. {
  246. struct context *context = user_data;
  247. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-09-C"))
  248. return FALSE;
  249. cb(session, stream, NULL);
  250. return TRUE;
  251. }
  252. static gboolean sep_start_ind(struct avdtp *session,
  253. struct avdtp_local_sep *sep,
  254. struct avdtp_stream *stream,
  255. uint8_t *err,
  256. void *user_data)
  257. {
  258. struct context *context = user_data;
  259. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-21-C")) {
  260. *err = 0xc0;
  261. return FALSE;
  262. }
  263. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-25-C"))
  264. context->pending_suspend = TRUE;
  265. return TRUE;
  266. }
  267. static gboolean sep_close_ind(struct avdtp *session,
  268. struct avdtp_local_sep *sep,
  269. struct avdtp_stream *stream,
  270. uint8_t *err,
  271. void *user_data)
  272. {
  273. struct context *context = user_data;
  274. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-24-C")) {
  275. *err = 0xc0;
  276. return FALSE;
  277. }
  278. return TRUE;
  279. }
  280. static gboolean sep_suspend_ind(struct avdtp *session,
  281. struct avdtp_local_sep *sep,
  282. struct avdtp_stream *stream,
  283. uint8_t *err,
  284. void *user_data)
  285. {
  286. struct context *context = user_data;
  287. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-27-C")) {
  288. *err = 0xc0;
  289. return FALSE;
  290. }
  291. return TRUE;
  292. }
  293. static struct avdtp_sep_ind sep_ind = {
  294. .get_capability = sep_getcap_ind,
  295. .set_configuration = sep_setconf_ind,
  296. .open = sep_open_ind,
  297. .close = sep_close_ind,
  298. .start = sep_start_ind,
  299. .suspend = sep_suspend_ind,
  300. };
  301. static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
  302. struct avdtp_stream *stream,
  303. struct avdtp_error *err, void *user_data)
  304. {
  305. struct context *context = user_data;
  306. int ret;
  307. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-09-C")) {
  308. context_quit(context);
  309. return;
  310. }
  311. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-07-C")) {
  312. g_assert(err != NULL);
  313. g_assert_cmpint(avdtp_error_error_code(err), ==, 0x13);
  314. context_quit(context);
  315. return;
  316. }
  317. g_assert(err == NULL);
  318. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-11-C") ||
  319. g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-10-C"))
  320. ret = avdtp_get_configuration(session, stream);
  321. else if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-23-C"))
  322. ret = avdtp_abort(session, stream);
  323. else
  324. ret = avdtp_open(session, stream);
  325. g_assert_cmpint(ret, ==, 0);
  326. }
  327. static void sep_getconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
  328. struct avdtp_stream *stream,
  329. struct avdtp_error *err, void *user_data)
  330. {
  331. struct context *context = user_data;
  332. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-10-C")) {
  333. g_assert(err != NULL);
  334. g_assert_cmpint(avdtp_error_error_code(err), ==, 0x12);
  335. } else
  336. g_assert(err == NULL);
  337. context_quit(context);
  338. }
  339. static void sep_open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
  340. struct avdtp_stream *stream, struct avdtp_error *err,
  341. void *user_data)
  342. {
  343. int ret;
  344. g_assert(err == NULL);
  345. g_assert(transport_open(stream));
  346. ret = avdtp_start(session, stream);
  347. g_assert_cmpint(ret, ==, 0);
  348. }
  349. static void sep_start_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
  350. struct avdtp_stream *stream, struct avdtp_error *err,
  351. void *user_data)
  352. {
  353. struct context *context = user_data;
  354. int ret;
  355. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-19-C") ||
  356. g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-22-C")) {
  357. g_assert(err != NULL);
  358. g_assert_cmpint(avdtp_error_error_code(err), ==, 0x31);
  359. context_quit(context);
  360. return;
  361. }
  362. g_assert(err == NULL);
  363. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-19-C"))
  364. ret = avdtp_close(session, stream, FALSE);
  365. else
  366. ret = avdtp_suspend(session, stream);
  367. g_assert_cmpint(ret, ==, 0);
  368. }
  369. static void sep_suspend_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
  370. struct avdtp_stream *stream, struct avdtp_error *err,
  371. void *user_data)
  372. {
  373. struct context *context = user_data;
  374. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-25-C")) {
  375. g_assert(err != NULL);
  376. g_assert_cmpint(avdtp_error_error_code(err), ==, 0x31);
  377. context_quit(context);
  378. }
  379. }
  380. static struct avdtp_sep_cfm sep_cfm = {
  381. .set_configuration = sep_setconf_cfm,
  382. .get_configuration = sep_getconf_cfm,
  383. .open = sep_open_cfm,
  384. .start = sep_start_cfm,
  385. .suspend = sep_suspend_cfm,
  386. };
  387. static void test_server(gconstpointer data)
  388. {
  389. struct context *context = create_context(0x0100, data);
  390. struct avdtp_local_sep *sep;
  391. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SOURCE,
  392. AVDTP_MEDIA_TYPE_AUDIO,
  393. 0x00, FALSE, &sep_ind, &sep_cfm,
  394. context);
  395. g_assert(sep);
  396. g_idle_add(send_pdu, context);
  397. }
  398. static void test_server_1_3(gconstpointer data)
  399. {
  400. struct context *context = create_context(0x0103, data);
  401. struct avdtp_local_sep *sep;
  402. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SOURCE,
  403. AVDTP_MEDIA_TYPE_AUDIO,
  404. 0x00, TRUE, &sep_ind, NULL, context);
  405. g_assert(sep);
  406. g_idle_add(send_pdu, context);
  407. }
  408. static void test_server_1_3_sink(gconstpointer data)
  409. {
  410. struct context *context = create_context(0x0103, data);
  411. struct avdtp_local_sep *sep;
  412. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SINK,
  413. AVDTP_MEDIA_TYPE_AUDIO,
  414. 0x00, TRUE, &sep_ind, NULL, context);
  415. g_assert(sep);
  416. g_idle_add(send_pdu, context);
  417. }
  418. static void test_server_0_sep(gconstpointer data)
  419. {
  420. struct context *context = create_context(0x0100, data);
  421. g_idle_add(send_pdu, context);
  422. }
  423. static void test_server_seid(gconstpointer data)
  424. {
  425. struct context *context = create_context(0x0103, data);
  426. struct avdtp_local_sep *sep;
  427. unsigned int i;
  428. for (i = 0; i < MAX_SEID; i++) {
  429. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SINK,
  430. AVDTP_MEDIA_TYPE_AUDIO,
  431. 0x00, TRUE, &sep_ind, NULL,
  432. context);
  433. g_assert(sep);
  434. }
  435. /* Now add (MAX_SEID + 1) SEP -> it shall fail */
  436. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SINK,
  437. AVDTP_MEDIA_TYPE_AUDIO,
  438. 0x00, TRUE, &sep_ind, NULL,
  439. context);
  440. g_assert(!sep);
  441. context_quit(context);
  442. }
  443. static void test_server_seid_duplicate(gconstpointer data)
  444. {
  445. struct context *context = create_context(0x0103, data);
  446. struct avdtp_local_sep *sep;
  447. int i;
  448. for (i = 0; i < 2; i++) {
  449. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SINK,
  450. AVDTP_MEDIA_TYPE_AUDIO,
  451. 0x00, TRUE, &sep_ind, NULL,
  452. context);
  453. g_assert(sep);
  454. }
  455. /* Remove 1st element */
  456. sep = queue_peek_head(context->lseps);
  457. g_assert(sep);
  458. avdtp_unregister_sep(context->lseps, sep);
  459. /* Now register new element */
  460. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SINK,
  461. AVDTP_MEDIA_TYPE_AUDIO,
  462. 0x00, TRUE, &sep_ind, NULL,
  463. context);
  464. g_assert(sep);
  465. /* Check SEID ids with DISCOVER */
  466. g_idle_add(send_pdu, context);
  467. }
  468. static gboolean sep_getcap_ind_frg(struct avdtp *session,
  469. struct avdtp_local_sep *sep,
  470. GSList **caps, uint8_t *err,
  471. void *user_data)
  472. {
  473. struct avdtp_service_capability *media_transport, *media_codec;
  474. struct avdtp_service_capability *content_protection;
  475. struct avdtp_media_codec_capability *codec_caps;
  476. uint8_t cap[4] = { 0xff, 0xff, 2, 64 };
  477. uint8_t frg_cap[96] = {};
  478. *caps = NULL;
  479. media_transport = avdtp_service_cap_new(AVDTP_MEDIA_TRANSPORT,
  480. NULL, 0);
  481. *caps = g_slist_append(*caps, media_transport);
  482. codec_caps = g_malloc0(sizeof(*codec_caps) + sizeof(cap));
  483. codec_caps->media_type = AVDTP_MEDIA_TYPE_AUDIO;
  484. codec_caps->media_codec_type = 0x00;
  485. memcpy(codec_caps->data, cap, sizeof(cap));
  486. media_codec = avdtp_service_cap_new(AVDTP_MEDIA_CODEC, codec_caps,
  487. sizeof(*codec_caps) + sizeof(cap));
  488. *caps = g_slist_append(*caps, media_codec);
  489. g_free(codec_caps);
  490. content_protection = avdtp_service_cap_new(AVDTP_CONTENT_PROTECTION,
  491. frg_cap, sizeof(frg_cap));
  492. *caps = g_slist_append(*caps, content_protection);
  493. return TRUE;
  494. }
  495. static struct avdtp_sep_ind sep_ind_frg = {
  496. .get_capability = sep_getcap_ind_frg,
  497. };
  498. static void test_server_frg(gconstpointer data)
  499. {
  500. struct context *context = context_new(0x0100, 48, 48, data);
  501. struct avdtp_local_sep *sep;
  502. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SOURCE,
  503. AVDTP_MEDIA_TYPE_AUDIO,
  504. 0x00, TRUE, &sep_ind_frg,
  505. NULL, context);
  506. g_assert(sep);
  507. g_idle_add(send_pdu, context);
  508. }
  509. static void discover_cb(struct avdtp *session, GSList *seps,
  510. struct avdtp_error *err, void *user_data)
  511. {
  512. struct context *context = user_data;
  513. struct avdtp_stream *stream;
  514. struct avdtp_remote_sep *rsep;
  515. struct avdtp_service_capability *media_transport, *media_codec;
  516. struct avdtp_media_codec_capability *cap;
  517. GSList *caps;
  518. uint8_t data[4] = { 0x21, 0x02, 2, 32 };
  519. int ret;
  520. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-05-C") ||
  521. g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-07-C") ||
  522. g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-25-C"))
  523. return;
  524. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-01-C")) {
  525. g_assert(err != NULL);
  526. g_assert_cmpint(avdtp_error_error_code(err), ==, 0x01);
  527. context_quit(context);
  528. return;
  529. }
  530. if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-04-C") ||
  531. g_str_equal(context->data->test_name, "/TP/SIG/SMG/BI-32-C")) {
  532. g_assert(err != NULL);
  533. g_assert_cmpint(avdtp_error_error_code(err), ==, 0x11);
  534. context_quit(context);
  535. return;
  536. }
  537. g_assert(err == NULL);
  538. g_assert_cmpint(g_slist_length(seps), !=, 0);
  539. if (g_str_equal(context->data->test_name, "/TP/SIG/FRA/BV-02-C")) {
  540. g_assert(err == NULL);
  541. context_quit(context);
  542. return;
  543. }
  544. rsep = avdtp_find_remote_sep(session, context->sep);
  545. g_assert(rsep != NULL);
  546. media_transport = avdtp_service_cap_new(AVDTP_MEDIA_TRANSPORT,
  547. NULL, 0);
  548. caps = g_slist_append(NULL, media_transport);
  549. cap = g_malloc0(sizeof(*cap) + sizeof(data));
  550. cap->media_type = AVDTP_MEDIA_TYPE_AUDIO;
  551. cap->media_codec_type = 0x00;
  552. memcpy(cap->data, data, sizeof(data));
  553. media_codec = avdtp_service_cap_new(AVDTP_MEDIA_CODEC, cap,
  554. sizeof(*cap) + sizeof(data));
  555. caps = g_slist_append(caps, media_codec);
  556. g_free(cap);
  557. ret = avdtp_set_configuration(session, rsep, context->sep, caps,
  558. &stream);
  559. g_assert_cmpint(ret, ==, 0);
  560. g_slist_free_full(caps, g_free);
  561. }
  562. static void test_client(gconstpointer data)
  563. {
  564. struct context *context = create_context(0x0100, data);
  565. struct avdtp_local_sep *sep;
  566. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SINK,
  567. AVDTP_MEDIA_TYPE_AUDIO,
  568. 0x00, FALSE, NULL, &sep_cfm, context);
  569. context->sep = sep;
  570. avdtp_discover(context->session, discover_cb, context);
  571. }
  572. static void test_client_1_3(gconstpointer data)
  573. {
  574. struct context *context = create_context(0x0103, data);
  575. struct avdtp_local_sep *sep;
  576. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SINK,
  577. AVDTP_MEDIA_TYPE_AUDIO,
  578. 0x00, TRUE, NULL, &sep_cfm, context);
  579. context->sep = sep;
  580. avdtp_discover(context->session, discover_cb, context);
  581. }
  582. static void test_client_frg(gconstpointer data)
  583. {
  584. struct context *context = context_new(0x0100, 48, 48, data);
  585. struct avdtp_local_sep *sep;
  586. sep = avdtp_register_sep(context->lseps, AVDTP_SEP_TYPE_SINK,
  587. AVDTP_MEDIA_TYPE_AUDIO,
  588. 0x00, TRUE, NULL, &sep_cfm, context);
  589. context->sep = sep;
  590. avdtp_discover(context->session, discover_cb, context);
  591. }
  592. int main(int argc, char *argv[])
  593. {
  594. tester_init(&argc, &argv);
  595. __btd_log_init("*", 0);
  596. /*
  597. * Stream Management Service
  598. *
  599. * To verify that the following procedures are implemented according to
  600. * their specification in AVDTP.
  601. */
  602. define_test("/TP/SIG/SMG/BV-06-C-SEID-1", test_server_seid,
  603. raw_pdu(0x00));
  604. define_test("/TP/SIG/SMG/BV-06-C-SEID-2", test_server_seid_duplicate,
  605. raw_pdu(0x00, 0x01),
  606. raw_pdu(0x02, 0x01, 0x08, 0x08, 0x04, 0x08));
  607. define_test("/TP/SIG/SMG/BV-05-C", test_client,
  608. raw_pdu(0x00, 0x01));
  609. define_test("/TP/SIG/SMG/BV-06-C", test_server,
  610. raw_pdu(0x00, 0x01),
  611. raw_pdu(0x02, 0x01, 0x04, 0x00));
  612. define_test("/TP/SIG/SMG/BV-07-C", test_client,
  613. raw_pdu(0x10, 0x01),
  614. raw_pdu(0x12, 0x01, 0x04, 0x00),
  615. raw_pdu(0x20, 0x02, 0x04));
  616. define_test("/TP/SIG/SMG/BV-08-C", test_server,
  617. raw_pdu(0x00, 0x01),
  618. raw_pdu(0x02, 0x01, 0x04, 0x00),
  619. raw_pdu(0x10, 0x02, 0x04),
  620. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  621. 0xff, 0xff, 0x02, 0x40));
  622. define_test("/TP/SIG/SMG/BV-09-C", test_client,
  623. raw_pdu(0x30, 0x01),
  624. raw_pdu(0x32, 0x01, 0x04, 0x00),
  625. raw_pdu(0x40, 0x02, 0x04),
  626. raw_pdu(0x42, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  627. 0xff, 0xff, 0x02, 0x40),
  628. raw_pdu(0x50, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  629. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  630. raw_pdu(0x52, 0x03));
  631. define_test("/TP/SIG/SMG/BV-10-C", test_server,
  632. raw_pdu(0x00, 0x01),
  633. raw_pdu(0x02, 0x01, 0x04, 0x00),
  634. raw_pdu(0x10, 0x02, 0x04),
  635. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  636. 0xff, 0xff, 0x02, 0x40),
  637. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  638. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  639. raw_pdu(0x22, 0x03));
  640. define_test("/TP/SIG/SMG/BV-11-C", test_client,
  641. raw_pdu(0x60, 0x01),
  642. raw_pdu(0x62, 0x01, 0x04, 0x00),
  643. raw_pdu(0x70, 0x02, 0x04),
  644. raw_pdu(0x72, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  645. 0xff, 0xff, 0x02, 0x40),
  646. raw_pdu(0x80, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  647. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  648. raw_pdu(0x82, 0x03),
  649. raw_pdu(0x90, 0x04, 0x04));
  650. define_test("/TP/SIG/SMG/BV-12-C", test_server,
  651. raw_pdu(0x00, 0x01),
  652. raw_pdu(0x02, 0x01, 0x04, 0x00),
  653. raw_pdu(0x10, 0x02, 0x04),
  654. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  655. 0xff, 0xff, 0x02, 0x40),
  656. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  657. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  658. raw_pdu(0x22, 0x03),
  659. raw_pdu(0x30, 0x04, 0x04),
  660. raw_pdu(0x32, 0x04, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  661. 0x21, 0x02, 0x02, 0x20));
  662. define_test("/TP/SIG/SMG/BV-15-C", test_client,
  663. raw_pdu(0xa0, 0x01),
  664. raw_pdu(0xa2, 0x01, 0x04, 0x00),
  665. raw_pdu(0xb0, 0x02, 0x04),
  666. raw_pdu(0xb2, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  667. 0xff, 0xff, 0x02, 0x40),
  668. raw_pdu(0xc0, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  669. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  670. raw_pdu(0xc2, 0x03),
  671. raw_pdu(0xd0, 0x06, 0x04));
  672. define_test("/TP/SIG/SMG/BV-16-C", test_server,
  673. raw_pdu(0x00, 0x01),
  674. raw_pdu(0x02, 0x01, 0x04, 0x00),
  675. raw_pdu(0x10, 0x02, 0x04),
  676. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  677. 0xff, 0xff, 0x02, 0x40),
  678. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  679. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  680. raw_pdu(0x22, 0x03),
  681. raw_pdu(0x30, 0x06, 0x04),
  682. raw_pdu(0x32, 0x06));
  683. define_test("/TP/SIG/SMG/BV-17-C", test_client,
  684. raw_pdu(0xe0, 0x01),
  685. raw_pdu(0xe2, 0x01, 0x04, 0x00),
  686. raw_pdu(0xf0, 0x02, 0x04),
  687. raw_pdu(0xf2, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  688. 0xff, 0xff, 0x02, 0x40),
  689. raw_pdu(0x00, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  690. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  691. raw_pdu(0x02, 0x03),
  692. raw_pdu(0x10, 0x06, 0x04),
  693. raw_pdu(0x12, 0x06),
  694. raw_pdu(0x20, 0x07, 0x04));
  695. define_test("/TP/SIG/SMG/BV-18-C", test_server,
  696. raw_pdu(0x00, 0x01),
  697. raw_pdu(0x02, 0x01, 0x04, 0x00),
  698. raw_pdu(0x10, 0x02, 0x04),
  699. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  700. 0xff, 0xff, 0x02, 0x40),
  701. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  702. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  703. raw_pdu(0x22, 0x03),
  704. raw_pdu(0x30, 0x06, 0x04),
  705. raw_pdu(0x32, 0x06),
  706. raw_pdu(0x40, 0x07, 0x04),
  707. raw_pdu(0x42, 0x07));
  708. define_test("/TP/SIG/SMG/BV-19-C", test_client,
  709. raw_pdu(0x30, 0x01),
  710. raw_pdu(0x32, 0x01, 0x04, 0x00),
  711. raw_pdu(0x40, 0x02, 0x04),
  712. raw_pdu(0x42, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  713. 0xff, 0xff, 0x02, 0x40),
  714. raw_pdu(0x50, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  715. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  716. raw_pdu(0x52, 0x03),
  717. raw_pdu(0x60, 0x06, 0x04),
  718. raw_pdu(0x62, 0x06),
  719. raw_pdu(0x70, 0x07, 0x04),
  720. raw_pdu(0x72, 0x07),
  721. raw_pdu(0x80, 0x08, 0x04));
  722. define_test("/TP/SIG/SMG/BV-20-C", test_server,
  723. raw_pdu(0x00, 0x01),
  724. raw_pdu(0x02, 0x01, 0x04, 0x00),
  725. raw_pdu(0x10, 0x02, 0x04),
  726. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  727. 0xff, 0xff, 0x02, 0x40),
  728. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  729. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  730. raw_pdu(0x22, 0x03),
  731. raw_pdu(0x30, 0x06, 0x04),
  732. raw_pdu(0x32, 0x06),
  733. raw_pdu(0x40, 0x07, 0x04),
  734. raw_pdu(0x42, 0x07),
  735. raw_pdu(0x50, 0x08, 0x04),
  736. raw_pdu(0x52, 0x08));
  737. define_test("/TP/SIG/SMG/BV-21-C", test_client,
  738. raw_pdu(0x90, 0x01),
  739. raw_pdu(0x92, 0x01, 0x04, 0x00),
  740. raw_pdu(0xa0, 0x02, 0x04),
  741. raw_pdu(0xa2, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  742. 0xff, 0xff, 0x02, 0x40),
  743. raw_pdu(0xb0, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  744. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  745. raw_pdu(0xb2, 0x03),
  746. raw_pdu(0xc0, 0x06, 0x04),
  747. raw_pdu(0xc2, 0x06),
  748. raw_pdu(0xd0, 0x07, 0x04),
  749. raw_pdu(0xd2, 0x07),
  750. raw_pdu(0xe0, 0x09, 0x04));
  751. define_test("/TP/SIG/SMG/BV-22-C", test_server,
  752. raw_pdu(0x00, 0x01),
  753. raw_pdu(0x02, 0x01, 0x04, 0x00),
  754. raw_pdu(0x10, 0x02, 0x04),
  755. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  756. 0xff, 0xff, 0x02, 0x40),
  757. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  758. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  759. raw_pdu(0x22, 0x03),
  760. raw_pdu(0x30, 0x06, 0x04),
  761. raw_pdu(0x32, 0x06),
  762. raw_pdu(0x40, 0x07, 0x04),
  763. raw_pdu(0x42, 0x07),
  764. raw_pdu(0x50, 0x09, 0x04),
  765. raw_pdu(0x52, 0x09));
  766. define_test("/TP/SIG/SMG/BV-23-C", test_client,
  767. raw_pdu(0xf0, 0x01),
  768. raw_pdu(0xf2, 0x01, 0x04, 0x00),
  769. raw_pdu(0x00, 0x02, 0x04),
  770. raw_pdu(0x02, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  771. 0xff, 0xff, 0x02, 0x40),
  772. raw_pdu(0x10, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  773. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  774. raw_pdu(0x12, 0x03),
  775. raw_pdu(0x20, 0x0a, 0x04));
  776. define_test("/TP/SIG/SMG/BV-24-C", test_server,
  777. raw_pdu(0x00, 0x01),
  778. raw_pdu(0x02, 0x01, 0x04, 0x00),
  779. raw_pdu(0x10, 0x02, 0x04),
  780. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  781. 0xff, 0xff, 0x02, 0x40),
  782. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  783. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  784. raw_pdu(0x22, 0x03),
  785. raw_pdu(0x30, 0x0a, 0x04),
  786. raw_pdu(0x32, 0x0a));
  787. define_test("/TP/SIG/SMG/BV-25-C", test_client_1_3,
  788. raw_pdu(0x30, 0x01),
  789. raw_pdu(0x32, 0x01, 0x04, 0x00),
  790. raw_pdu(0x40, 0x0c, 0x04));
  791. define_test("/TP/SIG/SMG/BV-26-C", test_server_1_3,
  792. raw_pdu(0x00, 0x01),
  793. raw_pdu(0x02, 0x01, 0x04, 0x00),
  794. raw_pdu(0x10, 0x0c, 0x04),
  795. raw_pdu(0x12, 0x0c, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  796. 0xff, 0xff, 0x02, 0x40, 0x08, 0x00));
  797. define_test("/TP/SIG/SMG/BV-27-C", test_server_1_3,
  798. raw_pdu(0x00, 0x01),
  799. raw_pdu(0x02, 0x01, 0x04, 0x00),
  800. raw_pdu(0x10, 0x02, 0x04),
  801. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  802. 0xff, 0xff, 0x02, 0x40));
  803. define_test("/TP/SIG/SMG/BV-28-C", test_client_1_3,
  804. raw_pdu(0x50, 0x01),
  805. raw_pdu(0x52, 0x01, 0x04, 0x00),
  806. raw_pdu(0x60, 0x0c, 0x04),
  807. raw_pdu(0x62, 0x0c, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  808. 0xff, 0xff, 0x02, 0x40, 0x0f, 0x00),
  809. raw_pdu(0x70, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  810. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20));
  811. define_test("/TP/SIG/SMG/BV-31-C", test_client_1_3,
  812. raw_pdu(0x80, 0x01),
  813. raw_pdu(0x82, 0x01, 0x04, 0x00),
  814. raw_pdu(0x90, 0x0c, 0x04),
  815. raw_pdu(0x92, 0x0c, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00,
  816. 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x06,
  817. 0x00, 0x00, 0xff, 0xff, 0x02, 0x40, 0x08, 0x00),
  818. raw_pdu(0xa0, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  819. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20, 0x08,
  820. 0x00));
  821. define_test("/TP/SIG/SMG/BI-01-C", test_client,
  822. raw_pdu(0xb0, 0x01),
  823. raw_pdu(0xb3, 0x01, 0x01));
  824. define_test("/TP/SIG/SMG/BI-02-C", test_server,
  825. raw_pdu(0x01, 0x01));
  826. define_test("/TP/SIG/SMG/BI-03-C", test_server_0_sep,
  827. raw_pdu(0x00, 0x01),
  828. raw_pdu(0x03, 0x01, 0x19));
  829. define_test("/TP/SIG/SMG/BI-04-C", test_client,
  830. raw_pdu(0xc0, 0x01),
  831. raw_pdu(0xc2, 0x01, 0x04, 0x00),
  832. raw_pdu(0xd0, 0x02, 0x04),
  833. raw_pdu(0xd3, 0x02, 0x11));
  834. define_test("/TP/SIG/SMG/BI-05-C", test_server,
  835. raw_pdu(0x00, 0x01),
  836. raw_pdu(0x02, 0x01, 0x04, 0x00),
  837. raw_pdu(0x10, 0x02),
  838. raw_pdu(0x13, 0x02, 0x11));
  839. define_test("/TP/SIG/SMG/BI-06-C", test_server,
  840. raw_pdu(0x00, 0x01),
  841. raw_pdu(0x02, 0x01, 0x04, 0x00),
  842. raw_pdu(0x10, 0x02, 0x00),
  843. raw_pdu(0x13, 0x02, 0x12));
  844. define_test("/TP/SIG/SMG/BI-07-C", test_client,
  845. raw_pdu(0xe0, 0x01),
  846. raw_pdu(0xe2, 0x01, 0x04, 0x00),
  847. raw_pdu(0xf0, 0x02, 0x04),
  848. raw_pdu(0xf2, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  849. 0xff, 0xff, 0x02, 0x40),
  850. raw_pdu(0x00, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  851. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  852. raw_pdu(0x03, 0x03, 0x00, 0x13));
  853. define_test("/TP/SIG/SMG/BI-08-C", test_server,
  854. raw_pdu(0x00, 0x01),
  855. raw_pdu(0x02, 0x01, 0x04, 0x00),
  856. raw_pdu(0x10, 0x02, 0x04),
  857. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  858. 0xff, 0xff, 0x02, 0x40),
  859. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  860. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  861. raw_pdu(0x22, 0x03),
  862. raw_pdu(0x30, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  863. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  864. raw_pdu(0x33, 0x03, 0x00, 0x13));
  865. define_test("/TP/SIG/SMG/BI-09-C", test_server,
  866. raw_pdu(0x00, 0x01),
  867. raw_pdu(0x02, 0x01, 0x04, 0x00),
  868. raw_pdu(0x10, 0x02, 0x04),
  869. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  870. 0xff, 0xff, 0x02, 0x40),
  871. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  872. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  873. raw_pdu(0x23, 0x03, 0x00, 0x29));
  874. define_test("/TP/SIG/SMG/BI-10-C", test_client,
  875. raw_pdu(0x10, 0x01),
  876. raw_pdu(0x12, 0x01, 0x04, 0x00),
  877. raw_pdu(0x20, 0x02, 0x04),
  878. raw_pdu(0x22, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  879. 0xff, 0xff, 0x02, 0x40),
  880. raw_pdu(0x30, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  881. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  882. raw_pdu(0x32, 0x03),
  883. raw_pdu(0x40, 0x04, 0x04),
  884. raw_pdu(0x43, 0x04, 0x12));
  885. define_test("/TP/SIG/SMG/BI-11-C", test_server,
  886. raw_pdu(0x00, 0x01),
  887. raw_pdu(0x02, 0x01, 0x04, 0x00),
  888. raw_pdu(0x10, 0x02, 0x04),
  889. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  890. 0xff, 0xff, 0x02, 0x40),
  891. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  892. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  893. raw_pdu(0x22, 0x03),
  894. raw_pdu(0x30, 0x04, 0x00),
  895. raw_pdu(0x33, 0x04, 0x12));
  896. define_test("/TP/SIG/SMG/BI-17-C", test_server,
  897. raw_pdu(0x00, 0x01),
  898. raw_pdu(0x02, 0x01, 0x04, 0x00),
  899. raw_pdu(0x10, 0x02, 0x04),
  900. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  901. 0xff, 0xff, 0x02, 0x40),
  902. raw_pdu(0x30, 0x06, 0x04),
  903. raw_pdu(0x33, 0x06, 0x31));
  904. define_test("/TP/SIG/SMG/BI-18-C", test_server,
  905. raw_pdu(0x00, 0x01),
  906. raw_pdu(0x02, 0x01, 0x04, 0x00),
  907. raw_pdu(0x10, 0x02, 0x04),
  908. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  909. 0xff, 0xff, 0x02, 0x40),
  910. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  911. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  912. raw_pdu(0x22, 0x03),
  913. raw_pdu(0x30, 0x06, 0x04),
  914. raw_pdu(0x33, 0x06, 0xc0));
  915. define_test("/TP/SIG/SMG/BI-19-C", test_client,
  916. raw_pdu(0x50, 0x01),
  917. raw_pdu(0x52, 0x01, 0x04, 0x00),
  918. raw_pdu(0x60, 0x02, 0x04),
  919. raw_pdu(0x62, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  920. 0xff, 0xff, 0x02, 0x40),
  921. raw_pdu(0x70, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  922. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  923. raw_pdu(0x72, 0x03),
  924. raw_pdu(0x80, 0x06, 0x04),
  925. raw_pdu(0x82, 0x06),
  926. raw_pdu(0x90, 0x07, 0x04),
  927. raw_pdu(0x93, 0x07, 0x04, 0x31));
  928. define_test("/TP/SIG/SMG/BI-20-C", test_server,
  929. raw_pdu(0x00, 0x01),
  930. raw_pdu(0x02, 0x01, 0x04, 0x00),
  931. raw_pdu(0x10, 0x02, 0x04),
  932. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  933. 0xff, 0xff, 0x02, 0x40),
  934. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  935. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  936. raw_pdu(0x22, 0x03),
  937. raw_pdu(0x30, 0x07, 0x04),
  938. raw_pdu(0x33, 0x07, 0x04, 0x31));
  939. define_test("/TP/SIG/SMG/BI-21-C", test_server,
  940. raw_pdu(0x00, 0x01),
  941. raw_pdu(0x02, 0x01, 0x04, 0x00),
  942. raw_pdu(0x10, 0x02, 0x04),
  943. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  944. 0xff, 0xff, 0x02, 0x40),
  945. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  946. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  947. raw_pdu(0x22, 0x03),
  948. raw_pdu(0x30, 0x06, 0x04),
  949. raw_pdu(0x32, 0x06),
  950. raw_pdu(0x40, 0x07, 0x04),
  951. raw_pdu(0x43, 0x07, 0x04, 0xc0));
  952. define_test("/TP/SIG/SMG/BI-22-C", test_client,
  953. raw_pdu(0xa0, 0x01),
  954. raw_pdu(0xa2, 0x01, 0x04, 0x00),
  955. raw_pdu(0xb0, 0x02, 0x04),
  956. raw_pdu(0xb2, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  957. 0xff, 0xff, 0x02, 0x40),
  958. raw_pdu(0xc0, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  959. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  960. raw_pdu(0xc2, 0x03),
  961. raw_pdu(0xd0, 0x06, 0x04),
  962. raw_pdu(0xd2, 0x06),
  963. raw_pdu(0xe0, 0x07, 0x04),
  964. raw_pdu(0xe3, 0x07, 0x04, 0x31));
  965. define_test("/TP/SIG/SMG/BI-23-C", test_server,
  966. raw_pdu(0x00, 0x01),
  967. raw_pdu(0x02, 0x01, 0x04, 0x00),
  968. raw_pdu(0x10, 0x02, 0x04),
  969. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  970. 0xff, 0xff, 0x02, 0x40),
  971. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  972. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  973. raw_pdu(0x22, 0x03),
  974. raw_pdu(0x30, 0x06, 0x04),
  975. raw_pdu(0x32, 0x06),
  976. raw_pdu(0x40, 0x08, 0x00),
  977. raw_pdu(0x43, 0x08, 0x12));
  978. define_test("/TP/SIG/SMG/BI-24-C", test_server,
  979. raw_pdu(0x00, 0x01),
  980. raw_pdu(0x02, 0x01, 0x04, 0x00),
  981. raw_pdu(0x10, 0x02, 0x04),
  982. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  983. 0xff, 0xff, 0x02, 0x40),
  984. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  985. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  986. raw_pdu(0x22, 0x03),
  987. raw_pdu(0x30, 0x06, 0x04),
  988. raw_pdu(0x32, 0x06),
  989. raw_pdu(0x40, 0x08, 0x04),
  990. raw_pdu(0x43, 0x08, 0xc0));
  991. define_test("/TP/SIG/SMG/BI-25-C", test_server,
  992. raw_pdu(0x00, 0x01),
  993. raw_pdu(0x02, 0x01, 0x04, 0x00),
  994. raw_pdu(0x10, 0x02, 0x04),
  995. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  996. 0xff, 0xff, 0x02, 0x40),
  997. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  998. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  999. raw_pdu(0x22, 0x03),
  1000. raw_pdu(0x30, 0x06, 0x04),
  1001. raw_pdu(0x32, 0x06),
  1002. raw_pdu(0x40, 0x07, 0x04),
  1003. raw_pdu(0x42, 0x07),
  1004. raw_pdu(0xf0, 0x09, 0x04),
  1005. raw_pdu(0xf3, 0x09, 0x04, 0x31));
  1006. define_test("/TP/SIG/SMG/BI-26-C", test_server,
  1007. raw_pdu(0x00, 0x01),
  1008. raw_pdu(0x02, 0x01, 0x04, 0x00),
  1009. raw_pdu(0x10, 0x02, 0x04),
  1010. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  1011. 0xff, 0xff, 0x02, 0x40),
  1012. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1013. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  1014. raw_pdu(0x22, 0x03),
  1015. raw_pdu(0x30, 0x06, 0x04),
  1016. raw_pdu(0x32, 0x06),
  1017. raw_pdu(0x40, 0x09, 0x04),
  1018. raw_pdu(0x43, 0x09, 0x04, 0x31));
  1019. define_test("/TP/SIG/SMG/BI-27-C", test_server,
  1020. raw_pdu(0x00, 0x01),
  1021. raw_pdu(0x02, 0x01, 0x04, 0x00),
  1022. raw_pdu(0x10, 0x02, 0x04),
  1023. raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  1024. 0xff, 0xff, 0x02, 0x40),
  1025. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1026. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
  1027. raw_pdu(0x22, 0x03),
  1028. raw_pdu(0x30, 0x06, 0x04),
  1029. raw_pdu(0x32, 0x06),
  1030. raw_pdu(0x40, 0x07, 0x04),
  1031. raw_pdu(0x42, 0x07),
  1032. raw_pdu(0x50, 0x09, 0x04),
  1033. raw_pdu(0x53, 0x09, 0x04, 0xc0));
  1034. define_test("/TP/SIG/SMG/BI-28-C", test_server,
  1035. raw_pdu(0x00, 0xff),
  1036. raw_pdu(0x01, 0x3f));
  1037. define_test("/TP/SIG/SMG/BI-30-C", test_client,
  1038. raw_pdu(0x00, 0x01),
  1039. raw_pdu(0x02, 0x01, 0x04, 0x00),
  1040. raw_pdu(0x10, 0x02, 0x04),
  1041. raw_pdu(0x12, 0x02, 0xee, 0x01, 0x00, 0x01, 0x00, 0x07,
  1042. 0x06, 0x00, 0x00, 0xff, 0xff, 0x02, 0x40),
  1043. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1044. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20));
  1045. define_test("/TP/SIG/SMG/ESR04/BI-28-C", test_server,
  1046. raw_pdu(0x00, 0x3f),
  1047. raw_pdu(0x01, 0x3f));
  1048. define_test("/TP/SIG/SMG/BI-32-C", test_client_1_3,
  1049. raw_pdu(0x30, 0x01),
  1050. raw_pdu(0x32, 0x01, 0x04, 0x00),
  1051. raw_pdu(0x40, 0x0c, 0x04),
  1052. raw_pdu(0x43, 0x0c, 0x11));
  1053. define_test("/TP/SIG/SMG/BI-33-C", test_server_1_3,
  1054. raw_pdu(0x00, 0x01),
  1055. raw_pdu(0x02, 0x01, 0x04, 0x00),
  1056. raw_pdu(0x10, 0x0c),
  1057. raw_pdu(0x13, 0x0c, 0x11));
  1058. define_test("/TP/SIG/SMG/BI-35-C", test_client_1_3,
  1059. raw_pdu(0x50, 0x01),
  1060. raw_pdu(0x52, 0x01, 0x04, 0x00),
  1061. raw_pdu(0x60, 0x0c, 0x04),
  1062. raw_pdu(0x62, 0x0c, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00,
  1063. 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x06,
  1064. 0x00, 0x00, 0xff, 0xff, 0x02, 0x40, 0x08, 0x00),
  1065. raw_pdu(0x70, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1066. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20, 0x08,
  1067. 0x00));
  1068. define_test("/TP/SIG/SMG/BI-36-C", test_client_1_3,
  1069. raw_pdu(0x80, 0x01),
  1070. raw_pdu(0x82, 0x01, 0x04, 0x00),
  1071. raw_pdu(0x90, 0x0c, 0x04),
  1072. raw_pdu(0x92, 0x0c, 0xee, 0x01, 0x00, 0x01, 0x00, 0x07,
  1073. 0x06, 0x00, 0x00, 0xff, 0xff, 0x02, 0x40),
  1074. raw_pdu(0xa0, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1075. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20));
  1076. /*
  1077. * Signaling Message Fragmentation Service
  1078. *
  1079. * verify that the IUT (INT and ACP) fragments the signaling messages
  1080. * that cannot fit in a single L2CAP packet.
  1081. */
  1082. define_test("/TP/SIG/FRA/BV-01-C", test_server_frg,
  1083. raw_pdu(0x00, 0x01),
  1084. raw_pdu(0x02, 0x01, 0x04, 0x00),
  1085. raw_pdu(0x10, 0x02, 0x04),
  1086. frg_pdu(0x16, 0x03, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00,
  1087. 0x00, 0xff, 0xff, 0x02, 0x40, 0x04, 0x60, 0x00,
  1088. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1089. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1090. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1091. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1092. 0x00),
  1093. frg_pdu(0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1094. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1095. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1096. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1097. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1098. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1099. 0x00),
  1100. raw_pdu(0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1101. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1102. 0x00));
  1103. define_test("/TP/SIG/FRA/BV-02-C", test_client_frg,
  1104. raw_pdu(0xb0, 0x01),
  1105. raw_pdu(0xb2, 0x01, 0x04, 0x00),
  1106. raw_pdu(0xc0, 0x02, 0x04),
  1107. frg_pdu(0xc6, 0x03, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00,
  1108. 0x00, 0xff, 0xff, 0x02, 0x40, 0x04, 0x60, 0x00,
  1109. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1110. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1111. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1112. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1113. 0x00),
  1114. frg_pdu(0xca, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1115. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1116. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1117. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1118. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1119. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1120. 0x00),
  1121. raw_pdu(0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1122. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1123. 0x00));
  1124. /*
  1125. * Delay Reporting
  1126. *
  1127. * Verify that the stream management signaling procedure of delay
  1128. * reporting is implemented according to its specification in AVDTP.
  1129. */
  1130. define_test("/TP/SIG/SYN/BV-01-C", test_server_1_3_sink,
  1131. raw_pdu(0x00, 0x01),
  1132. raw_pdu(0x02, 0x01, 0x04, 0x08),
  1133. raw_pdu(0x10, 0x0c, 0x04),
  1134. raw_pdu(0x12, 0x0c, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  1135. 0xff, 0xff, 0x02, 0x40, 0x08, 0x00));
  1136. define_test("/TP/SIG/SYN/BV-02-C", test_client_1_3,
  1137. raw_pdu(0xd0, 0x01),
  1138. raw_pdu(0xd2, 0x01, 0x04, 0x00),
  1139. raw_pdu(0xe0, 0x0c, 0x04),
  1140. raw_pdu(0xe2, 0x0c, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  1141. 0xff, 0xff, 0x02, 0x40, 0x0f, 0x00, 0x08, 0x00),
  1142. raw_pdu(0xf0, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1143. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20, 0x08,
  1144. 0x00));
  1145. define_test("/TP/SIG/SYN/BV-03-C", test_server_1_3_sink,
  1146. raw_pdu(0x00, 0x01),
  1147. raw_pdu(0x02, 0x01, 0x04, 0x08),
  1148. raw_pdu(0x10, 0x0c, 0x04),
  1149. raw_pdu(0x12, 0x0c, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  1150. 0xff, 0xff, 0x02, 0x40, 0x08, 0x00),
  1151. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1152. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20, 0x08,
  1153. 0x00),
  1154. raw_pdu(0x22, 0x03),
  1155. raw_pdu(0x00, 0x0d, 0x04, 0x00, 0x00));
  1156. define_test("/TP/SIG/SYN/BV-04-C", test_client_1_3,
  1157. raw_pdu(0x10, 0x01),
  1158. raw_pdu(0x12, 0x01, 0x04, 0x00),
  1159. raw_pdu(0x20, 0x0c, 0x04),
  1160. raw_pdu(0x22, 0x0c, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  1161. 0xff, 0xff, 0x02, 0x40, 0x0f, 0x00, 0x08, 0x00),
  1162. raw_pdu(0x30, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1163. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20, 0x08,
  1164. 0x00),
  1165. raw_pdu(0x32, 0x03),
  1166. raw_pdu(0x40, 0x0d, 0x04, 0x00, 0x00));
  1167. define_test("/TP/SIG/SYN/BV-05-C", test_server_1_3,
  1168. raw_pdu(0x00, 0x01),
  1169. raw_pdu(0x02, 0x01, 0x04, 0x00),
  1170. raw_pdu(0x10, 0x0c, 0x04),
  1171. raw_pdu(0x12, 0x0c, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  1172. 0xff, 0xff, 0x02, 0x40, 0x08, 0x00),
  1173. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1174. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20, 0x08,
  1175. 0x00),
  1176. raw_pdu(0x22, 0x03),
  1177. raw_pdu(0x30, 0x06, 0x04),
  1178. raw_pdu(0x32, 0x06),
  1179. raw_pdu(0x40, 0x0d, 0x04, 0x00, 0x00),
  1180. raw_pdu(0x42, 0x0d));
  1181. define_test("/TP/SIG/SYN/BV-06-C", test_server_1_3,
  1182. raw_pdu(0x00, 0x01),
  1183. raw_pdu(0x02, 0x01, 0x04, 0x00),
  1184. raw_pdu(0x10, 0x0c, 0x04),
  1185. raw_pdu(0x12, 0x0c, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
  1186. 0xff, 0xff, 0x02, 0x40, 0x08, 0x00),
  1187. raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
  1188. 0x00, 0x00, 0x21, 0x02, 0x02, 0x20, 0x08,
  1189. 0x00),
  1190. raw_pdu(0x22, 0x03),
  1191. raw_pdu(0x30, 0x06, 0x04),
  1192. raw_pdu(0x32, 0x06),
  1193. raw_pdu(0x40, 0x07, 0x04),
  1194. raw_pdu(0x42, 0x07),
  1195. raw_pdu(0x50, 0x0d, 0x04, 0x00, 0x00),
  1196. raw_pdu(0x52, 0x0d));
  1197. return tester_run();
  1198. }