35 lines
607 B
Go
35 lines
607 B
Go
package packets
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"io"
|
|
)
|
|
|
|
|
|
type PingreqPacket struct {}
|
|
|
|
func ParesPingreq(control controlPacket) (PingreqPacket, error) {
|
|
packet := PingreqPacket{}
|
|
|
|
if control.packetType != PacketTypePingreq {
|
|
panic("Wrong packet type for parsePingreq")
|
|
}
|
|
if control.flags != 0 {
|
|
return packet, errors.New("Malformed connect packet")
|
|
}
|
|
|
|
return packet, nil
|
|
}
|
|
|
|
type PingrespPacket struct {}
|
|
|
|
func (p PingrespPacket) Write(w io.Writer) error {
|
|
control := controlPacket {
|
|
packetType: PacketTypePingresp,
|
|
flags: 0,
|
|
reader: bytes.NewReader([]byte{}),
|
|
}
|
|
|
|
return control.write(w)
|
|
}
|