Beispiel #1
0
func parseFlowErrorRequest(r *xio.PacketReader) (*flowErrorRequest, error) {
	var err error
	fid := uint64(0)
	if fid, err = r.Read7BitValue64(); err != nil {
		return nil, errors.New("flowerror.read fid")
	}
	return &flowErrorRequest{fid}, nil
}
Beispiel #2
0
func parseFlowAckRequest(r *xio.PacketReader) (*flowAckRequest, error) {
	var err error
	fid := uint64(0)
	if fid, err = r.Read7BitValue64(); err != nil {
		return nil, errors.New("flowack.read fid")
	}
	cnt := uint64(0)
	if cnt, err = r.Read7BitValue64(); err != nil {
		return nil, errors.New("flowack.read cnt")
	}
	var ack *flowAck
	if ack, err = parseFlowAck(r); err != nil {
		return nil, errors.New("flowack.read ack")
	}
	return &flowAckRequest{fid, cnt, ack}, nil
}
Beispiel #3
0
func parseFlowRequest(r *xio.PacketReader) (*flowRequest, error) {
	var err error
	flags := uint8(0)
	if flags, err = r.Read8(); err != nil {
		return nil, errors.New("flow.read flags")
	}
	fid := uint64(0)
	if fid, err = r.Read7BitValue64(); err != nil {
		return nil, errors.New("flow.read fid")
	}
	stage, delta := uint64(0), uint64(0)
	if stage, err = r.Read7BitValue64(); err != nil {
		return nil, errors.New("flow.read stage")
	}
	if delta, err = r.Read7BitValue64(); err != nil {
		return nil, errors.New("flow.read delta")
	}
	signature := ""
	if (flags & flagsHeader) != 0 {
		if signature, err = r.ReadString8(); err != nil {
			return nil, errors.New("flow.read signature")
		}
		for {
			if size, err := r.Read8(); err != nil {
				return nil, errors.New("flow.read header content size")
			} else if size == 0 {
				break
			} else if n := int(size); n > r.Len() {
				return nil, errors.New("flows.too big header content size")
			} else if err = r.Skip(n); err != nil {
				return nil, errors.New("flows.skip header")
			}
		}
	}
	data := r.Bytes()
	req := &flowRequest{}
	req.fid = fid
	req.signature = signature
	req.stage = stage
	req.stageack = stage - delta
	req.slices = make([]*flowRequestSlice, 0, 4)
	req.AddSlice(&flowRequestSlice{flags, data})
	return req, nil
}
Beispiel #4
0
func parseFlowAck(r *xio.PacketReader) (*flowAck, error) {
	if stage, err := r.Read7BitValue64(); err != nil {
		return nil, err
	} else {
		ack := newFlowAck(stage)
		var beg, end uint64
		for r.Len() != 0 {
			if beg, err = r.Read7BitValue64(); err != nil {
				return nil, err
			}
			if end, err = r.Read7BitValue64(); err != nil {
				return nil, err
			}
			beg = beg + stage + 2
			end = end + beg
			ack.AddRange(beg, end)
			stage = end
		}
		return ack, nil
	}
}