void TTinyTP::TTPHandleDataIndication ( TTPBuf *userData) // data read { int credit; Boolean m; check(userData); { int position, bufsize; position = BufUsed(userData); // should be zero bufsize = BufSize(userData); // amount read XTRACE(kHandleDataIndication, position, bufsize); } ttp_pdu_data_parse(userData, &m, &credit); // strips out ttp overhead byte this->SendCredit += credit; if (SendCredit > 30) SendCredit = 30; // FIXME: temp workaround for HP runaway credits // WARNING: HP tells us that Microsoft believes in // extending lots and lots of credits, and relies on // lap-layer flow control to survive. if (credit > 0) // if we've been given more credits from IrLan box TTPBackEnable(); // then tell clients flow-control state has changed if (BufSize(userData) > 0) { XTRACE(kHandleDataIndication, m, credit); // log what we parsed this->RemoteCredit--; if (m == false) // if no More data this->AppendTail(&(this->RxQueue), TTP_Segment_Last, 0, userData); else // else have More data this->AppendTail(&(this->RxQueue), TTP_Segment, 0, userData); } else { XTRACE(kDataLessPacket, m, credit); // log we received a dataless packet BufFree(userData); // we're done with it now... } // Make sure a read is pending at all times .... this could // use a better model. Only post if connected. if( this->Connected ) { CBufferSegment *getBuf; getBuf = BufAlloc(2048+5); // need up to max lap size require(getBuf, NoMem); this->DataGet(getBuf); } NoMem: return; }
void SimpleScanner::Save(yostream* s) const { SavePodType(s, Header(2, sizeof(m))); Impl::AlignSave(s, sizeof(Header)); Locals mc = m; mc.initial -= reinterpret_cast<size_t>(m_transitions); SavePodType(s, mc); Impl::AlignSave(s, sizeof(mc)); SavePodType(s, Empty()); Impl::AlignSave(s, sizeof(Empty())); if (!Empty()) { YASSERT(m_buffer); Impl::AlignedSaveArray(s, m_buffer, BufSize()); } }