Пример #1
0
func DecodeLossDigestOption(opt *dccp.Option) *LossDigestOption {
	if opt.Type != OptionLossDigest || len(opt.Data) != 5 {
		return nil
	}
	return &LossDigestOption{
		RateInv:      dccp.DecodeUint32(opt.Data[0:4]),
		NewLossCount: dccp.DecodeUint8(opt.Data[4:5]),
	}
}
Пример #2
0
func DecodeLossIntervalsOption(opt *dccp.Option) *LossIntervalsOption {
	if opt.Type != OptionLossIntervals || len(opt.Data) < 1 {
		return nil
	}
	k, r := (len(opt.Data)-1)/lossIntervalFootprint, (len(opt.Data)-1)%lossIntervalFootprint
	if k > MaxLossIntervals || r != 0 {
		return nil
	}
	skip := dccp.DecodeUint8(opt.Data[0:1])
	intervals := make([]*LossInterval, k)
	for i := 0; i < k; i++ {
		start := 1 + lossIntervalFootprint*i
		intervals[i] = decodeLossInterval(opt.Data[start : start+lossIntervalFootprint])
		if intervals[i] == nil {
			return nil
		}
	}
	return &LossIntervalsOption{
		SkipLength:    skip,
		LossIntervals: intervals,
	}
}