int modAOS_VC_Frame::svc() { svcStart_(); NetworkData* data = 0; AOS_Transfer_Frame* aos = 0; while ( continueService() ) { bool frameIsValid = true; ndSafeRelease(data); // Handle all cases from previous iteration std::pair<NetworkData*, int> queueTop = getData_(); if ( msg_queue()->deactivated() ) break; if ( queueTop.second < 0 ) { MOD_ERROR("getData_() call failed."); continue; } else if ( ! queueTop.first ) { MOD_ERROR("getData_() returned with null data."); continue; } data = queueTop.first; queueTop.first = 0; MOD_DEBUG("Channel GVCID %X: Received a %d-octet VC frame.", getGVCID(), data->getTotalUnitLength()); if ( data->getTotalUnitLength() != getMRU() ) { MOD_ERROR("Received %d-octet frame when exactly %d octets are required.", data->getTotalUnitLength(), getMRU()); incBadLengthCount(); frameIsValid = false; if ( getDropBadFrames() ) continue; } if ( links_[PrimaryOutputLink] ) { ndSafeRelease(aos); aos = new AOS_Transfer_Frame( getFrameSize(), // all frames in MC have the same size data->ptrUnit() // copy the data buffer ); if ( ! aos ) { MOD_ALERT("Failed to allocate an AOS_Transfer_Frame!", getName().c_str()); } else if ( aos->getGVCID() != getGVCID() ) { ND_WARNING("[%s] Incoming frame GVCID %X does not match assigned GVCID %X.", aos->getGVCID(), getGVCID()); incBadGVCIDCount(); frameIsValid = false; if ( getDropBadFrames() ) continue; } if ( frameIsValid ) incValidFrameCount(); if (aos) { MOD_DEBUG("Sending %-octet frame to next segment.", aos->getUnitLength()); links_[PrimaryOutputLink]->send(aos); aos = 0; // important } } else { MOD_ERROR("No output target defined, dropping packet."); } } return svcEnd_(); }
int modTM_MC_Frame::svc() { svcStart_(); NetworkData* data = 0; TM_Transfer_Frame* frame = 0; while ( continueService() ) { ndSafeRelease(data); ndSafeRelease(frame); std::pair<NetworkData*, int> queueTop = getData_(); if ( msg_queue()->deactivated() ) break; if ( queueTop.second < 0 ) { MOD_ERROR("getData_() call failed."); continue; } else if ( ! queueTop.first ) { MOD_ERROR("getData_() returned with null data."); continue; } data = queueTop.first; queueTop.first = 0; MOD_DEBUG("Channel MCID %X: Received a %d-octet MC frame.", getMCID(), data->getTotalUnitLength()); if ( data->getTotalUnitLength() != getMRU() ) { MOD_ERROR("Received %d-octet frame when exactly %d octets are required.", data->getTotalUnitLength(), getMRU()); incBadLengthCount(); if ( getDropBadFrames() ) { ndSafeRelease(data); continue; } } TM_Transfer_Frame* frame = new TM_Transfer_Frame( getFrameSize(), // all frames in MC have the same size data->ptrUnit(), // copy the data getUseOperationalControl(), // existance of OCF is VC dependent getUseFrameErrorControl(), // all frames in MC have frame CRC, or not getFSHSize() // size of secondary header ); if ( ! frame ) { MOD_ALERT("Failed to allocate a TM_Transfer_Frame!", getName().c_str()); continue; } if ( frame->getMCID() != getMCID() ) { ND_WARNING("[%s] Incoming frame MCID %X does not match assigned MCID %X.", frame->getMCID(), getMCID()); incBadMCIDCount(); if ( getDropBadFrames() ) continue; } else { incValidFrameCount(); } if ( links_[PrimaryOutputLink] ) { MOD_DEBUG("Sending %-octet frame to next segment.", frame->getUnitLength()); links_[PrimaryOutputLink]->send(frame); frame = 0; // important } else { MOD_ERROR("No output target defined, dropping packet."); } } return svcEnd_(); }