From d1a9d5a7d052fa25422fd120cb4d6e24a2c74d94 Mon Sep 17 00:00:00 2001 From: Andrew Gutekanst Date: Fri, 27 Dec 2019 04:01:29 +0900 Subject: [PATCH] Implement some packet parsers --- network/mhfpacket/msg_mhf_enumerate_event.go | 13 +++++++--- network/mhfpacket/msg_mhf_enumerate_quest.go | 19 +++++++++++--- .../mhfpacket/msg_mhf_enumerate_ranking.go | 13 +++++++--- network/mhfpacket/msg_mhf_get_etc_points.go | 6 ++--- network/mhfpacket/msg_mhf_read_mercenary_w.go | 14 +++++++--- network/mhfpacket/msg_mhf_update_etc_point.go | 12 ++++++--- network/mhfpacket/msg_sys_ack.go | 19 +++++++++++--- network/mhfpacket/msg_sys_end.go | 6 ++--- network/mhfpacket/msg_sys_extend_threshold.go | 4 +-- network/mhfpacket/msg_sys_login.go | 26 ++++++++++++++++--- network/mhfpacket/msg_sys_nop.go | 6 ++--- network/mhfpacket/msg_sys_ping.go | 15 ++++++++--- network/mhfpacket/msg_sys_time.go | 15 ++++++++--- 13 files changed, 127 insertions(+), 41 deletions(-) diff --git a/network/mhfpacket/msg_mhf_enumerate_event.go b/network/mhfpacket/msg_mhf_enumerate_event.go index 8b8db9684..64c11f5da 100644 --- a/network/mhfpacket/msg_mhf_enumerate_event.go +++ b/network/mhfpacket/msg_mhf_enumerate_event.go @@ -6,7 +6,11 @@ import ( ) // MsgMhfEnumerateEvent represents the MSG_MHF_ENUMERATE_EVENT -type MsgMhfEnumerateEvent struct{} +type MsgMhfEnumerateEvent struct { + AckHandle uint32 + Unk0 uint16 // Hardcoded 0 in the binary + Unk1 uint16 // Hardcoded 0 in the binary +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfEnumerateEvent) Opcode() network.PacketID { @@ -15,10 +19,13 @@ func (m *MsgMhfEnumerateEvent) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfEnumerateEvent) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint16() + m.Unk1 = bf.ReadUint16() + return nil } // Build builds a binary packet from the current data. func (m *MsgMhfEnumerateEvent) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_mhf_enumerate_quest.go b/network/mhfpacket/msg_mhf_enumerate_quest.go index 177f1bbd1..e11c80c61 100644 --- a/network/mhfpacket/msg_mhf_enumerate_quest.go +++ b/network/mhfpacket/msg_mhf_enumerate_quest.go @@ -6,7 +6,14 @@ import ( ) // MsgMhfEnumerateQuest represents the MSG_MHF_ENUMERATE_QUEST -type MsgMhfEnumerateQuest struct{} +type MsgMhfEnumerateQuest struct { + AckHandle uint32 + Unk0 uint8 // Hardcoded 0 in the binary + Unk1 uint8 + Unk2 uint16 + Unk3 uint16 + Unk4 uint8 // Hardcoded 0 in the binary +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfEnumerateQuest) Opcode() network.PacketID { @@ -15,10 +22,16 @@ func (m *MsgMhfEnumerateQuest) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfEnumerateQuest) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint8() + m.Unk1 = bf.ReadUint8() + m.Unk2 = bf.ReadUint16() + m.Unk3 = bf.ReadUint16() + m.Unk4 = bf.ReadUint8() + return nil } // Build builds a binary packet from the current data. func (m *MsgMhfEnumerateQuest) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_mhf_enumerate_ranking.go b/network/mhfpacket/msg_mhf_enumerate_ranking.go index 0e62696dc..56e7366a1 100644 --- a/network/mhfpacket/msg_mhf_enumerate_ranking.go +++ b/network/mhfpacket/msg_mhf_enumerate_ranking.go @@ -6,7 +6,11 @@ import ( ) // MsgMhfEnumerateRanking represents the MSG_MHF_ENUMERATE_RANKING -type MsgMhfEnumerateRanking struct{} +type MsgMhfEnumerateRanking struct { + AckHandle uint32 + Unk0 uint16 // Hardcoded 0 in the binary + Unk1 uint16 // Hardcoded 0 in the binary +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfEnumerateRanking) Opcode() network.PacketID { @@ -15,10 +19,13 @@ func (m *MsgMhfEnumerateRanking) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfEnumerateRanking) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint16() + m.Unk1 = bf.ReadUint16() + return nil } // Build builds a binary packet from the current data. func (m *MsgMhfEnumerateRanking) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_mhf_get_etc_points.go b/network/mhfpacket/msg_mhf_get_etc_points.go index eab24144a..a6ece865b 100644 --- a/network/mhfpacket/msg_mhf_get_etc_points.go +++ b/network/mhfpacket/msg_mhf_get_etc_points.go @@ -15,10 +15,10 @@ func (m *MsgMhfGetEtcPoints) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfGetEtcPoints) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + return nil } // Build builds a binary packet from the current data. func (m *MsgMhfGetEtcPoints) Build(bf *byteframe.ByteFrame) error { - panic("Not implemented") -} \ No newline at end of file + return nil +} diff --git a/network/mhfpacket/msg_mhf_read_mercenary_w.go b/network/mhfpacket/msg_mhf_read_mercenary_w.go index 49c853949..27fe39eab 100644 --- a/network/mhfpacket/msg_mhf_read_mercenary_w.go +++ b/network/mhfpacket/msg_mhf_read_mercenary_w.go @@ -6,7 +6,12 @@ import ( ) // MsgMhfReadMercenaryW represents the MSG_MHF_READ_MERCENARY_W -type MsgMhfReadMercenaryW struct{} +type MsgMhfReadMercenaryW struct { + AckHandle uint32 + Unk0 uint8 + Unk1 uint8 + Unk2 uint16 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfReadMercenaryW) Opcode() network.PacketID { @@ -15,10 +20,13 @@ func (m *MsgMhfReadMercenaryW) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfReadMercenaryW) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint8() + m.Unk1 = bf.ReadUint8() + m.Unk2 = bf.ReadUint16() } // Build builds a binary packet from the current data. func (m *MsgMhfReadMercenaryW) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_mhf_update_etc_point.go b/network/mhfpacket/msg_mhf_update_etc_point.go index 6e7093be0..30ba76d69 100644 --- a/network/mhfpacket/msg_mhf_update_etc_point.go +++ b/network/mhfpacket/msg_mhf_update_etc_point.go @@ -6,7 +6,11 @@ import ( ) // MsgMhfUpdateEtcPoint represents the MSG_MHF_UPDATE_ETC_POINT -type MsgMhfUpdateEtcPoint struct{} +type MsgMhfUpdateEtcPoint struct { + AckHandle uint32 + Unk0 uint8 + Unk1 uint16 +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfUpdateEtcPoint) Opcode() network.PacketID { @@ -15,10 +19,12 @@ func (m *MsgMhfUpdateEtcPoint) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfUpdateEtcPoint) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint8() + m.Unk1 = bf.ReadUint16() } // Build builds a binary packet from the current data. func (m *MsgMhfUpdateEtcPoint) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_sys_ack.go b/network/mhfpacket/msg_sys_ack.go index 5e3ffe6fc..978e0f5d6 100644 --- a/network/mhfpacket/msg_sys_ack.go +++ b/network/mhfpacket/msg_sys_ack.go @@ -6,7 +6,11 @@ import ( ) // MsgSysAck represents the MSG_SYS_ACK -type MsgSysAck struct{} +type MsgSysAck struct { + AckHandle uint32 + Unk0 uint32 + Unk1 uint32 +} // Opcode returns the ID associated with this packet type. func (m *MsgSysAck) Opcode() network.PacketID { @@ -15,10 +19,17 @@ func (m *MsgSysAck) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgSysAck) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint32() + m.Unk1 = bf.ReadUint32() + + return nil } // Build builds a binary packet from the current data. func (m *MsgSysAck) Build(bf *byteframe.ByteFrame) error { - panic("Not implemented") -} \ No newline at end of file + bf.WriteUint32(m.AckHandle) + bf.WriteUint32(m.Unk0) + bf.WriteUint32(m.Unk1) + return nil +} diff --git a/network/mhfpacket/msg_sys_end.go b/network/mhfpacket/msg_sys_end.go index a4bb2e0de..f6c874657 100644 --- a/network/mhfpacket/msg_sys_end.go +++ b/network/mhfpacket/msg_sys_end.go @@ -15,10 +15,10 @@ func (m *MsgSysEnd) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgSysEnd) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + return nil } // Build builds a binary packet from the current data. func (m *MsgSysEnd) Build(bf *byteframe.ByteFrame) error { - panic("Not implemented") -} \ No newline at end of file + return nil +} diff --git a/network/mhfpacket/msg_sys_extend_threshold.go b/network/mhfpacket/msg_sys_extend_threshold.go index f03df77e7..f07dc384d 100644 --- a/network/mhfpacket/msg_sys_extend_threshold.go +++ b/network/mhfpacket/msg_sys_extend_threshold.go @@ -15,10 +15,10 @@ func (m *MsgSysExtendThreshold) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgSysExtendThreshold) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + return nil } // Build builds a binary packet from the current data. func (m *MsgSysExtendThreshold) Build(bf *byteframe.ByteFrame) error { - panic("Not implemented") + return nil } diff --git a/network/mhfpacket/msg_sys_login.go b/network/mhfpacket/msg_sys_login.go index 5694ada16..ef7af2d05 100644 --- a/network/mhfpacket/msg_sys_login.go +++ b/network/mhfpacket/msg_sys_login.go @@ -6,7 +6,17 @@ import ( ) // MsgSysLogin represents the MSG_SYS_LOGIN -type MsgSysLogin struct{} +type MsgSysLogin struct { + AckHandle uint32 + CharID0 uint32 + LoginTokenNumber uint32 + HardcodedZero0 uint16 + RequestVersion uint16 + CharID1 uint32 + HardcodedZero1 uint16 + LoginTokenStringLength uint16 // Hardcoded to 0x11 + LoginTokenString string +} // Opcode returns the ID associated with this packet type. func (m *MsgSysLogin) Opcode() network.PacketID { @@ -15,10 +25,20 @@ func (m *MsgSysLogin) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgSysLogin) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.CharID0 = bf.ReadUint32() + m.LoginTokenNumber = bf.ReadUint32() + m.HardcodedZero0 = bf.ReadUint16() + m.RequestVersion = bf.ReadUint16() + m.CharID1 = bf.ReadUint32() + m.HardcodedZero1 = bf.ReadUint16() + m.LoginTokenStringLength = bf.ReadUint16() + m.LoginTokenString = string(bf.ReadBytes(17)) // TODO(Andoryuuta): What encoding is this string? + + return nil } // Build builds a binary packet from the current data. func (m *MsgSysLogin) Build(bf *byteframe.ByteFrame) error { panic("Not implemented") -} \ No newline at end of file +} diff --git a/network/mhfpacket/msg_sys_nop.go b/network/mhfpacket/msg_sys_nop.go index 1fbc18376..e769142cd 100644 --- a/network/mhfpacket/msg_sys_nop.go +++ b/network/mhfpacket/msg_sys_nop.go @@ -15,10 +15,10 @@ func (m *MsgSysNop) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgSysNop) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + return nil } // Build builds a binary packet from the current data. func (m *MsgSysNop) Build(bf *byteframe.ByteFrame) error { - panic("Not implemented") -} \ No newline at end of file + return nil +} diff --git a/network/mhfpacket/msg_sys_ping.go b/network/mhfpacket/msg_sys_ping.go index 44c4fff12..ebbfe27ad 100644 --- a/network/mhfpacket/msg_sys_ping.go +++ b/network/mhfpacket/msg_sys_ping.go @@ -6,7 +6,10 @@ import ( ) // MsgSysPing represents the MSG_SYS_PING -type MsgSysPing struct{} +type MsgSysPing struct { + AckHandle uint32 + Unk0 uint16 +} // Opcode returns the ID associated with this packet type. func (m *MsgSysPing) Opcode() network.PacketID { @@ -15,10 +18,14 @@ func (m *MsgSysPing) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgSysPing) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint16() + return nil } // Build builds a binary packet from the current data. func (m *MsgSysPing) Build(bf *byteframe.ByteFrame) error { - panic("Not implemented") -} \ No newline at end of file + bf.WriteUint32(m.AckHandle) + bf.WriteUint16(m.Unk0) + return nil +} diff --git a/network/mhfpacket/msg_sys_time.go b/network/mhfpacket/msg_sys_time.go index 0f06e4b00..715a97161 100644 --- a/network/mhfpacket/msg_sys_time.go +++ b/network/mhfpacket/msg_sys_time.go @@ -6,7 +6,10 @@ import ( ) // MsgSysTime represents the MSG_SYS_TIME -type MsgSysTime struct{} +type MsgSysTime struct { + Unk0 uint8 + Timestamp uint32 // unix timestamp, e.g. 1577105879 +} // Opcode returns the ID associated with this packet type. func (m *MsgSysTime) Opcode() network.PacketID { @@ -15,10 +18,14 @@ func (m *MsgSysTime) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgSysTime) Parse(bf *byteframe.ByteFrame) error { - panic("Not implemented") + m.Unk0 = bf.ReadUint8() + m.Timestamp = bf.ReadUint32() + return nil } // Build builds a binary packet from the current data. func (m *MsgSysTime) Build(bf *byteframe.ByteFrame) error { - panic("Not implemented") -} \ No newline at end of file + bf.WriteUint8(m.Unk0) + bf.WriteUint32(m.Timestamp) + return nil +}