📄 v3_proxy.c
字号:
* \is* \i <*proxy>* Point to the proxy object to remove from the proxy table.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_Community_Create(), SNMP_Community_Deinstall(), * SNMP_Community_Index(), SNMP_Community_Install(), SNMP_Community_Lookup(), * SNMP_Community_Next_Community()*/void SNMP_Proxy_Destroy ( SNMP_PROXY_T * proxy ) { EBufferClean (&proxy->context_engine_id); EBufferClean (&proxy->context_name); EBufferClean (&proxy->target_params_in); EBufferClean (&proxy->single_target_out); EBufferClean (&proxy->multiple_target_out); SNMP_memory_free_lt (proxy); }/********************************************************************************* SNMP_Proxy_Create - create a proxy object* SYNOPSIS** \cs* SNMP_PROXY_T * SNMP_Proxy_Create* (* void* )* \ce** DESCRIPTION** This routine creates a proxy object (snmpProxyTable), in the form of a * SNMP_PROXY_T structure. At the time of creation, the proxy object\抯 fields * are initialized to default values.** \&NOTE: You must call SNMP_Community_Install() to insert the newly created * object into the global linked list of proxy objects.** Parameters:* None.** RETURNS: If successful, this routine returns a pointer to the newly created * 'SNMP_PROXY_T' object. Otherwise, it returns NULL.** ERRNO: N/A** SEE ALSO: SNMP_Community_Deinstall(), SNMP_Community_Destroy(), * SNMP_Community_Index(), SNMP_Community_Install(), SNMP_Community_Lookup(), * SNMP_Community_Next_Community()*/SNMP_PROXY_T * SNMP_Proxy_Create (void) { SNMP_PROXY_T * proxy; proxy = (SNMP_PROXY_T *) SNMP_memory_alloc_lt (sizeof (SNMP_PROXY_T)); if (proxy == 0) return(0); SNMP_Proxy_Set_Defaults (proxy); return (proxy); }/********************************************************************************* SNMP_Proxy_Install - install a proxy object into the proxy table* SYNOPSIS** \cs* envoy_err_t SNMP_PROXY_Install * (* SNMP_Proxy_T * proxy,* bits8_t * proxy_name,* ALENGTH_T proxy_name_len* )* \ce** DESCRIPTION** This routine installs an existing proxy object into the proxy table using * <proxy_name> and <proxy_name_len> as index information. This function takes * responsibility for allocating necessary memory for storage of the proxy name.** \&NOTE: Once a proxy object has been installed, you must call * SNMP_Community_Deinstall() before calling SNMP_Community_Destroy() to remove * it.** Parameters:* \is* \i <*proxy>* Point to the proxy object in the proxy table.* \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. If the * actual length of <proxy_name> exceeds this value, the proxy name is not * copied, and the length field is updated to inform the caller that the buffer * was too small.* \ie** RETURNS: If successful, this routine returns 'ENVOY_ERR_NOERR'. Otherwise, it * returns 'ENVOY_ERR_INSUFFICIENT_MEMORY' when an allocation error has * occurred, 'ENVOY_ERR_BAD_INSTANCE' when the instance information is * incorrect, or 'ENVOY_ERR_EXISTS' when an object already exists with that * name.** ERRNO: N/A** SEE ALSO: SNMP_Community_Create(), SNMP_Community_Deinstall(), * SNMP_Community_Destroy(), SNMP_Community_Index(), SNMP_Community_Lookup(), * SNMP_Community_Next_Community()*/envoy_err_t SNMP_Proxy_Install ( SNMP_PROXY_T * in_proxy, bits8_t * proxy_name, ALENGTH_T proxy_name_len ) { SNMP_PROXY_T ** ppProxy; /* see if the naming information is reasonable */ if ((proxy_name_len == 0) || (proxy_name_len > ETC_PROXY_NAME_MAX)) return (ENVOY_ERR_BAD_INSTANCE); /* see if the proxy already exists */ ppProxy = proxyFindBefore (proxy_name, proxy_name_len); if ((*ppProxy != 0) && (EBufferUsed (&((*ppProxy)->proxy_name)) == proxy_name_len) && (MEMCMP (EBufferStart (&((*ppProxy)->proxy_name)), proxy_name, proxy_name_len) == 0)) return (ENVOY_ERR_EXISTS); /* allocate space for the name */ EBufferAllocateLoad (BFL_IS_ALLOC, &(in_proxy->proxy_name), proxy_name, proxy_name_len); if (EBufferUsed(&(in_proxy->proxy_name)) == 0) return(ENVOY_ERR_INSUFFICIENT_MEMORY); /* insert the proxy into the list */ in_proxy->next = *ppProxy; *ppProxy = in_proxy; return (ENVOY_ERR_NOERR); }/********************************************************************************* SNMP_Proxy_Deinstall - remove a proxy object from the proxy table* SYNOPSIS** \cs* void SNMP_Proxy_Deinstall* (* SNMP_PROXY_T * proxy* )* \ce** DESCRIPTION** This routine removes a proxy object from the global linked list known as the * <snmpProxyTable> and cleans up any resources that might have been used for * indexing purposes.** Parameters:* \is* \i <*proxy>* Point to the proxy object entry to remove from the proxy table.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_Community_Create(), SNMP_Community_Destroy(), * SNMP_Community_Index(), SNMP_Community_Install(), SNMP_Community_Lookup(), * SNMP_Community_Next_Community()*/void SNMP_Proxy_Deinstall ( SNMP_PROXY_T * in_proxy ) { SNMP_PROXY_T ** ppProxy; for(ppProxy = &root_proxy; *ppProxy; ppProxy = &(*ppProxy)->next) if (*ppProxy == in_proxy) { *ppProxy = in_proxy->next; EBufferClean (&(in_proxy)->proxy_name); in_proxy->next = 0; return; } return; }/********************************************************************************* SNMP_Proxy_Name - copy the proxy name into the <proxy_name>.* SYNOPSIS** \cs* void SNMP_Proxy_Name * (* SNMP_PROXY_T * proxy,* bits8_t * proxy_name,* ALENGTH_T * proxy_name_len* )* \ce** DESCRIPTION** This routine copies the proxy name from the proxy object into the available * allocated memory for proxy_name. It also updates proxy_name_len with the * length of proxy_name. Verify that buffer\抯 length is at least * ETC_PROXY_NAME_MAX bytes long before calling this routine, as shown in the * code sample below.** \cs* int name_len = ETC_PROXY_NAME_MAX;* bits8_t name[ETC_PROXY_NAME_MAX];** SNMP_Proxy_Name(proxy, name, &name_len);* if (name_len \> ETC_PROXY_NAME_MAX)* return ERR;* /@ Otherwise, name_len is the number of bytes in name that comprise* * the proxy_name of the proxy object.* @/* \ce** Parameters:* \is* \i <*proxy>* Point to the proxy object in the proxy table.* \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. If the * actual length of <proxy_name> exceeds this value, the proxy name is not * copied, and the length field is updated to inform the caller that the buffer * was too small.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_Community_Create(), SNMP_Community_Deinstall(), * SNMP_Community_Destroy(), SNMP_Community_Install(), SNMP_Community_Lookup(), * SNMP_Community_Next_Community()*/void SNMP_Proxy_Name ( SNMP_PROXY_T * proxy, bits8_t * proxy_name, ALENGTH_T * proxy_name_len ) { if (EBufferUsed (&(proxy->proxy_name)) && (*proxy_name_len >= EBufferUsed (&(proxy->proxy_name)))) { MEMCPY(proxy_name, EBufferStart (&(proxy->proxy_name)), EBufferUsed (&(proxy->proxy_name))); } *proxy_name_len = EBufferUsed (&(proxy->proxy_name)); return; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -