mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
33 lines
601 B
Go
33 lines
601 B
Go
package frames
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/lucas-clemente/quic-go/protocol"
|
|
)
|
|
|
|
// A PingFrame is a ping frame
|
|
type PingFrame struct{}
|
|
|
|
// ParsePingFrame parses a Ping frame
|
|
func ParsePingFrame(r *bytes.Reader) (*PingFrame, error) {
|
|
frame := &PingFrame{}
|
|
|
|
_, err := r.ReadByte()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return frame, nil
|
|
}
|
|
|
|
func (f *PingFrame) Write(b *bytes.Buffer, packetNumber protocol.PacketNumber, packetNumberLen uint8) error {
|
|
typeByte := uint8(0x07)
|
|
b.WriteByte(typeByte)
|
|
return nil
|
|
}
|
|
|
|
// MinLength of a written frame
|
|
func (f *PingFrame) MinLength() int {
|
|
return 1
|
|
}
|