diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2009-09-03 16:21:57 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2009-09-03 16:22:02 +0300 |
commit | 5b968a14e181577439b37bf8cf4ab3a23d4eeb68 (patch) | |
tree | ad44b0efff4f87728165bcc41f387ca0ed5148d1 /test | |
parent | 467e28d995d99be98005c31734739d558919b2df (diff) | |
download | bluez-5b968a14e181577439b37bf8cf4ab3a23d4eeb68.tar.gz |
Fix do_send to wait for a proper reply
The remote side might be simultaneously sending commands to us which we
should just ignore.
Diffstat (limited to 'test')
-rw-r--r-- | test/avtest.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test/avtest.c b/test/avtest.c index f7b93a91c..37bb4acaf 100644 --- a/test/avtest.c +++ b/test/avtest.c @@ -45,6 +45,7 @@ #define AVDTP_PKT_TYPE_END 0x03 #define AVDTP_MSG_TYPE_COMMAND 0x00 +#define AVDTP_MSG_TYPE_GEN_REJECT 0x01 #define AVDTP_MSG_TYPE_ACCEPT 0x02 #define AVDTP_MSG_TYPE_REJECT 0x03 @@ -597,10 +598,14 @@ static void do_send(int sk, const bdaddr_t *src, const bdaddr_t *dst, break; } - len = read(sk, buf, sizeof(buf)); + do { + len = read(sk, buf, sizeof(buf)); - dump_buffer(buf, len); - dump_header(hdr); + dump_buffer(buf, len); + dump_header(hdr); + } while (len < 2 || (hdr->message_type != AVDTP_MSG_TYPE_ACCEPT && + hdr->message_type != AVDTP_MSG_TYPE_REJECT && + hdr->message_type != AVDTP_MSG_TYPE_GEN_REJECT)); if (cmd == AVDTP_OPEN && len >= 2 && hdr->message_type == AVDTP_MSG_TYPE_ACCEPT) |