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

📄 v3_comm.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
* \is* \i <*community>* Point to the community object to remove from the community 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_Community_Destroy(SNMP_COMMUNITY_T *community){EBufferClean(&community->comm_name);EBufferClean(&community->comm_sec_name);EBufferClean(&community->comm_con_id);EBufferClean(&community->comm_con_name);EBufferClean(&community->comm_tag);SNMP_memory_free_lt(community);}/********************************************************************************* SNMP_Community_Create - create a community object structure* SYNOPSIS** \cs* SNMP_COMMUNITY_T *  SNMP_Community_Create( void )* \ce** DESCRIPTION** This routine creates a community object structure. At the time of creation, * the community object\抯 fields are uninitialized to default settings where * applicable, or to empty strings.** \&NOTE: You must call SNMP_Community_Install() to insert the newly created * object into the global linked list of community objects.** PARAMETERS* None.** RETURNS: If successful, this routine returns a pointer to the newly created * 'SNMP_COMMUNITY_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_COMMUNITY_T *  SNMP_Community_Create(void){SNMP_COMMUNITY_T *community;community = (SNMP_COMMUNITY_T *)    SNMP_memory_alloc_lt(sizeof(SNMP_COMMUNITY_T));if (community == 0)    return(0);SNMP_Community_Set_Defaults(community);return(community);}/********************************************************************************* SNMP_Community_Install -  install a community object into the community table* SYNOPSIS** \cs* envoy_err_t SNMP_Community_Install*     (*     SNMP_COMMUNITY_T  *  community,*     bits8_t           *  comm_index,*     ALENGTH_T            comm_index_len*     )* \ce** DESCRIPTION** This routine installs an existing community object into the community table * using <comm_index> as an index. This function takes responsibility for * allocating necessary memory for storage of the community index.** \&NOTE: Once a community object has been installed, you must call * SNMP_Community_Deinstall() before calling SNMP_Community_Destroy() to remove * it.** PARAMETERS* \is* \i <*community>* Point to the community object in the community table.* \i <*comm_index>* Point to the community index, which corresponds to the MIB object * <snmpCommunityIndex>.* \i <comm_index_len>* Specify the length in bytes of the allocated <comm_index> buffer. If the * actual length of <comm_index> exceeds this value, the community index 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_BAD_INSTANCE' when the instance information is incorrect, * 'ENVOY_ERR_INSUFFICIENT_MEMORY' when an allocation error has occurred, 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_Community_Install(SNMP_COMMUNITY_T *in_community,                         bits8_t          *comm_index,                         ALENGTH_T         comm_index_len){SNMP_COMMUNITY_T **community;/* see if the naming information is reasonable */if ((comm_index_len == 0) || (comm_index_len > ETC_COMMUNITY_MAX))    return(ENVOY_ERR_BAD_INSTANCE);/* see if the community already exists */community = community_find_before(comm_index, comm_index_len);if (*community &&    (EBufferUsed(&((*community)->comm_index)) == comm_index_len) &&    (MEMCMP(EBufferStart(&((*community)->comm_index)), 	    comm_index, 	    comm_index_len) == 0))    return(ENVOY_ERR_EXISTS);/* allocate space for the name */EBufferAllocateLoad(BFL_IS_ALLOC, 		    &(in_community->comm_index), 		    comm_index, 		    comm_index_len);if (EBufferUsed(&(in_community->comm_index)) == 0)    return(ENVOY_ERR_INSUFFICIENT_MEMORY);/* insert the community into the list */in_community->next = *community;*community = in_community;return(ENVOY_ERR_NOERR);}/********************************************************************************* SNMP_Community_Deinstall - remove a community object from the community table* SYNOPSIS** \cs* void SNMP_Community_Deinstall*     (*     SNMP_COMMUNITY_T *  community*     )* \ce** DESCRIPTION** This routine removes a community object from the global linked list used for * the <snmpCommunityTable> and cleans up any resources that might have been * used for indexing purposes.** PARAMETERS* \is* \i <*community>* Point to the community object entry to remove from the community 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_Community_Deinstall(SNMP_COMMUNITY_T *in_community){SNMP_COMMUNITY_T **community;for(community = &root_community;     *community;     community = &(*community)->next)    if (*community == in_community) {        *community = in_community->next;	EBufferClean(&(in_community)->comm_index);	in_community->next = 0;	return;        }return;}/********************************************************************************* SNMP_Community_Index -  copy the community index into the <comm_index>.* SYNOPSIS** \cs* void SNMP_Community_Index*     (*     SNMP_COMMUNITY_T  *  community,*     bits8_t           *  comm_index,*     ALENGTH_T         *  comm_index_len*     )* \ce** DESCRIPTION** This routine copies the community index from the community object into the * available allocated memory for comm_index. It also updates comm_index_len * with the length of comm_index. Verify that buffer\抯 length is at least * ETC_COMMUNITY_INDEX_MAX bytes long before calling this routine, as shown in * the code sample below.** \cs* int index_len = ETC_COMMUNITY_INDEX_MAX;* bits8_t index[ETC_COMMUNITY_INDEX_MAX];** SNMP_Community_Index(community, index, &index_len);* if (index_len \> ETC_COMMUNITY_INDEX_MAX)*     return ERR;* /@ Otherwise, index_len is the number of bytes in index that comprise*  * the community_index of the community object.*  @/* \ce** PARAMETERS* \is* \i <*community>* Point to the community object in the community table.* \i <*comm_index>* Point to the community index, which corresponds to the MIB object * <snmpCommunityIndex>.* \i <*comm_index_len>* Specify the length in bytes of the allocated <comm_index> buffer. If the * actual length of <comm_index> exceeds this value, the community index 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_Community_Index(SNMP_COMMUNITY_T *community,                       bits8_t          *comm_index,                       ALENGTH_T        *comm_index_len){if (EBufferUsed(&(community->comm_index)) &&     (*comm_index_len >= EBufferUsed(&(community->comm_index)))) {    MEMCPY(comm_index,           EBufferStart(&(community->comm_index)),            EBufferUsed(&(community->comm_index)));    }*comm_index_len = EBufferUsed(&(community->comm_index));return;}

⌨️ 快捷键说明

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