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
|
2018-01-20 18:07:01 +00:00
|
|
|
func (f *PingFrame) MinLength(version protocol.VersionNumber) protocol.ByteCount {
|
|
|
|
return 1
|
2017-12-12 02:51:45 +00:00
|
|
|
}
|