📄 v3_ntfy.c
字号:
/* Scan through all objects with shorter params name fields */for (notify_filter = root_notify_filter; notify_filter && (EBufferUsed(&(notify_filter)->profile_name) < req_len); notify_filter = notify_filter->next) ; /* no body for for loop *//* Check to see if the profile name matches. */ for (; notify_filter; notify_filter = notify_filter->next) { if (EBufferUsed(&(notify_filter)->profile_name) > req_len) return(notify_filter); profile_name = EBufferStart(&(notify_filter)->profile_name); temp_oid = tlist; for (len = min_name_len; len && (*profile_name == *temp_oid); len--, profile_name++, temp_oid++) ; /* no body for for loop */ if (len) { if (*profile_name > *temp_oid) return(notify_filter); } else { if (req_len != min_name_len) return(notify_filter); /* params name matches exactly. Let's check subtree. */ min_subtree_len = min((tcount - min_name_len), notify_filter->subtree.num_components); subtree = notify_filter->subtree.component_list; for (len = min_subtree_len; len && (*subtree == *temp_oid); len--, subtree++, temp_oid++) ; /* no body for for loop */ if (len) { if (*subtree > *temp_oid) return(notify_filter); } else { if (min_subtree_len != notify_filter->subtree.num_components) return(notify_filter); } } }return(0);}/********************************************************************************* SNMP_Notify_Filter_Next_Filter - find the next notify filter entry in the notify filter table* SYNOPSIS** \cs* SNMP_NOTIFY_FILTER_T * SNMP_Notify_Filter_Next_Filter * (* SNMP_NOTIFY_FILTER_T * notify_filter* )* \ce** DESCRIPTION** This routine finds the <notify filter> entry in the <notify filter> table * after the specified <notify filter> entry. Use this routine to step through * the notify filter table to find all installed notify filters.** Parameters:* \is* \i <*notify_filter>* Point to the notify filter entry.* \ie** RETURNS: If successful, this routine returns a pointer to the <notify * filter>. If there is no successor or the specified <notify filter> is not * installed, it returns 0. If the <notify filter> is specified as 0, then it * returns a pointer to the first <notify filter> entry in the table.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Filter_Create(), SNMP_Notify_Filter_Deinstall(), * SNMP_Notify_Filter_Destroy(), SNMP_Notify_Filter_Install(), * SNMP_Notify_Filter_Lookup(), SNMP_Notify_Filter_Name(), SNMP Notify Filter * Table Field Routines*/SNMP_NOTIFY_FILTER_T * SNMP_Notify_Filter_Next_Filter (SNMP_NOTIFY_FILTER_T *notify_filter){if (notify_filter) return(notify_filter->next);return(root_notify_filter);}/********************************************************************************* SNMP_Notify_Filter_Destroy - destroy a notify filter entry and frees associated resources* SYNOPSIS** \cs* void SNMP_Notify_Filter_Destroy* (* SNMP_NOTIFY_FILTER_T * notify_filter * )* \ce** DESCRIPTION** This routine destroys the specified notify filter entry, frees the space for * the entry, and frees the space for any resources the entry might contain.** \&NOTE: If the specified notify filter entry has been installed, call * SNMP_Notify_Filter_Deinstall() before calling this routine.** Parameters:* \is* \i <*notify_filter>* Specify the notify filter entry to remove from the notify filter table.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Filter_Create(), SNMP_Notify_Filter_Deinstall(), * SNMP_Notify_Filter_Install(), SNMP_Notify_Filter_Lookup(), * SNMP_Notify_Filter_Name(), SNMP_Notify_Filter_Next_Filter(), SNMP Notify * Filter Table Field Routines*/void SNMP_Notify_Filter_Destroy(SNMP_NOTIFY_FILTER_T *notify_filter){EBufferClean(¬ify_filter->filter_mask);SNMP_memory_free_lt(notify_filter);}/********************************************************************************* SNMP_Notify_Filter_Create - create a notify filter structure* SYNOPSIS** \cs* SNMP_NOTIFY_FILTER_T * SNMP_Notify_Filter_Create* (* void * )* \ce** DESCRIPTION** This routine creates a notify filter structure ('snmpNotifyFilterTable'), * 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_Filter_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_Filter_Deinstall(), SNMP_Notify_Filter_Destroy(), * SNMP_Notify_Filter_Install(), SNMP_Notify_Filter_Lookup(), * SNMP_Notify_Filter_Name(), SNMP_Notify_Filter_Next_Filter(), SNMP Notify * Filter Table Field Routines*/SNMP_NOTIFY_FILTER_T * SNMP_Notify_Filter_Create(void){SNMP_NOTIFY_FILTER_T *notify_filter;notify_filter = (SNMP_NOTIFY_FILTER_T *) SNMP_memory_alloc_lt(sizeof(SNMP_NOTIFY_FILTER_T));if (notify_filter == 0) return(0);SNMP_Notify_Filter_Set_Defaults(notify_filter);return(notify_filter);}/********************************************************************************* SNMP_Notify_Filter_Install - install a notify filter entry in the notify filter table* SYNOPSIS** \cs* int SNMP_Notify_Filter_Install * (* SNMP_NOTIFY_FILTER_T * notify_filter,* bits8_t * profile_name,* ALENGTH_T profile_name_len,* OBJ_ID_T * subtree* )* \ce** DESCRIPTION** This routine installs the specified notify filter entry in the notify filter * table using <profile_name> and <subtree> as indices.** \&NOTE: Once a notify filter has been installed, you must call * SNMP_Notify_Filter_Deinstall() before calling SNMP_Notify_Filter_Destroy() to * remove it.** Parameters:* \is* \i <*notify_filter>* Point to the notify filter entry.* \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 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_Filter_Create(), SNMP_Notify_Filter_Deinstall(), * SNMP_Notify_Filter_Destroy(), SNMP_Notify_Filter_Lookup(), * SNMP_Notify_Filter_Name(), SNMP_Notify_Filter_Next_Filter(), SNMP Notify * Filter Table Field Routines*/int SNMP_Notify_Filter_Install(SNMP_NOTIFY_FILTER_T *in_notify_filter, bits8_t *profile_name, ALENGTH_T profile_name_len, OBJ_ID_T *subtree){SNMP_NOTIFY_FILTER_T **notify_filter;/* see if the naming information is reasonable */if ((profile_name_len == 0) || (profile_name_len > ETC_NOTIFY_FILTER_PROFILE_MAX) || (subtree->num_components < 2) || (subtree->component_list == 0)) return(-1);/* see if the notify_filter already exists */notify_filter = notify_filter_find_before(profile_name, profile_name_len, profile_name_len, subtree);if (*notify_filter && (EBufferUsed(&((*notify_filter)->profile_name)) == profile_name_len) && (MEMCMP(EBufferStart(&((*notify_filter)->profile_name)), profile_name, profile_name_len) == 0) && ((*notify_filter)->subtree.num_components == subtree->num_components) && (MEMCMP((*notify_filter)->subtree.component_list, subtree->component_list, (subtree->num_components * sizeof(OIDC_T))) == 0)) return(-1);/* allocate space for the name */EBufferAllocateLoad(BFL_IS_ALLOC, &(in_notify_filter->profile_name), profile_name, profile_name_len);if (EBufferUsed(&(in_notify_filter->profile_name)) == 0) return(-1);/* copy the subtree information into the subtree */if (build_object_id(subtree->num_components, subtree->component_list, &(in_notify_filter->subtree)) != 0) { EBufferClean(&(in_notify_filter->profile_name)); return(-1); }/* insert the notify into the list */in_notify_filter->next = *notify_filter;*notify_filter = in_notify_filter;return(0);}/********************************************************************************* SNMP_Notify_Filter_Deinstall - remove a notify filter entry from the notify filter table* SYNOPSIS** \cs* void SNMP_Notify_Filter_Deinstall* (* SNMP_NOTIFY_FILTER_T * notify_filter* ) * \ce** DESCRIPTION** This routine removes the specified notify filter entry from the notify filter * table and cleans up any resources that might have been used for indexing * purposes.** Parameters:* \is* \i <*notify_filter>* Specify the notify filter entry to remove from the notify filter table.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Filter_Create(), SNMP_Notify_Filter_Destroy(), * SNMP_Notify_Filter_Install(), SNMP_Notify_Filter_Lookup(), * SNMP_Notify_Filter_Name(), SNMP_Notify_Filter_Next_Filter(), SNMP Notify * Filter Table Field Routines*/void SNMP_Notify_Filter_Deinstall(SNMP_NOTIFY_FILTER_T *in_notify_filter){SNMP_NOTIFY_FILTER_T **notify_filter;for(notify_filter = &root_notify_filter; *notify_filter; notify_filter = &(*notify_filter)->next) if (*notify_filter == in_notify_filter) { *notify_filter = in_notify_filter->next; EBufferClean(&(in_notify_filter)->profile_name); Clean_Obj_ID(&(in_notify_filter->subtree)); in_notify_filter->next = 0; return; }return;}/********************************************************************************* SNMP_Notify_Filter_Name - extract the indexing information for a notify filter entry* SYNOPSIS** \cs* void SNMP_Notify_Filter_Name * (* SNMP_NOTIFY_FILTER_T * notify_filter,* bits8_t * profile_name,* ALENGTH_T * profile_name_len,* OIDC_T ** subtree,* int * subtree_len* )* \ce** DESCRIPTION** This routine extracts the indexing information for the specified notify * filter entry. After this routine completes, check the values in the * <profile_name> and <profile_name_len> fields.** Parameters:* \is* \i <*notify_filter>* Point to the notify filter entry.* \i <*profile_name>* Specify the name of the profile to filter, which corresponds to the MIB * object <snmpNotifyFilterProfileName>. If the buffer is large enough to hold * the <profile_name>, the name is copied and returned.* \i <profile_name_len>* Specify the length in bytes of the profile name. On input, this value is the * length of the <profile_name> buffer. On output, it is the length of the * <profile_ name>.* \i <**subtree>* Set the <subtree>, which corresponds to the MIB object * <snmpNotifyFilterSubtree>, to point to the OID of the subtree. It should not * be cleared.* \i <*subtree_len>* Specify the number of components in the subtree.* \ie** RETURNS: None.** ERRNO: N/A** SEE ALSO: SNMP_Notify_Filter_Create(), SNMP_Notify_Filter_Deinstall(), * SNMP_Notify_Filter_Destroy(), SNMP_Notify_Filter_Install(), * SNMP_Notify_Filter_Lookup(), SNMP_Notify_Filter_Next_Filter(), SNMP Notify * Filter Table Field Routines*/void SNMP_Notify_Filter_Name(SNMP_NOTIFY_FILTER_T *notify_filter, bits8_t *profile_name, ALENGTH_T *profile_name_len, OIDC_T **subtree, int *subtree_len){if (EBufferUsed(&(notify_filter->profile_name)) && (*profile_name_len >= EBufferUsed(&(notify_filter->profile_name)))) { MEMCPY(profile_name, EBufferStart(&(notify_filter->profile_name)), EBufferUsed(&(notify_filter->profile_name))); }*profile_name_len = EBufferUsed(&(notify_filter->profile_name));*subtree = notify_filter->subtree.component_list;*subtree_len = notify_filter->subtree.num_components;return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -