当前位置: 首页>>代码示例>>C++>>正文


C++ NetworkData::getTotalUnitLength方法代码示例

本文整理汇总了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_();
}
开发者ID:E-LLP,项目名称:channel-emulator,代码行数:67,代码来源:modAOS_VC_Frame.cpp

示例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_();
}
开发者ID:E-LLP,项目名称:channel-emulator,代码行数:68,代码来源:modTM_MC_Frame.cpp


注:本文中的NetworkData::getTotalUnitLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。