diff options
author | Javier <dev.git@javispedro.com> | 2015-12-13 05:50:18 +0100 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2015-12-13 05:50:18 +0100 |
commit | 97c93d800287a21b971b763d58c1eebb30ece071 (patch) | |
tree | 29aed96db3984520b76bbc53209b285ecf9fcbfa | |
parent | cd00ce1a7128cf11fa59e7a03bec49ea69425f54 (diff) | |
download | sapd-97c93d800287a21b971b763d58c1eebb30ece071.tar.gz sapd-97c93d800287a21b971b763d58c1eebb30ece071.zip |
fix broken decoding of multiple-channel connection requests
-rw-r--r-- | sappeer.cc | 4 | ||||
-rw-r--r-- | saprotocol.cc | 31 | ||||
-rw-r--r-- | webproxyagent.cc | 11 |
3 files changed, 37 insertions, 9 deletions
@@ -233,6 +233,7 @@ void SAPPeer::handleDefaultSessionMessage(const QByteArray &message) } if (!ok) { + // Send a negative status code message back SAProtocol::ServiceConnectionResponseFrame resp; resp.messageType = SAProtocol::ServiceConnectionResponse; resp.acceptorId = req.acceptorId; @@ -256,7 +257,8 @@ void SAPPeer::handleDefaultSessionMessage(const QByteArray &message) // TODO set socket QoS parameters conn->setSocket(s.channelId, socket); - qDebug() << " opening channel" << s.sessionId << s.channelId << "payload=" << s.payloadType; + qDebug() << " opening channel" << s.channelId << "as session" << s.sessionId; + qDebug() << " payload=" << s.payloadType << "qos=" << s.qosType << "prio=" << s.qosPriority << "rate=" << s.qosDataRate; _sessions.insert(s.sessionId, socket); } 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); } diff --git a/webproxyagent.cc b/webproxyagent.cc index 186912f..126cd75 100644 --- a/webproxyagent.cc +++ b/webproxyagent.cc @@ -46,11 +46,18 @@ void WebProxyAgent::registerServices(SAPManager *manager) service.setVersion(2, 0); service.setConnectionTimeout(0); + channel.setChannelId(501); + channel.setPayloadType(SAPChannelInfo::PayloadBinary); + channel.setQoSType(SAPChannelInfo::QoSReliabilityEnable); + channel.setQoSDataRate(SAPChannelInfo::QoSDataRateLow); + channel.setQoSPriority(SAPChannelInfo::QoSPriorityLow); + service.addChannel(channel); + channel.setChannelId(502); channel.setPayloadType(SAPChannelInfo::PayloadBinary); - channel.setQoSType(SAPChannelInfo::QoSRestricted); + channel.setQoSType(SAPChannelInfo::QoSReliabilityEnable); channel.setQoSDataRate(SAPChannelInfo::QoSDataRateLow); - channel.setQoSPriority(SAPChannelInfo::QoSPriorityHigh); + channel.setQoSPriority(SAPChannelInfo::QoSPriorityLow); service.addChannel(channel); manager->registerServiceAgent(service, instance()); |