summaryrefslogtreecommitdiff
path: root/src/pso/TSocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pso/TSocket.cpp')
-rw-r--r--src/pso/TSocket.cpp13
1 files changed, 8 insertions, 5 deletions
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<u8 *>(&val);
+ return ptr[0] + (ptr[1] << 8);
+}
+
+u16 to_le_uint16_t(u16 val) {
u8 *ptr = reinterpret_cast<u8 *>(&val);
return ptr[1] + (ptr[0] << 8);
}