github.com/apernet/quic-go@v0.43.1-0.20240515053213-5e9e635fd9f0/internal/wire/path_challenge_frame.go (about) 1 package wire 2 3 import ( 4 "bytes" 5 "io" 6 7 "github.com/apernet/quic-go/internal/protocol" 8 ) 9 10 // A PathChallengeFrame is a PATH_CHALLENGE frame 11 type PathChallengeFrame struct { 12 Data [8]byte 13 } 14 15 func parsePathChallengeFrame(r *bytes.Reader, _ protocol.Version) (*PathChallengeFrame, error) { 16 frame := &PathChallengeFrame{} 17 if _, err := io.ReadFull(r, frame.Data[:]); err != nil { 18 if err == io.ErrUnexpectedEOF { 19 return nil, io.EOF 20 } 21 return nil, err 22 } 23 return frame, nil 24 } 25 26 func (f *PathChallengeFrame) Append(b []byte, _ protocol.Version) ([]byte, error) { 27 b = append(b, pathChallengeFrameType) 28 b = append(b, f.Data[:]...) 29 return b, nil 30 } 31 32 // Length of a written frame 33 func (f *PathChallengeFrame) Length(_ protocol.Version) protocol.ByteCount { 34 return 1 + 8 35 }