ClearBox Server™ v1.2 Developer's Guide

ITACACSAccounting::ProcessAccounting

Called when server receives TACACS+ accounting packet.

HRESULT ProcessAccounting(
	[in] long tag,
	[in] TAC_AUTHORPARAMS * accParams,
	[in] unsigned long avSize,
	[in] AVPAIR * avPairs,
	[in] VARIANT_BOOL start,
	[in] VARIANT_BOOL update,
	[out] USERADDRESS * userAddr,
	[out] ACCOUNTINGSTATUS * status);

Parameters

tag
[in] Unique value identifying TACACS+ packet in whose context this method is called.
accParams
[in] Accounting packet data.
avSize
[in] Number of elements in array pointed by avPairs.
avPairs
[in] Array of attribute-value pairs from accounting packet.
start
[in] Specifies whether it is a accounting-start record (VARIANT_TRUE) or accounting-stop record (VARIANT_FALSE).
update
[in] Specifies whether it is a accounting-update record (VARIANT_TRUE) or not (VARIANT_FALSE). update flag is never VARIANT_TRUE when start=VARIANT_FALSE (i.e. it is stop record).
userAddr
[out] If extension decides to disconnect user and returns appropriate status (A_DISCONNECT), this structure must be filled properly and validInfo field set to VARIANT_TRUE.
status
[out] Extension must set this parameter to accounting processing result.

Return Values

If extension returns error code, it is assumed that status was set to A_ERROR.

Thread Safety

This method is called in context of WORK thread. (See Server Threads Model for details.) You should synchronize data which is shared with other threads.

Memory Management

Memory for accParams fields and avPairs is allocated and freed by server, so extension must not change them.

Memory for userAddr fields may be allocated by extension and is freed by server.

Remarks

This method may be used to disconnect a user when it is an interim accounting record (update=VARIANT_TRUE), setting status to A_DISCONNECT. Disconnecting user on receiving "start" or "stop" record is senseless.

Example Code

This code will record session duration when it ends.

STDMETHODIMP CTest::ProcessAccounting(
	long tag, TAC_AUTHORPARAMS * accParams,
	unsigned long avSize, AVPAIR * avPairs,
	VARIANT_BOOL start, VARIANT_BOOL update,
	USERADDRESS * userAddr, ACCOUNTINGSTATUS * status)
{
	*status=A_OK;
	if (start==VARIANT_TRUE)
		return S_OK;
		
	BSTR elapsed=NULL;
	for (int i=0;i<avSize;i++)
	{
		if (wcscmp(avPairs[i].attribute,L"elapsed")==0)
		{
			elapsed=avPairs[i].value;
			break;
		}
	}
	if (elapsed!=NULL)
	{
		int elpsd=_wtoi(elapsed);
		// Some function defined by extension
		RecordResourceUsage(accParams->user,elpsd);
	}
	return S_OK;
}

See Also

ITACACSAccounting, List of TACACS+ Attribute-Value Pairs, Accounting concepts, TACACS+ accounting packet processing


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

Created by chm2web html help conversion utility.