Implement some packet parsers

This commit is contained in:
Andrew Gutekanst
2019-12-27 04:01:29 +09:00
parent e38b725662
commit d1a9d5a7d0
13 changed files with 127 additions and 41 deletions

View File

@@ -6,7 +6,11 @@ import (
) )
// MsgMhfEnumerateEvent represents the MSG_MHF_ENUMERATE_EVENT // 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. // Opcode returns the ID associated with this packet type.
func (m *MsgMhfEnumerateEvent) Opcode() network.PacketID { func (m *MsgMhfEnumerateEvent) Opcode() network.PacketID {
@@ -15,10 +19,13 @@ func (m *MsgMhfEnumerateEvent) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgMhfEnumerateEvent) Parse(bf *byteframe.ByteFrame) error { 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. // Build builds a binary packet from the current data.
func (m *MsgMhfEnumerateEvent) Build(bf *byteframe.ByteFrame) error { func (m *MsgMhfEnumerateEvent) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") panic("Not implemented")
} }

View File

@@ -6,7 +6,14 @@ import (
) )
// MsgMhfEnumerateQuest represents the MSG_MHF_ENUMERATE_QUEST // 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. // Opcode returns the ID associated with this packet type.
func (m *MsgMhfEnumerateQuest) Opcode() network.PacketID { func (m *MsgMhfEnumerateQuest) Opcode() network.PacketID {
@@ -15,10 +22,16 @@ func (m *MsgMhfEnumerateQuest) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgMhfEnumerateQuest) Parse(bf *byteframe.ByteFrame) error { 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. // Build builds a binary packet from the current data.
func (m *MsgMhfEnumerateQuest) Build(bf *byteframe.ByteFrame) error { func (m *MsgMhfEnumerateQuest) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") panic("Not implemented")
} }

View File

@@ -6,7 +6,11 @@ import (
) )
// MsgMhfEnumerateRanking represents the MSG_MHF_ENUMERATE_RANKING // 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. // Opcode returns the ID associated with this packet type.
func (m *MsgMhfEnumerateRanking) Opcode() network.PacketID { func (m *MsgMhfEnumerateRanking) Opcode() network.PacketID {
@@ -15,10 +19,13 @@ func (m *MsgMhfEnumerateRanking) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgMhfEnumerateRanking) Parse(bf *byteframe.ByteFrame) error { 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. // Build builds a binary packet from the current data.
func (m *MsgMhfEnumerateRanking) Build(bf *byteframe.ByteFrame) error { func (m *MsgMhfEnumerateRanking) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") panic("Not implemented")
} }

View File

@@ -15,10 +15,10 @@ func (m *MsgMhfGetEtcPoints) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgMhfGetEtcPoints) Parse(bf *byteframe.ByteFrame) error { func (m *MsgMhfGetEtcPoints) Parse(bf *byteframe.ByteFrame) error {
panic("Not implemented") return nil
} }
// Build builds a binary packet from the current data. // Build builds a binary packet from the current data.
func (m *MsgMhfGetEtcPoints) Build(bf *byteframe.ByteFrame) error { func (m *MsgMhfGetEtcPoints) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") return nil
} }

View File

@@ -6,7 +6,12 @@ import (
) )
// MsgMhfReadMercenaryW represents the MSG_MHF_READ_MERCENARY_W // 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. // Opcode returns the ID associated with this packet type.
func (m *MsgMhfReadMercenaryW) Opcode() network.PacketID { func (m *MsgMhfReadMercenaryW) Opcode() network.PacketID {
@@ -15,10 +20,13 @@ func (m *MsgMhfReadMercenaryW) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgMhfReadMercenaryW) Parse(bf *byteframe.ByteFrame) error { 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. // Build builds a binary packet from the current data.
func (m *MsgMhfReadMercenaryW) Build(bf *byteframe.ByteFrame) error { func (m *MsgMhfReadMercenaryW) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") panic("Not implemented")
} }

View File

@@ -6,7 +6,11 @@ import (
) )
// MsgMhfUpdateEtcPoint represents the MSG_MHF_UPDATE_ETC_POINT // 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. // Opcode returns the ID associated with this packet type.
func (m *MsgMhfUpdateEtcPoint) Opcode() network.PacketID { func (m *MsgMhfUpdateEtcPoint) Opcode() network.PacketID {
@@ -15,10 +19,12 @@ func (m *MsgMhfUpdateEtcPoint) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgMhfUpdateEtcPoint) Parse(bf *byteframe.ByteFrame) error { 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. // Build builds a binary packet from the current data.
func (m *MsgMhfUpdateEtcPoint) Build(bf *byteframe.ByteFrame) error { func (m *MsgMhfUpdateEtcPoint) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") panic("Not implemented")
} }

View File

@@ -6,7 +6,11 @@ import (
) )
// MsgSysAck represents the MSG_SYS_ACK // 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. // Opcode returns the ID associated with this packet type.
func (m *MsgSysAck) Opcode() network.PacketID { func (m *MsgSysAck) Opcode() network.PacketID {
@@ -15,10 +19,17 @@ func (m *MsgSysAck) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgSysAck) Parse(bf *byteframe.ByteFrame) error { 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. // Build builds a binary packet from the current data.
func (m *MsgSysAck) Build(bf *byteframe.ByteFrame) error { func (m *MsgSysAck) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") bf.WriteUint32(m.AckHandle)
} bf.WriteUint32(m.Unk0)
bf.WriteUint32(m.Unk1)
return nil
}

View File

@@ -15,10 +15,10 @@ func (m *MsgSysEnd) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgSysEnd) Parse(bf *byteframe.ByteFrame) error { func (m *MsgSysEnd) Parse(bf *byteframe.ByteFrame) error {
panic("Not implemented") return nil
} }
// Build builds a binary packet from the current data. // Build builds a binary packet from the current data.
func (m *MsgSysEnd) Build(bf *byteframe.ByteFrame) error { func (m *MsgSysEnd) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") return nil
} }

View File

@@ -15,10 +15,10 @@ func (m *MsgSysExtendThreshold) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgSysExtendThreshold) Parse(bf *byteframe.ByteFrame) error { func (m *MsgSysExtendThreshold) Parse(bf *byteframe.ByteFrame) error {
panic("Not implemented") return nil
} }
// Build builds a binary packet from the current data. // Build builds a binary packet from the current data.
func (m *MsgSysExtendThreshold) Build(bf *byteframe.ByteFrame) error { func (m *MsgSysExtendThreshold) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") return nil
} }

View File

@@ -6,7 +6,17 @@ import (
) )
// MsgSysLogin represents the MSG_SYS_LOGIN // 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. // Opcode returns the ID associated with this packet type.
func (m *MsgSysLogin) Opcode() network.PacketID { func (m *MsgSysLogin) Opcode() network.PacketID {
@@ -15,10 +25,20 @@ func (m *MsgSysLogin) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgSysLogin) Parse(bf *byteframe.ByteFrame) error { 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. // Build builds a binary packet from the current data.
func (m *MsgSysLogin) Build(bf *byteframe.ByteFrame) error { func (m *MsgSysLogin) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") panic("Not implemented")
} }

View File

@@ -15,10 +15,10 @@ func (m *MsgSysNop) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgSysNop) Parse(bf *byteframe.ByteFrame) error { func (m *MsgSysNop) Parse(bf *byteframe.ByteFrame) error {
panic("Not implemented") return nil
} }
// Build builds a binary packet from the current data. // Build builds a binary packet from the current data.
func (m *MsgSysNop) Build(bf *byteframe.ByteFrame) error { func (m *MsgSysNop) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") return nil
} }

View File

@@ -6,7 +6,10 @@ import (
) )
// MsgSysPing represents the MSG_SYS_PING // 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. // Opcode returns the ID associated with this packet type.
func (m *MsgSysPing) Opcode() network.PacketID { func (m *MsgSysPing) Opcode() network.PacketID {
@@ -15,10 +18,14 @@ func (m *MsgSysPing) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgSysPing) Parse(bf *byteframe.ByteFrame) error { 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. // Build builds a binary packet from the current data.
func (m *MsgSysPing) Build(bf *byteframe.ByteFrame) error { func (m *MsgSysPing) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") bf.WriteUint32(m.AckHandle)
} bf.WriteUint16(m.Unk0)
return nil
}

View File

@@ -6,7 +6,10 @@ import (
) )
// MsgSysTime represents the MSG_SYS_TIME // 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. // Opcode returns the ID associated with this packet type.
func (m *MsgSysTime) Opcode() network.PacketID { func (m *MsgSysTime) Opcode() network.PacketID {
@@ -15,10 +18,14 @@ func (m *MsgSysTime) Opcode() network.PacketID {
// Parse parses the packet from binary // Parse parses the packet from binary
func (m *MsgSysTime) Parse(bf *byteframe.ByteFrame) error { 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. // Build builds a binary packet from the current data.
func (m *MsgSysTime) Build(bf *byteframe.ByteFrame) error { func (m *MsgSysTime) Build(bf *byteframe.ByteFrame) error {
panic("Not implemented") bf.WriteUint8(m.Unk0)
} bf.WriteUint32(m.Timestamp)
return nil
}