summaryrefslogtreecommitdiff
path: root/context.h
diff options
context:
space:
mode:
Diffstat (limited to 'context.h')
-rw-r--r--context.h55
1 files changed, 37 insertions, 18 deletions
diff --git a/context.h b/context.h
index 95824e4..497c12b 100644
--- a/context.h
+++ b/context.h
@@ -538,6 +538,10 @@ extern short tcp_receive(short nh, void (*notify)(short size, short sock_fd), sh
extern int get_link_status();
extern char *get_sock_status_name(short code);
+// pso/TSocket.h
+extern u16 to_be_uint16_t(u16 val);
+extern u16 to_le_uint16_t(u16 val);
+
// THeap.cpp
extern void heap_xfree(void *ptr);
extern void *heap_xmalloc(size_t size);
@@ -560,6 +564,9 @@ extern void func_803e11f0();
extern void func_803369b4();
+// pso/TProtocol.h
+extern void copy_packet(struct packet *pkt);
+
// pso/protocol.h
extern void bswap_16(u16 *val);
extern void bswap_32(u32 *val);
@@ -693,13 +700,23 @@ struct send_buffs {
// pso/TProtocol.h
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 {
@@ -1082,15 +1099,15 @@ public:
};
// pso/TSocket.h
-class TSocket : private TObject {
-private:
+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;
@@ -1118,19 +1135,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);
@@ -1138,8 +1155,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);
@@ -1154,7 +1171,7 @@ public:
// pso/TTcpSocket.h
class TTcpSocket : public TSocket {
-private:
+public:
PSOV3EncryptionTCP m_send_crypt;
PSOV3EncryptionTCP m_recv_crypt;
int m_is_encrypted;
@@ -1259,7 +1276,7 @@ private:
// pso/TProtocol.h
class TProtocol : public TTcpSocket {
-private:
+public:
TPlySmth m_smth;
TPlyGuildCardTag m_guildcard_tag;
u16 m_sub_version;
@@ -1267,7 +1284,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;
@@ -1300,9 +1317,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);
@@ -1311,7 +1330,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);