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