summaryrefslogtreecommitdiff
path: root/include/pso
diff options
context:
space:
mode:
Diffstat (limited to 'include/pso')
-rw-r--r--include/pso/TProtocol.h28
-rw-r--r--include/pso/TSocket.h23
-rw-r--r--include/pso/TTcpSocket.h2
3 files changed, 34 insertions, 19 deletions
diff --git a/include/pso/TProtocol.h b/include/pso/TProtocol.h
index ed80d04..6cd2a9e 100644
--- a/include/pso/TProtocol.h
+++ b/include/pso/TProtocol.h
@@ -18,17 +18,27 @@
#include <pso/TSocket.h>
#include <pso/TTcpSocket.h>
-
EXTERN_OBJECT_NAME(TProtocol);
+extern void copy_packet(struct packet *pkt);
struct packet {
- packet_header header;
- TArray<u8, 0x7c00-sizeof(packet_header)> data;
+ union {
+ struct {
+ packet_header header;
+ TArray<u8, 0x7c00-sizeof(packet_header)> data;
+ } packet;
+ u8 bytes[0x7c00];
+ };
template<typename T>
T &as() {
return reinterpret_cast<T>(*this);
};
+
+ template<typename T>
+ T *as_ptr() {
+ return reinterpret_cast<T *>(this);
+ };
};
struct GameListEntry {
@@ -51,7 +61,7 @@ struct QuestListEntry {
typedef void (*recv_packet_handler)(packet &pkt);
class TProtocol : public TTcpSocket {
-private:
+public:
TPlySmth m_smth;
TPlyGuildCardTag m_guildcard_tag;
u16 m_sub_version;
@@ -59,7 +69,7 @@ private:
int m_connected;
int m_joined_game;
int m_has_meet_user_settings;
- int m_buffer_ready;
+ int m_handle_pings_only;
int m_entry_count;
int m_unused;
int m_lobby_list_count;
@@ -92,9 +102,11 @@ public:
virtual ~TProtocol();
virtual void run_task();
- virtual int send(u8 *data, size_t size);
+ virtual short send(u8 *data, size_t size);
- int handle_command(packet *pkt);
+ void some_stub();
+ int handle_command(struct packet *pkt);
+ void parse_packet();
PRIVATE_MEMBER_ACCESSORS(TPlySmth, smth);
PRIVATE_MEMBER_ACCESSORS(TPlyGuildCardTag, guildcard_tag);
@@ -103,7 +115,7 @@ public:
PRIVATE_MEMBER_ACCESSORS(int, connected);
PRIVATE_MEMBER_ACCESSORS(int, joined_game);
PRIVATE_MEMBER_ACCESSORS(int, has_meet_user_settings);
- PRIVATE_MEMBER_ACCESSORS(int, buffer_ready);
+ PRIVATE_MEMBER_ACCESSORS(int, handle_pings_only);
PRIVATE_MEMBER_ACCESSORS(int, entry_count);
PRIVATE_MEMBER_ACCESSORS(int, unused);
PRIVATE_MEMBER_ACCESSORS(int, lobby_list_count);
diff --git a/include/pso/TSocket.h b/include/pso/TSocket.h
index c55dd08..6f79e13 100644
--- a/include/pso/TSocket.h
+++ b/include/pso/TSocket.h
@@ -13,15 +13,18 @@ union ipv4_addr {
TArray<u8, 4> addr_bytes;
};
-class TSocket : private TObject {
-private:
+extern u16 to_be_uint16_t(u16 val);
+extern u16 to_le_uint16_t(u16 val);
+
+class TSocket : public TObject {
+public:
ipv4_addr m_dst_addr;
u16 m_dst_port;
u16 m_src_port;
ipv4_addr m_src_addr;
s16 m_sock_fd;
- u8 m_sock_flags;
- bool m_buffer_cleared;
+ char m_is_invalid_packet;
+ char m_buffer_cleared;
s16 m_size;
s16 m_buffer_offset;
u32 m_unused;
@@ -49,19 +52,19 @@ public:
int is_empty();
void set_flags(u8 flags) {
- m_sock_flags |= flags;
+ m_is_invalid_packet |= flags;
};
void clear_flags(u8 flags) {
- m_sock_flags &= ~flags;
+ m_is_invalid_packet &= ~flags;
};
void toggle_flags(u8 flags) {
- m_sock_flags ^= flags;
+ m_is_invalid_packet ^= flags;
};
u8 get_flags(u8 flags) {
- return m_sock_flags & flags;
+ return m_is_invalid_packet & flags;
};
PRIVATE_MEMBER_ACCESSORS(ipv4_addr, dst_addr);
@@ -69,8 +72,8 @@ public:
PRIVATE_MEMBER_ACCESSORS(u16, src_port);
PRIVATE_MEMBER_ACCESSORS(ipv4_addr, src_addr);
PRIVATE_MEMBER_ACCESSORS(s16, sock_fd);
- PRIVATE_MEMBER_ACCESSORS(u8, sock_flags);
- PRIVATE_MEMBER_ACCESSORS(bool, buffer_cleared);
+ PRIVATE_MEMBER_ACCESSORS(char, is_invalid_packet);
+ PRIVATE_MEMBER_ACCESSORS(char, buffer_cleared);
PRIVATE_MEMBER_ACCESSORS(s16, size);
PRIVATE_MEMBER_ACCESSORS(s16, buffer_offset);
PRIVATE_MEMBER_ACCESSORS(u32, unused);
diff --git a/include/pso/TTcpSocket.h b/include/pso/TTcpSocket.h
index b2c8cfb..8e90558 100644
--- a/include/pso/TTcpSocket.h
+++ b/include/pso/TTcpSocket.h
@@ -14,7 +14,7 @@ EXTERN_OBJECT_NAME(TTcpSocket);
extern TTcpSocket *tcp_socket_table[16];
class TTcpSocket : public TSocket {
-private:
+public:
PSOV3EncryptionTCP m_send_crypt;
PSOV3EncryptionTCP m_recv_crypt;
int m_is_encrypted;