add packet types
This commit is contained in:
parent
98d1747c33
commit
04032cca4c
2 changed files with 10 additions and 3 deletions
|
|
@ -59,7 +59,7 @@ func (host *LuxHost) Heartbeat() error {
|
||||||
|
|
||||||
packet := net.LuxPacket{
|
packet := net.LuxPacket{
|
||||||
Target: host.router.GetThisKey().Id,
|
Target: host.router.GetThisKey().Id,
|
||||||
Type: 0x6969, // FIXME
|
Type: net.LuxPacketTypeHeartbeat,
|
||||||
Buffer: proto.NewLuxBuffer(),
|
Buffer: proto.NewLuxBuffer(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,13 @@ import (
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type LuxPacketType uint
|
||||||
|
|
||||||
|
const (
|
||||||
|
LuxPacketTypeHeartbeat = 0
|
||||||
|
LuxPacketTypeSync = 1
|
||||||
|
)
|
||||||
|
|
||||||
const LUX_PROTO_PACKET_HDRLEN = proto.LUX_PROTO_ID_SIZE + 2
|
const LUX_PROTO_PACKET_HDRLEN = proto.LUX_PROTO_ID_SIZE + 2
|
||||||
|
|
||||||
// Target, Type are decoded from header
|
// Target, Type are decoded from header
|
||||||
|
|
@ -22,7 +29,7 @@ const LUX_PROTO_PACKET_HDRLEN = proto.LUX_PROTO_ID_SIZE + 2
|
||||||
// associated key with route.
|
// associated key with route.
|
||||||
type LuxPacket struct {
|
type LuxPacket struct {
|
||||||
Target proto.LuxID
|
Target proto.LuxID
|
||||||
Type uint
|
Type LuxPacketType
|
||||||
Buffer proto.LuxBuffer
|
Buffer proto.LuxBuffer
|
||||||
ChannelType LuxChannelType
|
ChannelType LuxChannelType
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +58,7 @@ func DecryptLuxPacket(dgram LuxDatagram, key crypto.LuxKey) (LuxPacket, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if pType, err := packet.Buffer.ReadUint16(); err == nil {
|
if pType, err := packet.Buffer.ReadUint16(); err == nil {
|
||||||
packet.Type = uint(pType)
|
packet.Type = LuxPacketType(pType)
|
||||||
} else {
|
} else {
|
||||||
return packet, err
|
return packet, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue