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

📄 v3_ntfy.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 4 页
字号:
*     void *     )* \ce** DESCRIPTION** This routine creates a notify filter profile structure * ('snmpNotifyFilterProfileTable'), initialized to the default values * specified in RFC 2573. It attempts to allocate space for the entry. To make * an entry visible to the engine, use SNMP_Notify_Profile_Install().** Parameters:* None.** RETURNS: If successful, this routine sets the entry to a default state and * returns a pointer to the entry. Otherwise, it returns 0.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Profile_Deinstall(), SNMP_Notify_Profile_Destroy(), * SNMP_Notify_Profile_Install(), SNMP_Notify_Profile_Lookup(), * SNMP_Notify_Profile_Name(), SNMP_Notify_Profile_Next_Profile(), SNMP Notify * Filter Profile Table Field Routines*/SNMP_NOTIFY_FILTER_PROFILE_T *  SNMP_Notify_Profile_Create(void){SNMP_NOTIFY_FILTER_PROFILE_T *notify_profile;notify_profile = (SNMP_NOTIFY_FILTER_PROFILE_T *)     SNMP_memory_alloc_lt(sizeof(SNMP_NOTIFY_FILTER_PROFILE_T));if (notify_profile == 0)    return(0);SNMP_Notify_Profile_Set_Defaults(notify_profile);return(notify_profile);}/********************************************************************************* SNMP_ Notify_Profile_Install - install a notify filter profile entry in the table* SYNOPSIS** \cs* int SNMP_Notify_Profile_Install*     (*     SNMP_NOTIFY_FILTER_PROFILE_T *  notify_profile,*     bits8_t                      *  params_name,*     ALENGTH_T                       params_name_len*     )* \ce** DESCRIPTION** This routine installs the specified notify filter profile entry in the user * table using <params_name> as an index.** \&NOTE: Once a notify filter profile has been installed, you must call * SNMP_Notify_Profile_Deinstall() before calling SNMP_Notify_Profile_Destroy() * to remove it.** Parameters:* \is* \i <*notify_profile>* Specify the notify filter profile entry to add to the notify filter profile * table.* \i <*params_name>* Specify the name of the parameter from the <snmpTargetParamsTable>.* \i <params_name_len>* Specify the length in bytes of the parameter name.* \ie** RETURNS: If successful, this routine returns a value of 0. If an entry * already exists with the same indices or another error occurs, it returns -1.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Profile_Create(), SNMP_Notify_Profile_Deinstall(), * SNMP_Notify_Profile_Destroy(), SNMP_Notify_Profile_Lookup(), * SNMP_Notify_Profile_Name(), SNMP_Notify_Profile_Next_Profile(), SNMP Notify * Filter Profile Table Field Routines*/int  SNMP_Notify_Profile_Install(SNMP_NOTIFY_FILTER_PROFILE_T *in_notify_profile,			      bits8_t                      *params_name,			      ALENGTH_T                     params_name_len){SNMP_NOTIFY_FILTER_PROFILE_T **notify_profile;/* see if the naming information is reasonable */if ((params_name_len == 0) || (params_name_len > ETC_TARGET_PARAMS_MAX))    return(-1);/* see if the notify_filter_profile already exists */notify_profile = notify_profile_find_before(params_name, params_name_len);if (*notify_profile &&    (EBufferUsed(&((*notify_profile)->params_name)) == params_name_len) &&    (MEMCMP(EBufferStart(&((*notify_profile)->params_name)), 	    params_name, 	    params_name_len) == 0))    return(-1);/* allocate space for the name */EBufferAllocateLoad(BFL_IS_ALLOC, 		    &(in_notify_profile->params_name), 		    params_name, 		    params_name_len);if (EBufferUsed(&(in_notify_profile->params_name)) == 0)    return(-1);/* insert the notify into the list */in_notify_profile->next = *notify_profile;*notify_profile = in_notify_profile;return(0);}/********************************************************************************* SNMP_Notify_Profile_Deinstall - remove a notify filter profile entry from the table* SYNOPSIS** \cs* void SNMP_Notify_Profile_Deinstall *     (*     SNMP_NOTIFY_FILTER_PROFILE_T *  notify_profile*     )* \ce** DESCRIPTION** This routine removes the specified notify filter profile entry from the * notify filter profile table and cleans up any resources that might have been * used for indexing purposes.** Parameters:* \is* \i <*notify_profile>* Specify the <notify filter profile> entry to remove from the notify filter * profile table.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Profile_Create(), SNMP_Notify_Profile_Destroy(), * SNMP_Notify_Profile_Install(), SNMP_Notify_Profile_Lookup(), * SNMP_Notify_Profile_Name(), SNMP_Notify_Profile_Next_Profile(), SNMP Notify * Filter Profile Table Field Routines*/void    SNMP_Notify_Profile_Deinstall(SNMP_NOTIFY_FILTER_PROFILE_T *in_notify_profile){SNMP_NOTIFY_FILTER_PROFILE_T **notify_profile;for(notify_profile = &root_notify_filter_profile;     *notify_profile;     notify_profile = &(*notify_profile)->next)    if (*notify_profile == in_notify_profile) {        *notify_profile = in_notify_profile->next;	EBufferClean(&(in_notify_profile)->params_name);	in_notify_profile->next = 0;	return;        }return;}/********************************************************************************* SNMP_Notify_Profile_Name - extract the indices for a notify filter profile entry* SYNOPSIS** \cs* void SNMP_Notify_Profile_Name *     (*     SNMP_NOTIFY_FILTER_PROFILE_T *  notify_profile,*     bits8_t                      *  params_name,*     ALENGTH_T                    *  params_name_len*     )* \ce** DESCRIPTION** This routine extracts the indexing information for the specified notify * filter profile entry. After this routine completes, check the values in the * <params_name> and <params_name_len> fields.** Parameters:* \is* \i <*notify_profile>* Specify the notify filter profile entry.* \i <*params_name>* Specify the name of the parameter from the <snmpTargetParamsTable>. If the * <params_name> argument is long enough to hold the profile name, the name is * copied and returned.* \i <*params_name_len>* Specify the length in bytes of the parameter name. On input, this contains * the length of the <params_name> buffer. On output, it contains the length of * <params_name>.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Profile_Create(), SNMP_Notify_Profile_Deinstall(), * SNMP_Notify_Profile_Destroy(), SNMP_Notify_Profile_Install(), * SNMP_Notify_Profile_Lookup(), SNMP_Notify_Profile_Next_Profile(), SNMP Notify * Filter Profile Table Field Routines*/void  SNMP_Notify_Profile_Name(SNMP_NOTIFY_FILTER_PROFILE_T *notify_profile,			   bits8_t                      *params_name,			   ALENGTH_T                    *params_name_len){if (EBufferUsed(&(notify_profile->params_name)) &&     (*params_name_len >= EBufferUsed(&(notify_profile->params_name)))) {    MEMCPY(params_name, 	   EBufferStart(&(notify_profile->params_name)), 	   EBufferUsed(&(notify_profile->params_name)));    }*params_name_len = EBufferUsed(&(notify_profile->params_name));return;}/****************************************************************************\NOMANUALNAME:    notify filter listPURPOSE: This is the list of notify_filter objects that we know about.         It is ordered by notify filter profile name (from the         snmpNotifyFilterProfileTable) and the notify filter subtree,         the same as the indexing for the mib.****************************************************************************//****************************************************************************NAME: notify_filter_find_beforePURPOSE: Search through the list until we find the notify_filter         structure we are looking for.  We return a pointer to the         pointer that would point to the requested notify_filter if it         were to exist.  The calling routine is responsible for         determining if the requested notify_filter exists.  This         construction allows us to reuse this code for all of the find         routines (lookup and install).	 We have two length fields for use with get-nexts or bulks.	 Because there is an explicit length field we must handle	 the cases where the requested objectid has a length field	 that doesn't match the number of bytes available for the name.PARAMETERS: bits8_t   * pointer to name buffer	    ALENGTH_T   number of bytes in name	    ALENGTH_T   length of requested name from object id	    OBJ_ID_T  * pointer to subtreeRETURNS: SNMP_NOTIFY_FILTER_T ** pointer to pointer that would point		                 to the notify_filter if it were to		                 exist.****************************************************************************/static SNMP_NOTIFY_FILTER_T **  notify_filter_find_before(bits8_t   *profile_name,			    ALENGTH_T  profile_name_len,			    ALENGTH_T  req_len,			    OBJ_ID_T  *subtree){SNMP_NOTIFY_FILTER_T **notify_filter;int                    compare = 0;for(notify_filter = &root_notify_filter;     *notify_filter;     notify_filter = &(*notify_filter)->next) {    if (EBufferUsed(&((*notify_filter)->profile_name)) >= req_len)      break;    }for (; *notify_filter; notify_filter = &(*notify_filter)->next) {    compare = MEMCMP(EBufferStart(&((*notify_filter)->profile_name)),		     profile_name, profile_name_len);    if ((EBufferUsed(&((*notify_filter)->profile_name)) != req_len) ||	(compare >= 0))        break;    }if (compare > 0)    return(notify_filter);for (; *notify_filter; notify_filter = &(*notify_filter)->next) {    compare = MEMCMP(EBufferStart(&((*notify_filter)->profile_name)),		     profile_name, profile_name_len);    if ((EBufferUsed(&((*notify_filter)->profile_name)) != req_len) ||	(compare > 0))        break;    if ((compare = oidcmp2((*notify_filter)->subtree.num_components,                            (*notify_filter)->subtree.component_list,                            subtree->num_components,                            subtree->component_list)) >= 0)        break;    }return(notify_filter);}/********************************************************************************* SNMP_Notify_Filter_Lookup - find a notify filter entry matching the specified indices* SYNOPSIS** \cs* SNMP_NOTIFY_FILTER_T * SNMP_Notify_Filter_Lookup *     (*     bits8_t   *  profile_name,*     ALENGTH_T    profile_name_len,*     OBJ_ID_T  *  subtree*     )* \ce** DESCRIPTION** This routine finds a notify filter entry matching the specified indices.** Parameters:* \is* \i <*profile_name>* Specify the name of the profile to filter, which corresponds to the MIB * object <snmpNotifyFilterProfileName>.* \i <*profile_name_len>* Specify the length in bytes of the profile name.* \i <*subtree>* Specify the subtree, which corresponds to the MIB object * <snmpNotifyFilterSubtree>.* \ie** RETURNS: If successful, this routine returns a pointer to the entry. * Otherwise, it returns 0.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Filter_Create(), SNMP_Notify_Filter_Deinstall(), * SNMP_Notify_Filter_Destroy(), SNMP_Notify_Filter_Install(), * SNMP_Notify_Filter_Name(), SNMP_Notify_Filter_Next_Filter(), SNMP Notify * Filter Table Field Routines*/SNMP_NOTIFY_FILTER_T *  SNMP_Notify_Filter_Lookup(bits8_t   *profile_name,			    ALENGTH_T  profile_name_len,			    OBJ_ID_T  *subtree){SNMP_NOTIFY_FILTER_T **notify_filter;notify_filter = notify_filter_find_before(profile_name, 					  profile_name_len, 					  profile_name_len,					  subtree);if (*notify_filter &&     (profile_name_len == EBufferUsed(&((*notify_filter)->profile_name))) &&    (subtree->num_components == (*notify_filter)->subtree.num_components) &&    (MEMCMP(EBufferStart(&((*notify_filter)->profile_name)), 	    profile_name,	    profile_name_len) == 0) &&    (MEMCMP((*notify_filter)->subtree.component_list, 	    subtree->component_list,	    (subtree->num_components * sizeof(OIDC_T))) == 0))    return(*notify_filter);return(0);}/****************************************************************************\NOMANUALNAME: SNMP_Notify_Filter_NextPURPOSE: Find the next notify_filter after the named one.	the indexing information is of the form:	<length of profile_name> 	<profile_name>        <subtree>	but as this is a next we might not have all of it...PARAMETERS: 	 int	 tcount number of subids	 OIDC_T *tlist  list of subids	 RETURNS: SNMP_NOTIFY_FILTER_T * pointer to notify_filter or 0 if                                none found****************************************************************************/SNMP_NOTIFY_FILTER_T *  SNMP_Notify_Filter_Next(int     tcount,			  OIDC_T *tlist){SNMP_NOTIFY_FILTER_T *notify_filter;bits8_t *profile_name;OIDC_T req_len = 0, min_name_len = 0, *temp_oid, len;OIDC_T *subtree, min_subtree_len;if (tcount == 0)    return(root_notify_filter);req_len = *tlist++;tcount--;min_name_len = min(req_len, (OIDC_T)tcount);

⌨️ 快捷键说明

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