diff options
Diffstat (limited to 'saprotocol.cc')
-rw-r--r-- | saprotocol.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/saprotocol.cc b/saprotocol.cc index 9f25613..22b3111 100644 --- a/saprotocol.cc +++ b/saprotocol.cc @@ -229,6 +229,30 @@ QByteArray SAProtocol::packFrame(quint16 sessionId, const QByteArray &data) return packFrame(frame); } +SAProtocol::DataFrame SAProtocol::unpackDataFrame(const QByteArray &data, bool withSeqNum) +{ + DataFrame frame; + int offset = 0; + frame.withSeqNum = withSeqNum; + if (withSeqNum) { + frame.seqNum = read<quint16>(data, offset); + frame.unk_1 = read<quint8>(data, offset); + } + frame.data = data.mid(offset); + return frame; +} + +QByteArray SAProtocol::packDataFrame(const DataFrame &frame) +{ + QByteArray data; + if (frame.withSeqNum) { + append<quint16>(data, frame.seqNum); + append<quint8>(data, frame.unk_1); + } + data.append(frame.data); + return data; +} + SAProtocol::ServiceConnectionRequestFrame SAProtocol::unpackServiceConnectionRequestFrame(const QByteArray &data) { ServiceConnectionRequestFrame frame; |