Пример #1
0
// Copy ctor
TMsgAuthLastRawBufferBase::TMsgAuthLastRawBufferBase(const TMsgAuthLastRawBufferBase& theMsgR) :
	TMessage(theMsgR),
	mRawP(NULL),
	mRawLen(0),
	mRawBuf()
{
	SetRawBuf(theMsgR.mRawP, theMsgR.mRawLen, true);
}
Пример #2
0
// Assignment operator
TMsgAuthLastRawBufferBase&
TMsgAuthLastRawBufferBase::operator=(const TMsgAuthLastRawBufferBase& theMsgR)
{
	if (this != &theMsgR)  // protect against a = a
	{
		TMessage::operator=(theMsgR);
		SetRawBuf(theMsgR.mRawP, theMsgR.mRawLen, true);
	}
	return *this;
}
// TMsgAuth1Complete::Unpack
// Virtual method from TMessage.  Extracts data from message buffer.
void
TMsgAuth1Complete::Unpack(void)
{
	WTRACE("TMsgAuth1Complete::Unpack");
	TMsgAuthRawBufferBase::Unpack();

	if ((GetServiceType() != WONMsg::Auth1PeerToPeer) ||
	    (GetMessageType() != WONMsg::Auth1Complete))
	{
		WDBG_AH("TMsgAuth1Complete::Unpack Not a Auth1Complete message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__,
		                              "Not a Auth1Complete message.");
	}

	WDBG_LL("TMsgAuth1Complete::Unpack Reading message data");
	mStatus = static_cast<ServerStatus>((short)ReadShort());

	// If status implies failure, read error info
	if (mStatus < 0)
	{
		WDBG_LL("TMsgAuth1Complete::Unpack Failure status, read error info");
		unsigned short aNumErrs = ReadShort();
		for (int i=0; i < aNumErrs; i++)
			mErrList.push_back(Read_PA_STRING());
		SetRawBuf(NULL, 0);
		mSessionId = 0;
	}

	// Otherwise, read secret and optional sessionId
	else
	{
		WDBG_LL("TMsgAuth1Complete::Unpack Success status, read secret and optional session");
		UnpackRawBuf();
		mSessionId = (BytesLeftToRead() > 0 ? ReadShort() : 0);
		mErrList.clear();
	}
}