summaryrefslogtreecommitdiff
path: root/saprotocol.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-12-13 05:50:18 +0100
committerJavier <dev.git@javispedro.com>2015-12-13 05:50:18 +0100
commit97c93d800287a21b971b763d58c1eebb30ece071 (patch)
tree29aed96db3984520b76bbc53209b285ecf9fcbfa /saprotocol.cc
parentcd00ce1a7128cf11fa59e7a03bec49ea69425f54 (diff)
downloadsapd-97c93d800287a21b971b763d58c1eebb30ece071.tar.gz
sapd-97c93d800287a21b971b763d58c1eebb30ece071.zip
fix broken decoding of multiple-channel connection requests
Diffstat (limited to 'saprotocol.cc')
-rw-r--r--saprotocol.cc31
1 files changed, 25 insertions, 6 deletions
diff --git a/saprotocol.cc b/saprotocol.cc
index 541f0af..c580f12 100644
--- a/saprotocol.cc
+++ b/saprotocol.cc
@@ -247,20 +247,30 @@ SAProtocol::ServiceConnectionRequestFrame SAProtocol::unpackServiceConnectionReq
frame.profile = QString::fromUtf8(&data.constData()[offset], marker - offset);
offset = marker + 1;
- int num_sessions = read<quint16>(data, offset);
+ const int num_sessions = read<quint16>(data, offset);
+ frame.sessions.reserve(num_sessions);
- while (num_sessions > 0) {
+ for (int i = 0; i < num_sessions; i++) {
ServiceConnectionRequestSession session;
session.sessionId = read<quint16>(data, offset);
+ frame.sessions.append(session);
+ }
+
+ for (int i = 0; i < num_sessions; i++) {
+ ServiceConnectionRequestSession &session = frame.sessions[i];
session.channelId = read<quint16>(data, offset);
+ }
+
+ for (int i = 0; i < num_sessions; i++) {
+ ServiceConnectionRequestSession &session = frame.sessions[i];
session.qosType = read<quint8>(data, offset);
session.qosDataRate = read<quint8>(data, offset);
session.qosPriority = read<quint8>(data, offset);
- session.payloadType = read<quint8>(data, offset);
-
- frame.sessions.append(session);
+ }
- num_sessions--;
+ for (int i = 0; i < num_sessions; i++) {
+ ServiceConnectionRequestSession &session = frame.sessions[i];
+ session.payloadType = read<quint8>(data, offset);
}
return frame;
@@ -281,10 +291,19 @@ QByteArray SAProtocol::packServiceConnectionRequestFrame(const ServiceConnection
foreach (const ServiceConnectionRequestSession &session, frame.sessions) {
append<quint16>(data, session.sessionId);
+ }
+
+ foreach (const ServiceConnectionRequestSession &session, frame.sessions) {
append<quint16>(data, session.channelId);
+ }
+
+ foreach (const ServiceConnectionRequestSession &session, frame.sessions) {
append<quint8>(data, session.qosType);
append<quint8>(data, session.qosDataRate);
append<quint8>(data, session.qosPriority);
+ }
+
+ foreach (const ServiceConnectionRequestSession &session, frame.sessions) {
append<quint8>(data, session.payloadType);
}