summaryrefslogtreecommitdiff
path: root/saprotocol.cc
diff options
context:
space:
mode:
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);
}