• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang common.BytesToUint24函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/SlyMarbo/spdy/common.BytesToUint24函数的典型用法代码示例。如果您正苦于以下问题:Golang BytesToUint24函数的具体用法?Golang BytesToUint24怎么用?Golang BytesToUint24使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了BytesToUint24函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: ReadFrom

func (frame *WINDOW_UPDATE) ReadFrom(reader io.Reader) (int64, error) {
	c := common.ReadCounter{R: reader}
	data, err := common.ReadExactly(&c, 16)
	if err != nil {
		return c.N, err
	}

	err = controlFrameCommonProcessing(data[:5], _WINDOW_UPDATE, 0)
	if err != nil {
		return c.N, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length != 8 {
		return c.N, common.IncorrectDataLength(length, 8)
	}

	frame.StreamID = common.StreamID(common.BytesToUint32(data[8:12]))
	frame.DeltaWindowSize = common.BytesToUint32(data[12:16])

	if !frame.StreamID.Valid() {
		return c.N, common.StreamIdTooLarge
	}
	if frame.StreamID.Zero() {
		return c.N, common.StreamIdIsZero
	}
	if frame.DeltaWindowSize > common.MAX_DELTA_WINDOW_SIZE {
		return c.N, errors.New("Error: Delta Window Size too large.")
	}

	return c.N, nil
}
开发者ID:vonwenm,项目名称:spdy,代码行数:33,代码来源:window_update.go


示例2: ReadFrom

func (frame *RST_STREAM) ReadFrom(reader io.Reader) (int64, error) {
	c := common.ReadCounter{R: reader}
	data, err := common.ReadExactly(&c, 16)
	if err != nil {
		return c.N, err
	}

	err = controlFrameCommonProcessing(data[:5], _RST_STREAM, 0)
	if err != nil {
		return c.N, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length != 8 {
		return c.N, common.IncorrectDataLength(length, 8)
	} else if length > common.MAX_FRAME_SIZE-8 {
		return c.N, common.FrameTooLarge
	}

	frame.StreamID = common.StreamID(common.BytesToUint32(data[8:12]))
	frame.Status = common.StatusCode(common.BytesToUint32(data[12:16]))

	if !frame.StreamID.Valid() {
		return c.N, common.StreamIdTooLarge
	}

	return c.N, nil
}
开发者ID:vonwenm,项目名称:spdy,代码行数:29,代码来源:rst_stream.go


示例3: ReadFrom

func (frame *GOAWAY) ReadFrom(reader io.Reader) (int64, error) {
	data, err := common.ReadExactly(reader, 16)
	if err != nil {
		return 0, err
	}

	err = controlFrameCommonProcessing(data[:5], _GOAWAY, 0)
	if err != nil {
		return 16, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length != 8 {
		return 16, common.IncorrectDataLength(length, 8)
	}

	frame.LastGoodStreamID = common.StreamID(common.BytesToUint32(data[8:12]))
	frame.Status = common.StatusCode(common.BytesToUint32(data[12:16]))

	if !frame.LastGoodStreamID.Valid() {
		return 16, common.StreamIdTooLarge
	}

	return 16, nil
}
开发者ID:rnapier,项目名称:spdy,代码行数:26,代码来源:goaway.go


示例4: ReadFrom

func (frame *SYN_REPLY) ReadFrom(reader io.Reader) (int64, error) {
	data, err := common.ReadExactly(reader, 12)
	if err != nil {
		return 0, err
	}

	err = controlFrameCommonProcessing(data[:5], _SYN_REPLY, common.FLAG_FIN)
	if err != nil {
		return 12, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length < 4 {
		return 12, common.IncorrectDataLength(length, 4)
	} else if length > common.MAX_FRAME_SIZE-8 {
		return 12, common.FrameTooLarge
	}

	// Read in data.
	header, err := common.ReadExactly(reader, length-4)
	if err != nil {
		return 12, err
	}

	frame.Flags = common.Flags(data[4])
	frame.StreamID = common.StreamID(common.BytesToUint32(data[8:12]))
	frame.rawHeader = header

	return int64(length + 8), nil
}
开发者ID:rnapier,项目名称:spdy,代码行数:31,代码来源:syn_reply.go


示例5: ReadFrom

func (frame *GOAWAY) ReadFrom(reader io.Reader) (int64, error) {
	c := common.ReadCounter{R: reader}
	data, err := common.ReadExactly(&c, 12)
	if err != nil {
		return c.N, err
	}

	err = controlFrameCommonProcessing(data[:5], _GOAWAY, 0)
	if err != nil {
		return c.N, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length != 4 {
		return c.N, common.IncorrectDataLength(length, 4)
	}

	frame.LastGoodStreamID = common.StreamID(common.BytesToUint32(data[8:12]))

	if !frame.LastGoodStreamID.Valid() {
		return c.N, common.StreamIdTooLarge
	}

	return c.N, nil
}
开发者ID:vonwenm,项目名称:spdy,代码行数:26,代码来源:goaway.go


示例6: decodeSetting

func decodeSetting(data []byte) *common.Setting {
	if len(data) < 8 {
		return nil
	}

	setting := new(common.Setting)
	setting.Flags = common.Flags(data[0])
	setting.ID = common.BytesToUint24(data[1:])
	setting.Value = common.BytesToUint32(data[4:])

	return setting
}
开发者ID:vonwenm,项目名称:spdy,代码行数:12,代码来源:settings.go


示例7: ReadFrom

func (frame *CREDENTIAL) ReadFrom(reader io.Reader) (int64, error) {
	c := common.ReadCounter{R: reader}
	data, err := common.ReadExactly(&c, 18)
	if err != nil {
		return c.N, err
	}

	err = controlFrameCommonProcessing(data[:5], _CREDENTIAL, 0)
	if err != nil {
		return c.N, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length < 6 {
		return c.N, common.IncorrectDataLength(length, 6)
	} else if length > common.MAX_FRAME_SIZE-8 {
		return c.N, common.FrameTooLarge
	}

	// Read in data.
	certs, err := common.ReadExactly(&c, length-10)
	if err != nil {
		return c.N, err
	}

	frame.Slot = common.BytesToUint16(data[8:10])
	proofLen := int(common.BytesToUint32(data[10:14]))
	if proofLen > 0 {
		frame.Proof = data[14 : 14+proofLen]
	} else {
		frame.Proof = []byte{}
	}

	numCerts := 0
	for offset := 0; offset < length-10; {
		offset += int(common.BytesToUint32(certs[offset:offset+4])) + 4
		numCerts++
	}

	frame.Certificates = make([]*x509.Certificate, numCerts)
	for i, offset := 0, 0; offset < length-10; i++ {
		length := int(common.BytesToUint32(certs[offset : offset+4]))
		rawCert := certs[offset+4 : offset+4+length]
		frame.Certificates[i], err = x509.ParseCertificate(rawCert)
		if err != nil {
			return c.N, err
		}
		offset += length + 4
	}

	return c.N, nil
}
开发者ID:vonwenm,项目名称:spdy,代码行数:53,代码来源:credential.go


示例8: ReadFrom

func (frame *SETTINGS) ReadFrom(reader io.Reader) (int64, error) {
	c := common.ReadCounter{R: reader}

	data, err := common.ReadExactly(&c, 12)
	if err != nil {
		return c.N, err
	}

	err = controlFrameCommonProcessing(data[:5], _SETTINGS, common.FLAG_SETTINGS_CLEAR_SETTINGS)
	if err != nil {
		return c.N, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length < 4 {
		return c.N, common.IncorrectDataLength(length, 8)
	} else if length > common.MAX_FRAME_SIZE-8 {
		return c.N, common.FrameTooLarge
	}

	// Check size.
	numSettings := int(common.BytesToUint32(data[8:12]))
	if length != 4+(8*numSettings) {
		return c.N, common.IncorrectDataLength(length, 4+(8*numSettings))
	}

	// Read in data.
	settings, err := common.ReadExactly(&c, 8*numSettings)
	if err != nil {
		return c.N, err
	}

	frame.Flags = common.Flags(data[4])
	frame.Settings = make(common.Settings)
	for i := 0; i < numSettings; i++ {
		j := i * 8
		setting := decodeSetting(settings[j:])
		if setting == nil {
			return c.N, errors.New("Error: Failed to parse settings.")
		}
		frame.Settings[setting.ID] = setting
	}

	return c.N, nil
}
开发者ID:vonwenm,项目名称:spdy,代码行数:46,代码来源:settings.go


示例9: ReadFrom

func (frame *SYN_STREAM) ReadFrom(reader io.Reader) (int64, error) {
	c := common.ReadCounter{R: reader}
	data, err := common.ReadExactly(&c, 18)
	if err != nil {
		return c.N, err
	}

	err = controlFrameCommonProcessing(data[:5], _SYN_STREAM, common.FLAG_FIN|common.FLAG_UNIDIRECTIONAL)
	if err != nil {
		return c.N, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length < 10 {
		return c.N, common.IncorrectDataLength(length, 10)
	} else if length > common.MAX_FRAME_SIZE-18 {
		return c.N, common.FrameTooLarge
	}

	// Read in data.
	header, err := common.ReadExactly(&c, length-10)
	if err != nil {
		return c.N, err
	}

	frame.Flags = common.Flags(data[4])
	frame.StreamID = common.StreamID(common.BytesToUint32(data[8:12]))
	frame.AssocStreamID = common.StreamID(common.BytesToUint32(data[12:16]))
	frame.Priority = common.Priority(data[16] >> 5)
	frame.Slot = data[17]
	frame.rawHeader = header

	if !frame.StreamID.Valid() {
		return c.N, common.StreamIdTooLarge
	}
	if frame.StreamID.Zero() {
		return c.N, common.StreamIdIsZero
	}
	if !frame.AssocStreamID.Valid() {
		return c.N, common.StreamIdTooLarge
	}

	return c.N, nil
}
开发者ID:vonwenm,项目名称:spdy,代码行数:45,代码来源:syn_stream.go


示例10: ReadFrom

func (frame *NOOP) ReadFrom(reader io.Reader) (int64, error) {
	data, err := common.ReadExactly(reader, 8)
	if err != nil {
		return 0, err
	}

	err = controlFrameCommonProcessing(data[:5], _NOOP, 0)
	if err != nil {
		return 8, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length != 0 {
		return 8, common.IncorrectDataLength(length, 0)
	}

	return 8, nil
}
开发者ID:rnapier,项目名称:spdy,代码行数:19,代码来源:noop.go


示例11: ReadFrom

func (frame *DATA) ReadFrom(reader io.Reader) (int64, error) {
	c := common.ReadCounter{R: reader}
	data, err := common.ReadExactly(&c, 8)
	if err != nil {
		return c.N, err
	}

	// Check it's a data frame.
	if data[0]&0x80 == 1 {
		return c.N, common.IncorrectFrame(_CONTROL_FRAME, _DATA_FRAME, 3)
	}

	// Check flags.
	if data[4] & ^byte(common.FLAG_FIN) != 0 {
		return c.N, common.InvalidField("flags", int(data[4]), common.FLAG_FIN)
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length == 0 && data[4] == 0 {
		return c.N, common.IncorrectDataLength(length, 1)
	} else if length > common.MAX_FRAME_SIZE-8 {
		return c.N, common.FrameTooLarge
	}

	// Read in data.
	if length != 0 {
		frame.Data, err = common.ReadExactly(&c, length)
		if err != nil {
			return c.N, err
		}
	}

	frame.StreamID = common.StreamID(common.BytesToUint32(data[0:4]))
	frame.Flags = common.Flags(data[4])
	if frame.Data == nil {
		frame.Data = []byte{}
	}

	return c.N, nil
}
开发者ID:vonwenm,项目名称:spdy,代码行数:41,代码来源:data.go


示例12: ReadFrom

func (frame *PING) ReadFrom(reader io.Reader) (int64, error) {
	data, err := common.ReadExactly(reader, 12)
	if err != nil {
		return 0, err
	}

	err = controlFrameCommonProcessing(data[:5], _PING, 0)
	if err != nil {
		return 12, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length != 4 {
		return 12, common.IncorrectDataLength(length, 4)
	}

	frame.PingID = common.BytesToUint32(data[8:12])

	return 12, nil
}
开发者ID:rnapier,项目名称:spdy,代码行数:21,代码来源:ping.go


示例13: ReadFrom

func (frame *HEADERS) ReadFrom(reader io.Reader) (int64, error) {
	c := common.ReadCounter{R: reader}
	data, err := common.ReadExactly(&c, 16)
	if err != nil {
		return c.N, err
	}

	err = controlFrameCommonProcessing(data[:5], _HEADERS, common.FLAG_FIN)
	if err != nil {
		return c.N, err
	}

	// Get and check length.
	length := int(common.BytesToUint24(data[5:8]))
	if length < 6 {
		return c.N, common.IncorrectDataLength(length, 6)
	} else if length > common.MAX_FRAME_SIZE-8 {
		return c.N, common.FrameTooLarge
	}

	// Read in data.
	header, err := common.ReadExactly(&c, length-8)
	if err != nil {
		return c.N, err
	}

	frame.Flags = common.Flags(data[4])
	frame.StreamID = common.StreamID(common.BytesToUint32(data[8:12]))
	frame.rawHeader = header

	if !frame.StreamID.Valid() {
		return c.N, common.StreamIdTooLarge
	}
	if frame.StreamID.Zero() {
		return c.N, common.StreamIdIsZero
	}

	return c.N, nil
}
开发者ID:vonwenm,项目名称:spdy,代码行数:39,代码来源:headers.go



注:本文中的github.com/SlyMarbo/spdy/common.BytesToUint24函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang common.BytesToUint32函数代码示例发布时间:2022-05-28
下一篇:
Golang rss.Fetch函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap