* @brief Processes one byte of an incoming binary-32 header (ZDLE-decoded). */
| 280 | * @brief Processes one byte of an incoming binary-32 header (ZDLE-decoded). |
| 281 | */ |
| 282 | void IO::Protocols::ZMODEM::processBin32Byte(quint8 ch) |
| 283 | { |
| 284 | static constexpr int kMaxBinHeaderBytes = 128; |
| 285 | |
| 286 | if (m_headerBuf.size() >= kMaxBinHeaderBytes) [[unlikely]] { |
| 287 | m_parseState = ParseState::Idle; |
| 288 | m_headerBuf.clear(); |
| 289 | m_zdleEscape = false; |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | if (m_zdleEscape) { |
| 294 | m_headerBuf.append(static_cast<char>(ch ^ 0x40)); |
| 295 | m_zdleEscape = false; |
| 296 | } else if (ch == kZDLE) { |
| 297 | m_zdleEscape = true; |
| 298 | return; |
| 299 | } else { |
| 300 | m_headerBuf.append(static_cast<char>(ch)); |
| 301 | } |
| 302 | |
| 303 | if (m_headerBuf.size() < m_headerBytesExpected) |
| 304 | return; |
| 305 | |
| 306 | quint8 type = static_cast<quint8>(m_headerBuf[0]); |
| 307 | quint32 arg = static_cast<quint32>(static_cast<quint8>(m_headerBuf[1])) |
| 308 | | (static_cast<quint32>(static_cast<quint8>(m_headerBuf[2])) << 8) |
| 309 | | (static_cast<quint32>(static_cast<quint8>(m_headerBuf[3])) << 16) |
| 310 | | (static_cast<quint32>(static_cast<quint8>(m_headerBuf[4])) << 24); |
| 311 | |
| 312 | parseReceivedHeader(type, arg); |
| 313 | m_parseState = ParseState::Idle; |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * @brief Processes one byte of an incoming binary header (ZDLE-decoded). |