2018-02-17 00:29:53 -05:00
|
|
|
package wire
|
2017-05-27 14:30:11 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
2018-02-17 00:29:53 -05:00
|
|
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
2017-05-27 14:30:11 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// A PingFrame is a ping frame
|
|
|
|
type PingFrame struct{}
|
|
|
|
|
2018-04-18 16:48:08 -05:00
|
|
|
// parsePingFrame parses a Ping frame
|
|
|
|
func parsePingFrame(r *bytes.Reader, version protocol.VersionNumber) (*PingFrame, error) {
|
2017-05-27 14:30:11 -05: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
|
|
|
|
}
|
|
|
|
|
2018-02-17 00:29:53 -05:00
|
|
|
// Length of a written frame
|
|
|
|
func (f *PingFrame) Length(version protocol.VersionNumber) protocol.ByteCount {
|
|
|
|
return 1
|
2017-05-27 14:30:11 -05:00
|
|
|
}
|