ClearBox Server™ v1.2 Developer's Guide

IServer2::SetCookie

Allows server extension to store some data associated with a packet.

HRESULT SetCookie(
	[in] long packetTag,
	[in] unsigned long cookieDataSize,	
	[in] unsigned char* cookieData);

Parameters

packetTag
[in] Packet unique ID. It is usually obtained by server extension in its implementation of IRADIUSAuthentication::GetChallengeResponseAttributes or IEAP::ProcessMessage (although its use is not restricted by them).
cookieDataSize
[in] Number of bytes in array pointed by cookieData.
cookieData
[in] Array of bytes representing some data that server extension has to store and associate with a packet with packetTag ID.

Return Values

This method always returns S_OK.

Thread Safety

This method can be called from any thread.

Memory Management

Server extension should allocate and free memory for cookieData parameter.

Remarks

This method allows to design server extension as "stateless", one that doesn't store intermediary data.

Server extension may call this method only once for a particular packetTag unless GetCookie method has been called and has erased stored data.

Example Code

This code uses m_pServer as IServer interface pointer stored in ICommonExtenderEx::InitializeEx implementation. In this example server stores 8 bytes of some data.

STDMETHODIMP CTest::GetChallengeResponseAttributes(
	long tag, AUTHENTYPE authType,
	USERINFOLITE * userInf, unsigned char * waitForAttribute,
	unsigned long * attrNumOut, RADIUS_ATTRIBUTE * * outpAttributes )
{
...
IServer2* pS2=NULL;
m_pServer->QueryInterface(IID_IServer2,(void**)&pS2;
//QueryInterface will always succeed

BYTE* pData=(BYTE*)CoTaskMemAlloc(8);
memcpy(pData,pPointerToSomeData,8);

pS2->SetCookie(tag,8,pData);

CoTaskMemFree(pData);
// Call to  pS2->Release() is not necessary 
...
}

See Also

IServer2, Server services, IRADIUSAuthentication::GetChallengeResponseAttributes, IEAP::ProcessMessage, GetCookie


© 2001-2003 XPerience Technologies. www.xperiencetech.com

Created by chm2web html help conversion utility.