diff --git a/src/OverteClient.cpp b/src/OverteClient.cpp index ced1b86..5460ebb 100644 --- a/src/OverteClient.cpp +++ b/src/OverteClient.cpp @@ -967,23 +967,21 @@ void OverteClient::handleDomainListReply(const char* data, size_t len) { std::cout << "[OverteClient] Node UUID (our session): " << nodeUUID << std::endl; - // Read domain local ID (16-bit) - this is in LITTLE-ENDIAN, not big-endian! - // Do NOT use ntohs() - just read directly on x86 + // Read node local ID (16-bit, BIG-ENDIAN / network byte order) if (offset + 2 > len) return; // Debug: show the exact bytes at this position - std::cout << "[OverteClient] LocalID bytes at offset " << offset << ": " + std::cout << "[OverteClient] Node LocalID bytes at offset " << offset << ": " << std::hex << std::setfill('0') << std::setw(2) << (int)(unsigned char)data[offset] << " " << std::setw(2) << (int)(unsigned char)data[offset+1] << std::dec << std::endl; - uint16_t localID; - std::memcpy(&localID, data + offset, sizeof(uint16_t)); // Direct read, little-endian + uint16_t localID = ntohs(*reinterpret_cast(data + offset)); // Big-endian! offset += 2; // Store our local ID for use in sourced packets m_localID = localID; - std::cout << "[OverteClient] Local ID: " << localID << " (0x" << std::hex << localID << std::dec << ")" << std::endl; + std::cout << "[OverteClient] Node Local ID (ours!): " << localID << " (0x" << std::hex << localID << std::dec << ")" << std::endl; // Read permissions (32-bit) if (offset + 4 > len) return;