func (rsp *flowResponse) SetLastInfo(lastfid, laststage uint64) int { if (rsp.fw.fid == lastfid) && (rsp.f.stage == laststage+1) { rsp.header = false } else { rsp.header = true } size := 1 + len(rsp.f.data) if rsp.header { if add, err := xio.SizeOf7BitValue64(rsp.fw.fid); err == nil { size += add } if add, err := xio.SizeOf7BitValue64(rsp.f.stage); err == nil { size += add } if add, err := xio.SizeOf7BitValue64(rsp.f.delta); err == nil { size += add } if len(rsp.fw.signature) != 0 { size += 1 + len(rsp.fw.signature) if rsp.fr.fid != 0 { more := 1 if add, err := xio.SizeOf7BitValue64(rsp.fr.fid); err == nil { more += add } if add, err := xio.SizeOf7BitValue64(uint64(more)); err == nil { size += add } size += more } } size += 1 } return size }
func (rsp *flowAckResponse) SetLastInfo(lastfid, laststage uint64) int { size := 0 if add, err := xio.SizeOf7BitValue64(rsp.fid); err == nil { size += add } if add, err := xio.SizeOf7BitValue64(rsp.cnt); err == nil { size += add } if add, err := rsp.ack.Size(); err != nil { size += add } return size }
func (ack *flowAck) Size() (int, error) { if add, err := xio.SizeOf7BitValue64(ack.stage); err != nil { return 0, err } else { total := add stage := ack.stage for e := ack.conts.Front(); e != nil; e = e.Next() { r := e.Value.(*flowAckRange) if add, err := xio.SizeOf7BitValue64(r.beg - stage - 2); err != nil { return 0, err } else { total += add } if add, err := xio.SizeOf7BitValue64(r.end - r.beg); err != nil { return 0, err } else { total += add } stage = r.end } return total, nil } }
func (rsp *flowResponse) WriteTo(w *xio.PacketWriter) error { flags := rsp.f.flags if rsp.header { flags |= flagsHeader } if err := w.Write8(flags); err != nil { return err } if rsp.header { if err := w.Write7BitValue64(rsp.fw.fid); err != nil { return err } if err := w.Write7BitValue64(rsp.f.stage); err != nil { return err } if err := w.Write7BitValue64(rsp.f.delta); err != nil { return err } if len(rsp.fw.signature) != 0 { if err := w.WriteString8(rsp.fw.signature); err != nil { return err } if rsp.fr.fid != 0 { more := 1 if add, err := xio.SizeOf7BitValue64(rsp.fr.fid); err != nil { return err } else { more += add } if err := w.Write7BitValue64(uint64(more)); err != nil { return err } if err := w.Write8(0x0a); err != nil { return err } if err := w.Write7BitValue64(rsp.fr.fid); err != nil { return err } } } if err := w.Write8(0); err != nil { return err } } if err := w.WriteBytes(rsp.f.data); err != nil { return err } return nil }