summaryrefslogtreecommitdiff
path: root/test/avtest.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-09-02 15:16:57 +0300
committerJohan Hedberg <johan.hedberg@nokia.com>2009-09-02 15:17:08 +0300
commitfed73810714b4d52c6bb14253e5e5481ad0bf3f2 (patch)
tree21132cc5f1269205350f3165ccc280c3143cf0d0 /test/avtest.c
parent00a727e43ba47badf11c236a7df2d32f584cc38b (diff)
Add avtest support for sending corrupted DISCOVER command
Diffstat (limited to 'test/avtest.c')
-rw-r--r--test/avtest.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/test/avtest.c b/test/avtest.c
index e1dabf146..d3e365568 100644
--- a/test/avtest.c
+++ b/test/avtest.c
@@ -276,7 +276,7 @@ error:
return -1;
}
-static void do_send(int sk, unsigned char cmd)
+static void do_send(int sk, unsigned char cmd, int invalid)
{
unsigned char buf[672];
struct avdtp_header *hdr = (void *) buf;
@@ -286,7 +286,10 @@ static void do_send(int sk, unsigned char cmd)
switch (cmd) {
case AVDTP_DISCOVER:
- hdr->message_type = AVDTP_MSG_TYPE_COMMAND;
+ if (invalid)
+ hdr->message_type = 0x01;
+ else
+ hdr->message_type = AVDTP_MSG_TYPE_COMMAND;
hdr->packet_type = AVDTP_PKT_TYPE_SINGLE;
hdr->signal_id = AVDTP_DISCOVER;
len = write(sk, buf, 2);
@@ -336,14 +339,14 @@ static unsigned char parse_cmd(const char *arg)
}
enum {
- MODE_NONE, MODE_REJECT, MODE_SEND, MODE_SEND_INVALID,
+ MODE_NONE, MODE_REJECT, MODE_SEND,
};
int main(int argc, char *argv[])
{
unsigned char cmd = 0x00;
bdaddr_t src, dst;
- int opt, mode = MODE_NONE, sk;
+ int opt, mode = MODE_NONE, sk, invalid = 0;
bacpy(&src, BDADDR_ANY);
bacpy(&dst, BDADDR_ANY);
@@ -363,16 +366,15 @@ int main(int argc, char *argv[])
cmd = parse_cmd(optarg);
break;
+ case 'f':
+ invalid = 1;
+ /* Intentionally missing break */
+
case 's':
mode = MODE_SEND;
cmd = parse_cmd(optarg);
break;
- case 'v':
- mode = MODE_SEND_INVALID;
- cmd = parse_cmd(optarg);
- break;
-
case 'h':
default:
usage();
@@ -388,11 +390,10 @@ int main(int argc, char *argv[])
do_listen(&src, cmd);
break;
case MODE_SEND:
- case MODE_SEND_INVALID:
sk = do_connect(&src, &dst);
if (sk < 0)
exit(1);
- do_send(sk, cmd);
+ do_send(sk, cmd, invalid);
close(sk);
break;
default: