mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
make wire an internal package
This commit is contained in:
parent
1794636220
commit
ed522ebbce
58 changed files with 32 additions and 31 deletions
26
internal/wire/version_negotiation.go
Normal file
26
internal/wire/version_negotiation.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package wire
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||
"github.com/lucas-clemente/quic-go/protocol"
|
||||
)
|
||||
|
||||
// ComposeVersionNegotiation composes a Version Negotiation Packet
|
||||
func ComposeVersionNegotiation(connectionID protocol.ConnectionID, versions []protocol.VersionNumber) []byte {
|
||||
fullReply := &bytes.Buffer{}
|
||||
responsePublicHeader := PublicHeader{
|
||||
ConnectionID: connectionID,
|
||||
PacketNumber: 1,
|
||||
VersionFlag: true,
|
||||
}
|
||||
err := responsePublicHeader.Write(fullReply, protocol.VersionWhatever, protocol.PerspectiveServer)
|
||||
if err != nil {
|
||||
utils.Errorf("error composing version negotiation packet: %s", err.Error())
|
||||
}
|
||||
for _, v := range versions {
|
||||
utils.LittleEndian.WriteUint32(fullReply, protocol.VersionNumberToTag(v))
|
||||
}
|
||||
return fullReply.Bytes()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue