Пример #1
0
func (opt *LossDigestOption) Encode() (*dccp.Option, error) {
	d := make([]byte, 5)
	dccp.EncodeUint32(opt.RateInv, d)
	dccp.EncodeUint8(opt.NewLossCount, d[4:])
	return &dccp.Option{
		Type:      OptionLossDigest,
		Data:      d,
		Mandatory: false,
	}, nil
}
Пример #2
0
func (opt *LossIntervalsOption) Encode() (*dccp.Option, error) {
	if opt.SkipLength > NDUPACK {
		return nil, dccp.ErrOverflow
	}
	if len(opt.LossIntervals) > MaxLossIntervals {
		return nil, dccp.ErrOverflow
	}
	d := make([]byte, 1+lossIntervalFootprint*len(opt.LossIntervals))
	dccp.EncodeUint8(opt.SkipLength, d[0:1])
	for i, lossInterval := range opt.LossIntervals {
		j := 1 + i*lossIntervalFootprint
		if lossInterval.encode(d[j:j+lossIntervalFootprint]) != nil {
			return nil, nil
		}
	}
	return &dccp.Option{
		Type:      OptionLossIntervals,
		Data:      d,
		Mandatory: false,
	}, nil
}