本文整理汇总了C++中NetworkData::getTotalUnitLength方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkData::getTotalUnitLength方法的具体用法?C++ NetworkData::getTotalUnitLength怎么用?C++ NetworkData::getTotalUnitLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkData
的用法示例。
在下文中一共展示了NetworkData::getTotalUnitLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: svc
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_();
}
示例2: svc
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_();
}