github.com/metacubex/quic-go@v0.44.1-0.20240520163451-20b689a59136/internal/wire/path_challenge_frame.go (about)

     1  package wire
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/metacubex/quic-go/internal/protocol"
     7  )
     8  
     9  // A PathChallengeFrame is a PATH_CHALLENGE frame
    10  type PathChallengeFrame struct {
    11  	Data [8]byte
    12  }
    13  
    14  func parsePathChallengeFrame(b []byte, _ protocol.Version) (*PathChallengeFrame, int, error) {
    15  	f := &PathChallengeFrame{}
    16  	if len(b) < 8 {
    17  		return nil, 0, io.EOF
    18  	}
    19  	copy(f.Data[:], b)
    20  	return f, 8, nil
    21  }
    22  
    23  func (f *PathChallengeFrame) Append(b []byte, _ protocol.Version) ([]byte, error) {
    24  	b = append(b, pathChallengeFrameType)
    25  	b = append(b, f.Data[:]...)
    26  	return b, nil
    27  }
    28  
    29  // Length of a written frame
    30  func (f *PathChallengeFrame) Length(_ protocol.Version) protocol.ByteCount {
    31  	return 1 + 8
    32  }