📄 v3_proxy.c
字号:
/* v3_proxy.c - object manipulation routines for RFC 2573 Proxy code *//* * Copyright 2000-2005 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//*modification history--------------------01d,12may05,job fix apigen comments01c,18apr05,job update copyright notices01b,22feb05,job apigen for documented APIs01a,24nov03,job update copyright information$Log: v3_proxy.c,v $Revision 1.2 2001/11/06 21:20:32 joshrevised new path hackingRevision 1.1.1.1 2001/11/05 17:47:44 tnealeTornado shuffleRevision 9.2.2.2 2001/10/19 19:11:54 joshreturn the proper envoy_err_t error codes from SNMP_Proxy_Install()Revision 9.2.2.1 2001/06/28 18:23:00 joshSeeding the Cormorant branch with the code from the oldcormorant branchRevision 9.1.2.1 2001/04/11 19:35:42 joshmoving cormorant-specific files onto the specialcormorant branch so they don't get in kingfisher's wayRevision 9.1 2001/01/19 22:22:30 paulUpdate copyright.Revision 9.0 2000/06/09 13:59:12 joshupdating version stamp for fileRevision 1.1 2000/06/09 13:56:42 joshobject management code for proxy objects*//*DESCRIPTIONThis module contains the object manipulation routines for theSNMP proxy object.INCLUDE FILES: snmp.h, v3_proxy.h*//* includes */#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/v3_proxy.h>#include <wrn/wm/snmp/engine/snmpdefs.h>/***************************************************************************** proxyFindBefore - find the where the previous proxy object would be* in the proxy list.** Search through the list until we find the proxy structure we are looking* for. We return a pointer to the pointer that would point to the* requested proxy if it were to exist. The calling routine is responsible* for determining if the requested proxy exists. This construction allows* us to reuse this code for all of the find routines (lookup and install).** RETURNS: SNMP_PROXY_T ** pointer to pointer that would point to the* proxy object if it were to exist.*/static SNMP_PROXY_T ** proxyFindBefore ( bits8_t * pProxyName, ALENGTH_T proxyNameLen ) { SNMP_PROXY_T ** ppProxy; /* proxy pointer for walking the list */ ALENGTH_T minNameLen; /* the minimum name length to check */ int compare; /* used for comparing memory */ for(ppProxy = &root_proxy; *ppProxy; ppProxy = &(*ppProxy)->next) { minNameLen = min(proxyNameLen, EBufferUsed(&((*ppProxy)->proxy_name))); if ((compare = MEMCMP(EBufferStart(&((*ppProxy)->proxy_name)), pProxyName, minNameLen)) >= 0) if ((compare > 0) || (minNameLen == proxyNameLen)) break; } return(ppProxy); }/********************************************************************************* SNMP_Proxy_Lookup - find a proxy matching the specified name.* SYNOPSIS** \cs* SNMP_PROXY_T * SNMP_Proxy_Lookup * (* bits8_t * proxy_name,* ALENGTH_T proxy_name_len* )* \ce** DESCRIPTION** This routine finds the proxy object entry that matches the specified * <proxy_name>.** Parameters:* \is* \i <*proxy_name>* Point to the proxy name, which corresponds to the MIB object <snmpProxyName>.* \i <proxy_name_len>* Specify the length in bytes of the allocated <proxy_name> buffer.* \ie** RETURNS: If successful, this routine returns a pointer to the proxy object * with the specified name. Otherwise, the object doesn\抰 exist and this * routine returns NULL.** ERRNO: N/A** SEE ALSO: SNMP_Community_Create(), SNMP_Community_Deinstall(), * SNMP_Community_Destroy(), SNMP_Community_Index(), SNMP_Community_Install(), * SNMP_Community_Next_Community()*/SNMP_PROXY_T * SNMP_Proxy_Lookup ( bits8_t * proxy_name, ALENGTH_T proxy_name_len ) { SNMP_PROXY_T ** ppProxy; /* proxy pointer for walking the proxy list */ ppProxy = proxyFindBefore (proxy_name, proxy_name_len); if ((*ppProxy != 0) && (proxy_name_len == EBufferUsed (&((*ppProxy)->proxy_name))) && (MEMCMP (EBufferStart (&((*ppProxy)->proxy_name)), proxy_name, proxy_name_len) == 0)) return (*ppProxy); return (0); }/***************************************************************************** \NOMANUAL* SNMP_Proxy_Next - Find the next proxy after this instance** This routine takes instance information as input and attempts to* find the lexicographically next proxy object in the proxy list.* * the indexing information is of the form:* <proxy_name>* but as this is a next we might not have all of it...* * RETURNS: SNMP_PROXY_T * pointer to proxy* 0 if none found*/SNMP_PROXY_T * SNMP_Proxy_Next ( int tcount, OIDC_T * tlist ) { SNMP_PROXY_T * pProxy; /* proxy pointer for walking the list */ bits8_t * pProxyName; /* proxy name for proxy pointer */ OIDC_T minNameLen = 0; /* minimum length of name to check */ OIDC_T len; /* counter for walking down name */ OIDC_T * pTempOID; /* temp variable for walking OID */ if (tcount == 0) return (root_proxy); for (pProxy = root_proxy; pProxy; pProxy = pProxy->next) { pProxyName = EBufferStart (&(pProxy)->proxy_name); minNameLen = min (tcount, EBufferUsed (&(pProxy->proxy_name))); pTempOID = tlist; for (len = minNameLen; len && (*pProxyName == *pTempOID); len--, pProxyName++, pTempOID++) ; if (len) { if (*pProxyName > *pTempOID) return (pProxy); } else { if (EBufferUsed (&(pProxy->proxy_name)) > tcount) return (pProxy); } } return (0); }/********************************************************************************* SNMP_Proxy_Next_Proxy - find the next proxy object* SYNOPSIS** \cs* SNMP_PROXY_T * SNMP_Proxy_Next_proxy * (* SNMP_PROXY_T * proxy* )* \ce** DESCRIPTION** This routine finds the next proxy object entry in the proxy table after the * specified proxy object. Use this routine to step through the proxy table to * find all installed proxy objects.** Parameters:* \is* \i <*proxy>* Point to a proxy object in the proxy table. To return a pointer to the first * proxy object in the table, specify this parameter as 0.* \ie** RETURNS: If successful, this routine returns a pointer to the proxy object * that comes next in the list after the specified proxy object. If there is no * successor, or the specified proxy object is not installed, this routine * returns NULL.** ERRNO: N/A** SEE ALSO: SNMP_Community_Create(), SNMP_Community_Deinstall(), * SNMP_Community_Destroy(), SNMP_Community_Index(), SNMP_Community_Install(), * SNMP_Community_Lookup()*/SNMP_PROXY_T * SNMP_Proxy_Next_Proxy ( SNMP_PROXY_T * proxy ) { if (proxy) return (proxy->next); return (root_proxy); }/********************************************************************************* SNMP_Proxy_Destroy - destroy the proxy object and free any associated resources* SYNOPSIS** \cs* void SNMP_Proxy_Destroy* (* SNMP_PROXY_T * proxy* )* \ce** DESCRIPTION** This routine destroys the specified proxy object, frees the space that the * object occupies, and frees the space for any resources the object might * contain.** \&NOTE: If the specified object has been installed, call * SNMP_Community_Deinstall() before calling this routine.** Parameters:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -