make wire an internal package

This commit is contained in:
Marten Seemann 2017-08-29 23:51:56 +07:00
parent 1794636220
commit ed522ebbce
58 changed files with 32 additions and 31 deletions

View 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()
}