⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 radius_acct_mib.c

📁 vxworks下radius协议栈 的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
			rw_container_next (server_iterator);			}	rw_container_free_iterator (server_iterator);	if (best)	{		found = true;		p_server = best;	}	else	{		found = false;	}	if (found == true)		{		p_server_stat = &(p_server->statistics);		pRadiusAccServerInfo->radiusAccServerIndex = (UINT)p_server;		pRadiusAccServerInfo->radiusAccServerAddress = htonl (p_server->ip_address);		pRadiusAccServerInfo->radiusAccClientServerPortNumber = p_server->port;		acc_server_mib_stat_sync (pRadiusAccServerInfo, p_server_stat);		radiusAccServerEntry_build_instance (pRadiusAccServerInfo, best_inst);	    /* we found a next so get the values and set the instance for all	     * the varbinds for this row of this table.	     * NOTE: if you allow holes in the table then this code will have to	     * change significantly to accomodate that.  */	    for ( ; vbp ; vbp = vbp->vb_link)	    	{			if ((error = radiusAccServerEntryGetValue				(vbp->vb_ml.ml_last_match, pktp, vbp, pRadiusAccServerInfo)) == NO_ERROR)				{  				nextproc_next_instance(pktp, vbp, RADIUS_TBL_INDEX_LEN, best_inst);				}			else				{				nextproc_error(pktp, vbp, error);				}			}		}	else  /* there's no more in this table */		{	    for ( ; vbp ; vbp = vbp->vb_link )			{			nextproc_no_next(pktp, vbp);			}		}	semGive (g_sem_radius_mib);}/******************************************************************************** Method routines for the radiusAccClient variables:********************************************************************************//******************************************************************************** radiusAccClientGetValue** An internal routine to retrieve the values of the variables, used* by the method routines radiusAccClientGet and radiusAccClientNext.* Parameters to this routine are** <lastmatch> 	- the last oid component that was matched to get to this leaf.* <pktp>      	- ptr to internal representation of the snmp pkt.* <vbp>       	- ptr to var bind being processed.* <pRadiusClientInfo>*			  	- the structure holding the info of RADIUS Client.*******************************************************************************/static int  radiusAccClientGetValue (OIDC_T      lastmatch,                            SNMP_PKT_T *pktp,                            VB_T       *vbp,                            M2_RADIUS_ACC_CLIENT_INFO *pRadiusAccClientInfo){	switch(lastmatch) 	{		case LEAF_radiusAccClientInvalidServerAddresses:			getproc_got_uint32(pktp, vbp, 					pRadiusAccClientInfo->radiusAccClientInvalidServerAddresses, 					VT_COUNTER);		break;		case LEAF_radiusAccClientIdentifier:		/* if the data being returned is in dynamic storage and needs		 * to be free'd, change the 0 argument to a 1. */			getproc_got_string(pktp, vbp, 					strlen (pRadiusAccClientInfo->radiusAccClientIdentifier), 					pRadiusAccClientInfo->radiusAccClientIdentifier, 0, VT_STRING);		break;		default:			return GEN_ERR;	}	return NO_ERROR;}/*******************************************************************************  radiusAccClientGet**  Get method routine for for RADIUS Accounting client table***  Parameters to this routine are**  <lastmatch> - the last oid component that was matched to get to this leaf.*  <compc>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <compl>     - ptr to the oid sequence remaining, i.e. the instance portion.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.** RETURNS : N/A*******************************************************************************/void  radiusAccClientGet(OIDC_T      lastmatch,                      int         compc,                      OIDC_T     *compl,                      SNMP_PKT_T *pktp,                      VB_T       *vbp){	int error;	/* find all the varbinds that share the same getproc and instance */	snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl);	/* check that the instance is exactly .0 */	if (!((compc == 1) && (*compl == 0)))		{		for ( ; vbp; vbp = vbp->vb_link)			{			getproc_nosuchins(pktp, vbp);			}		}	  /* grab the actual data for this variable.  this lookup routine will	   * probably have to be changed for your system.  for scalar variables	   * there might not even be any lookup routine. */	else		{/* retrieve all the values from the same data structure */	    for ( ; vbp; vbp = vbp->vb_link)	    	{	    	if ((error = radiusAccClientGetValue	    		(vbp->vb_ml.ml_last_match, pktp, vbp, &radiusAccClientInfo)) != NO_ERROR)				{				getproc_error(pktp, vbp, error);				}			}	    }}/*******************************************************************************  radiusAccClientNext**  Next method routine for RADIUS Accounting Client table***  Parameters to this routine are**  <lastmatch> - the last oid component that was matched to get to this leaf.*  <compc>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <compl>     - ptr to the oid sequence remaining, i.e. the instance portion.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.** RETURNS : N/A********************************************************************************/void  radiusAccClientNext(OIDC_T      lastmatch,                       int         compc,                       OIDC_T     *compl,                       SNMP_PKT_T *pktp,                       VB_T       *vbp){	OIDC_T instance = 0;	/* the only time there's a next for a scalar is if we're given	 * no instance at all. */	if (compc != 0)		{	    nextproc_no_next(pktp, vbp);		}	  /* grab the data for these variables.  you'll probably have to change	   * this lookup routine for your system.  for scalar variables there	   * might not even be any lookup routine. */	else 		{	    /* find all the varbinds in this group and retrieve their	     * values from the same data structure */	    for (snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl);	        vbp; vbp = vbp->vb_link)	        {	        nextproc_next_instance(pktp, vbp, 1, &instance);			radiusAccClientGetValue(vbp->vb_ml.ml_last_match, pktp, vbp,				&radiusAccClientInfo);			}		}}/********************************************************************************* Private functions.********************************************************************************/static int radiusAccServerEntry_lookup(int compc, OIDC_T *compl, 	M2_RADIUS_ACC_SERVER_INFO* pRadiusAccServerInfo){	RW_CONTAINER_ITERATOR server_iterator;	RADIUS_SERVER* p_server;	RADIUS_SERVER_STATISTICS *p_server_stat;	bool item_found = false;	if ((compc != RADIUS_TBL_INDEX_LEN) || (compl == NULL))		{		return (-1);		}	semTake (g_sem_radius_mib, WAIT_FOREVER);	server_iterator = rw_container_create_copy_of_iterator 		(radius.server_controller.iterator);	if (server_iterator != 0)		{		item_found = rw_container_find_by_content ((RW_CONTAINER_ITEM*)*compl, server_iterator);		if (item_found == true)			{			p_server = (RADIUS_SERVER*) rw_container_at (server_iterator);   	        if (p_server->type == RADIUS_ACCOUNTING_SERVER_TYPE)				{				p_server_stat = &(p_server->statistics);								pRadiusAccServerInfo->radiusAccServerIndex = (UINT)p_server;				pRadiusAccServerInfo->radiusAccServerAddress = htonl (p_server->ip_address);				pRadiusAccServerInfo->radiusAccClientServerPortNumber = p_server->port;				acc_server_mib_stat_sync (pRadiusAccServerInfo, p_server_stat);				}			else				{				item_found = false;				}			}		rw_container_free_iterator (server_iterator);		}	semGive (g_sem_radius_mib);	if (item_found == true)		{		return (0);		}	else		{		return (-1);		}}/*******************************************************************************/static unsigned radiusAccServerEntry_build_instance (M2_RADIUS_ACC_SERVER_INFO* data, OIDC_T* tmp_inst){	*tmp_inst = data->radiusAccServerIndex;	return (0);} /*******************************************************************************/void acc_server_mib_stat_sync 	(M2_RADIUS_ACC_SERVER_INFO* pRadiusAccServerInfo, RADIUS_SERVER_STATISTICS *pServerStat){	pRadiusAccServerInfo->radiusAccClientRoundTripTime = pServerStat->accounting_round_trip_time;	pRadiusAccServerInfo->radiusAccClientRequests = pServerStat->accounting_requests_tx;	pRadiusAccServerInfo->radiusAccClientRetransmissions = pServerStat->accounting_requests_retransmit;	pRadiusAccServerInfo->radiusAccClientResponses = pServerStat->accounting_responses_rx;	pRadiusAccServerInfo->radiusAccClientMalformedResponses = pServerStat->accounting_malformed_responses_rx;	pRadiusAccServerInfo->radiusAccClientBadAuthenticators = pServerStat->accounting_bad_authenticators_rx;	pRadiusAccServerInfo->radiusAccClientPendingRequests = pServerStat->accounting_pending_access_requests;	pRadiusAccServerInfo->radiusAccClientTimeouts = pServerStat->accounting_timeouts;	pRadiusAccServerInfo->radiusAccClientUnknownTypes = pServerStat->accounting_unknown_type_packets_rx;	pRadiusAccServerInfo->radiusAccClientPacketsDropped = pServerStat->accounting_dropped_packets_rx;}/*******************************************************************************/#endif	/* __RADIUS_MIB__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -