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


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

本文整理汇总了C++中NetworkData::rd_ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkData::rd_ptr方法的具体用法?C++ NetworkData::rd_ptr怎么用?C++ NetworkData::rd_ptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetworkData的用法示例。


在下文中一共展示了NetworkData::rd_ptr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: svc


//.........这里部分代码省略.........
		_updateMarker(markerBuf, markerLen);

		MOD_DEBUG("Received a %d-octet unit to test for ASMs.", data->getUnitLength());

		while ( data->getUnitLength() ) {
			if ( ! goodUnit ) { // no unit to continue, need to find next ASM
				partialMarkerLen = markerLen - markerOffset;

				// determine if enough buffer left to find ASM
				// if not, check what's left and check for remainder in next buffer
				if ( data->getUnitLength() < partialMarkerLen ) {
					if ( _markerMatch(data->ptrUnit(), markerBuf + markerOffset, data->getUnitLength()) ) {
						// this portion is correct
						markerOffset += data->getUnitLength();
					}
					else {
						MOD_DEBUG("Missed partial ASM, resetting marker offset and bit error count.");
						incPartialMismatchCount();
						markerOffset = 0;
						_currentBitErrors = 0;
					}

					advanceLen = data->getUnitLength();
				}
				// if so, look for ASM normally
				else if ( _markerMatch(data->ptrUnit(), markerBuf + markerOffset, partialMarkerLen) ) {
					MOD_DEBUG("Found ASM.");
					_asmCount++;

					if ( searching ) _asmDiscoveredCount++;
					else _asmValidCount++;

					searching = false;
					advanceLen = partialMarkerLen;
					markerOffset = 0;
					_currentBitErrors = 0;

					// determine if entire unit can be extracted from buffer
					// if so, wrap and send
                    if ( data->getUnitLength() - partialMarkerLen >= getExpectedUnitLength() ) {
						MOD_DEBUG("Found complete unit.");
						goodUnit = data->wrapInnerPDU<NetworkData>(getExpectedUnitLength(),
							data->ptrUnit() + partialMarkerLen);
						_send(goodUnit);
						advanceLen += getExpectedUnitLength();
                    }
					// if not, create a new unit to hold it
					else {
						MOD_DEBUG("Holding partial unit for expected completion.");
						goodUnitLength = data->getUnitLength() - partialMarkerLen;
						goodUnit = new NetworkData(getExpectedUnitLength());
						goodUnit->copyUnit(goodUnit->ptrUnit(), data->ptrUnit() + partialMarkerLen, goodUnitLength);
						advanceLen += goodUnitLength;
					};
				}
				else {
					MOD_DEBUG("Missed ASM, advancing one octet at a time.");
					if (! searching ) _asmMissedCount++; // Only increment for the first miss, or after another ASM was found.
					searching = true;
					incSearchCount();

					// data->dump();
					advanceLen = 1;
					markerOffset = 0;
					_currentBitErrors = 0;
				}
			}
			else { // continuing previous unit, don't look for ASM
				remainingLen = getExpectedUnitLength() - goodUnitLength;
				// determine if remaining unit fits in buffer
				// if so, append it and send, reset goodUnit to 0
				if ( data->getUnitLength() >= remainingLen ) {
					MOD_DEBUG("Completing partial unit with newly received data.");
					goodUnit->copyUnit(goodUnit->ptrUnit() + goodUnitLength, data->ptrUnit(),
						remainingLen);
					_send(goodUnit);
					advanceLen = remainingLen;
				}

				// if not, append it and don't send
				else {
					MOD_DEBUG("Adding to partial unit but will complete later.");

					goodUnit->copyUnit(goodUnit->ptrUnit() + goodUnitLength, data->ptrUnit(),
						data->getUnitLength());
					goodUnitLength += data->getUnitLength();
					advanceLen = data->getUnitLength();
				}
			}

			// advance read pointer by length just used up
			data->rd_ptr(advanceLen);
			MOD_DEBUG("Buffer length is now %d.", data->getUnitLength());
		}

		ndSafeRelease(data);
	}

	return svcEnd_();
}
开发者ID:E-LLP,项目名称:channel-emulator,代码行数:101,代码来源:modASM_Remove.cpp


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