route/vendor/github.com/lucas-clemente/quic-go/internal/wire/ping_frame.go

34 lines
672 B
Go
Raw Normal View History

2018-01-03 19:19:49 +00:00
package wire
2017-12-12 02:51:45 +00:00
import (
"bytes"
2018-01-03 19:19:49 +00:00
"github.com/lucas-clemente/quic-go/internal/protocol"
2017-12-12 02:51:45 +00:00
)
// A PingFrame is a ping frame
type PingFrame struct{}
// ParsePingFrame parses a Ping frame
2018-01-03 19:19:49 +00:00
func ParsePingFrame(r *bytes.Reader, version protocol.VersionNumber) (*PingFrame, error) {
2017-12-12 02:51:45 +00:00
frame := &PingFrame{}
_, err := r.ReadByte()
if err != nil {
return nil, err
}
return frame, nil
}
func (f *PingFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
typeByte := uint8(0x07)
b.WriteByte(typeByte)
return nil
}
// MinLength of a written frame
func (f *PingFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error) {
return 1, nil
}