From 06d75ece6452a33f11afd7e5ec3dd1f916c8583f Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Mon, 6 Mar 2023 16:19:36 -0400 Subject: TProtocol: Match both `parse_packet()`, and `run_task()` --- src/pso/TSocket.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/pso/TSocket.cpp') diff --git a/src/pso/TSocket.cpp b/src/pso/TSocket.cpp index 0a0166e..3c5576f 100644 --- a/src/pso/TSocket.cpp +++ b/src/pso/TSocket.cpp @@ -5,8 +5,6 @@ #include "pso/TObject.h" #include "pso/TSocket.h" -u16 bswap_word(u16 val); - int TSocket::is_empty() { if (all_parents_unqueued_for_destruction()) { return !m_size; @@ -25,7 +23,7 @@ const u8 TSocket::next() { } void TSocket::set_port(u32 port) { - m_dst_port = bswap_word(port); + m_dst_port = to_le_uint16_t(port); } void TSocket::set_ip_address(u32 addr) { @@ -42,14 +40,19 @@ TSocket::TSocket(TObject *parent) : TObject(parent) { m_dst_port = 0; m_src_port = 0; m_sock_fd = -1; - m_sock_flags = 0; + m_is_invalid_packet = false; m_size = 0; m_buffer_offset = 0; m_buffer_cleared = true; m_callback = nullptr; } -u16 bswap_word(u16 val) { +u16 to_be_uint16_t(u16 val) { + u8 *ptr = reinterpret_cast(&val); + return ptr[0] + (ptr[1] << 8); +} + +u16 to_le_uint16_t(u16 val) { u8 *ptr = reinterpret_cast(&val); return ptr[1] + (ptr[0] << 8); } -- cgit v1.2.3-13-gbd6f