mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-06 21:57:36 +03:00
introduce protocol/version.go and remove big endian functions
This commit is contained in:
parent
052822aea5
commit
b6c9c9b6a4
8 changed files with 57 additions and 74 deletions
|
@ -38,25 +38,6 @@ func ReadUint32(b io.ByteReader) (uint32, error) {
|
|||
return uint32(b1) + uint32(b2)<<8 + uint32(b3)<<16 + uint32(b4)<<24, nil
|
||||
}
|
||||
|
||||
// ReadUint32BigEndian reads a uint32 Big Endian
|
||||
func ReadUint32BigEndian(b io.ByteReader) (uint32, error) {
|
||||
var b1, b2, b3, b4 uint8
|
||||
var err error
|
||||
if b1, err = b.ReadByte(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if b2, err = b.ReadByte(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if b3, err = b.ReadByte(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if b4, err = b.ReadByte(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint32(b4) + uint32(b3)<<8 + uint32(b2)<<16 + uint32(b1)<<24, nil
|
||||
}
|
||||
|
||||
// ReadUint16 reads a uint16
|
||||
func ReadUint16(b io.ByteReader) (uint16, error) {
|
||||
var b1, b2 uint8
|
||||
|
@ -90,14 +71,6 @@ func WriteUint32(b *bytes.Buffer, i uint32) {
|
|||
b.WriteByte(uint8((i >> 24) & 0xff))
|
||||
}
|
||||
|
||||
// WriteUint32BigEndian writes a uint32
|
||||
func WriteUint32BigEndian(b *bytes.Buffer, i uint32) {
|
||||
b.WriteByte(uint8((i >> 24) & 0xff))
|
||||
b.WriteByte(uint8((i >> 16) & 0xff))
|
||||
b.WriteByte(uint8((i >> 8) & 0xff))
|
||||
b.WriteByte(uint8(i & 0xff))
|
||||
}
|
||||
|
||||
// WriteUint16 writes a uint16
|
||||
func WriteUint16(b *bytes.Buffer, i uint16) {
|
||||
b.WriteByte(uint8(i & 0xff))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue