Ejemplo n.º 1
0
PppConfOption* PppConfPacket::optionAt (const int optIdx) {
	ACE_TRACE("PppConfPacket::optionAt");
	
	int optNum = 0;
	
	if (codeVal() != Configure_Request &&
		codeVal() != Configure_Ack &&
		codeVal() != Configure_Nak)
			throw std::runtime_error("No options in this type of packet.");
	
	ACE_UINT8 optType, bufLen;
	ACE_UINT8* optPtr;
	int optPos = 0;
	
	do {
		optType = *(dataPtr() + optPos);
		bufLen = *(dataPtr() + optPos + 1) - 2;
		optPtr = dataPtr() + optPos + 2;
		optPos += bufLen + 2;
	} while ( optPos < dataLength() && optNum++ <= optIdx );
	
	if ( optNum != optIdx )
		throw std::runtime_error("Could not reach specified option index.");
		
	// TODO: use an auto_ptr here so there's no worry about deleting later
	return new PppConfOption(optType, bufLen, optPtr);
}
Ejemplo n.º 2
0
float parsenumber(char code) 
{
	if(codeSeen(code))
		return codeVal();
	else
		return BLANK;
}