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

📄 v3mt_nfy.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
        }    if ((pf_chg == 0) &&	(SNMP_Notify_Profile_Get_Storage(profile) ==	 SNMP_Notify_Profile_Get_Storage(&tempprofile)) &&	(SNMP_Notify_Profile_Get_Status(profile) ==	 SNMP_Notify_Profile_Get_Status(&tempprofile))) {        setproc_all_bits(pktp, vbp);	return;        }    }else     pf_chg = 1;/* Because of how we do the backout stuff we always allocate a new   notify_filter_profile and set it up */newprofile = SNMP_Notify_Profile_Create();if (newprofile == 0) {    testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);    return;    }SNMP_Notify_Profile_Set_Flags(newprofile, 			      SNMP_Notify_Profile_Get_Flags(&tempprofile));SNMP_Notify_Profile_Set_Status(newprofile, 			       SNMP_Notify_Profile_Get_Status(&tempprofile));SNMP_Notify_Profile_Set_Storage(newprofile, 				SNMP_Notify_Profile_Get_Storage(&tempprofile));if (pf_chg) {    if (EBufferClone(&tempprofile.profile_name, 		     &newprofile->profile_name) != 0) {        SNMP_Notify_Profile_Destroy(newprofile);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;        }    }else{    EBufferPreLoad(BFL_IS_STATIC, &newprofile->profile_name,		   SNMP_Notify_Profile_Get_Profile(profile),		   SNMP_Notify_Profile_Get_Profile_Len(profile));    }/* if we are creating a new target_addr we need to install it and run   the create test, if we are updating an old target_addr we just run   the update test */if (profile == 0) {    if (SNMP_Notify_Profile_Install(newprofile, name, name_len)) {	SNMP_Notify_Profile_Destroy(newprofile);	testproc_error(pktp, vbp, RESOURCE_UNAVAILABLE);	return;	}    ptret = SNMP_V3_NPROF_CREATE_TEST(pktp, vbp, 0, newprofile);    if (ptret != NO_ERROR) {        SNMP_Notify_Profile_Deinstall(newprofile);	SNMP_Notify_Profile_Destroy(newprofile);	testproc_error(pktp, vbp, ptret);	return;        }    vbp->vb_free_priv = nproftable_create_cleanup;    }else {    ptret = SNMP_V3_NPROF_UPDATE_TEST(pktp, vbp, profile, newprofile);    if (ptret != NO_ERROR) {	SNMP_Notify_Profile_Destroy(newprofile);	testproc_error(pktp, vbp, ptret);	return;	}    newprofile->next = profile;    vbp->vb_free_priv = nproftable_update_cleanup;    }if (cago)    SNMP_Notify_Profile_Set_Status(newprofile, ETC_RS_CAGO);vbp->vb_priv = (PTR_T)newprofile;return;}void  snmpNotifyFilterProfileEntry_set(OIDC_T      lastmatch,                                   int         tcount,                                   OIDC_T     *tlist,                                   SNMP_PKT_T *pktp,                                   VB_T       *vbp){SNMP_NOTIFY_FILTER_PROFILE_T *old_profile, *new_profile;bits16_t temp_value;EBUFFER_T temp_ebuf;new_profile = (SNMP_NOTIFY_FILTER_PROFILE_T *)vbp->vb_priv;if (vbp->vb_free_priv == nproftable_destroy_cleanup) {    SNMP_V3_NPROF_DESTROY_SET(pktp, vbp, new_profile, 0);    SNMP_Notify_Profile_Deinstall(new_profile);    vbp->vb_free_priv = nproftable_set_cleanup;    undoproc_set(pktp, vbp, nproftable_destroy_undo);    }else if (vbp->vb_free_priv == nproftable_create_cleanup) {    if (SNMP_Notify_Profile_Get_Status(new_profile) == ETC_RS_CAGO)        SNMP_Notify_Profile_Set_Status(new_profile, ETC_RS_ACTIVE);    SNMP_V3_NPROF_CREATE_SET(pktp, vbp, 0, new_profile);    undoproc_set(pktp, vbp, nproftable_create_undo);    }else {    old_profile = new_profile->next;    SNMP_V3_NPROF_UPDATE_SET(pktp, vbp, old_profile, new_profile);    /* deal with status, storage and prefix information */    temp_value = SNMP_Notify_Profile_Get_Flags(old_profile);    SNMP_Notify_Profile_Set_Flags(old_profile, 				  SNMP_Notify_Profile_Get_Flags(new_profile));    SNMP_Notify_Profile_Set_Flags(new_profile, temp_value);    temp_value = SNMP_Notify_Profile_Get_Status(old_profile);    SNMP_Notify_Profile_Set_Status(old_profile, 				   SNMP_Notify_Profile_Get_Status(new_profile));    SNMP_Notify_Profile_Set_Status(new_profile, temp_value);    temp_value = SNMP_Notify_Profile_Get_Storage(old_profile);    SNMP_Notify_Profile_Set_Storage(old_profile, 				    SNMP_Notify_Profile_Get_Storage(new_profile));    SNMP_Notify_Profile_Set_Storage(new_profile, temp_value);    if (SNMP_Notify_Profile_Get_Profile(new_profile) !=	SNMP_Notify_Profile_Get_Profile(old_profile)) {        MEMCPY(&temp_ebuf, &old_profile->profile_name, sizeof(EBUFFER_T));	MEMCPY(&old_profile->profile_name, &new_profile->profile_name, 	       sizeof(EBUFFER_T));	MEMCPY(&new_profile->profile_name, &temp_ebuf, sizeof(EBUFFER_T));        }    undoproc_set(pktp, vbp, nproftable_update_undo);    }vbp->vb_free_priv = nproftable_set_cleanup;setproc_good(pktp, vbp);return;}/* * Method routines for the snmpNotifyFilterTable: * *   snmpNotifyFilterSubtree -- not-accessible * The MIB subtree which, when combined with the corresponding * instance of snmpNotifyFilterMask, defines a family of * subtrees which are included in or excluded from the * filter profile. * *   snmpNotifyFilterMask -- read-create * The bit mask which, in combination with the corresponding * instance of snmpNotifyFilterSubtree, defines a family of * subtrees which are included in or excluded from the * filter profile. *  * Each bit of this bit mask corresponds to a * sub-identifier of snmpNotifyFilterSubtree, with the * most significant bit of the i-th octet of this octet * string value (extended if necessary, see below) * corresponding to the (8*i - 7)-th sub-identifier, and * the least significant bit of the i-th octet of this * octet string corresponding to the (8*i)-th * sub-identifier, where i is in the range 1 through 16. *  * Each bit of this bit mask specifies whether or not * the corresponding sub-identifiers must match when * determining if an OBJECT IDENTIFIER matches this * family of filter subtrees; a '1' indicates that an * exact match must occur; a '0' indicates 'wild card', * i.e., any sub-identifier value matches. *  * Thus, the OBJECT IDENTIFIER X of an object instance * is contained in a family of filter subtrees if, for * each sub-identifier of the value of * snmpNotifyFilterSubtree, either: *  *   the i-th bit of snmpNotifyFilterMask is 0, or *  *   the i-th sub-identifier of X is equal to the i-th *   sub-identifier of the value of *   snmpNotifyFilterSubtree. *  * If the value of this bit mask is M bits long and * there are more than M sub-identifiers in the * corresponding instance of snmpNotifyFilterSubtree, * then the bit mask is extended with 1's to be the * required length. *  * Note that when the value of this object is the * zero-length string, this extension rule results in * a mask of all-1's being used (i.e., no 'wild card'), * and the family of filter subtrees is the one * subtree uniquely identified by the corresponding * instance of snmpNotifyFilterSubtree. * *   snmpNotifyFilterType -- read-create * This object indicates whether the family of filter subtrees * defined by this entry are included in or excluded from a * filter.  A more detailed discussion of the use of this * object can be found in section 6. of [RFC2573]. * *   snmpNotifyFilterStorageType -- read-create * The storage type of this conceptual row. * *   snmpNotifyFilterRowStatus -- read-create * The status of this conceptual row. *  * To create a row in this table, a manager must * set this object to either createAndGo(4) or * createAndWait(5). *//* An internal routine to retrieve the values of the variables, used * by the method routines snmpNotifyFilterEntry_get and * snmpNotifyFilterEntry_next.   */static int  snmpNotifyFilterEntry_get_value(OIDC_T                lastmatch,                                  SNMP_PKT_T           *pktp,                                  VB_T                 *vbp,				  SNMP_NOTIFY_FILTER_T *filter){  switch(lastmatch) {  case LEAF_snmpNotifyFilterMask:    getproc_got_string(pktp, vbp, 		       SNMP_Notify_Filter_Get_Mask_Len(filter),		       SNMP_Notify_Filter_Get_Mask(filter),		       0, VT_STRING);    break;  case LEAF_snmpNotifyFilterType:    /* Values:     *  included(1) = VAL_snmpNotifyFilterType_included     *  excluded(2) = VAL_snmpNotifyFilterType_excluded     */    getproc_got_int32(pktp, vbp, SNMP_Notify_Filter_Get_Type(filter));    break;  case LEAF_snmpNotifyFilterStorageType:    /* Values:     *  other(1)       = VAL_snmpNotifyFilterStorageType_other     *  volatile(2)    = VAL_snmpNotifyFilterStorageType_volatile     *  nonVolatile(3) = VAL_snmpNotifyFilterStorageType_nonVolatile     *  permanent(4)   = VAL_snmpNotifyFilterStorageType_permanent     *  readOnly(5)    = VAL_snmpNotifyFilterStorageType_readOnly     */    getproc_got_int32(pktp, vbp, SNMP_Notify_Filter_Get_Storage(filter));      break;  case LEAF_snmpNotifyFilterRowStatus:    /* Values:     *  active(1)        = VAL_snmpNotifyFilterRowStatus_active     *  notInService(2)  = VAL_snmpNotifyFilterRowStatus_notInService     *  notReady(3)      = VAL_snmpNotifyFilterRowStatus_notReady     *  createAndGo(4)   = VAL_snmpNotifyFilterRowStatus_createAndGo     *  createAndWait(5) = VAL_snmpNotifyFilterRowStatus_createAndWait     *  destroy(6)       = VAL_snmpNotifyFilterRowStatus_destroy     */    getproc_got_int32(pktp, vbp, SNMP_Notify_Filter_Get_Status(filter));      break;  default:    return GEN_ERR;  }  return NO_ERROR;}void  snmpNotifyFilterEntry_get(OIDC_T      lastmatch,                            int         tcount,                            OIDC_T     *tlist,                            SNMP_PKT_T *pktp,                            VB_T       *vbp){SNMP_NOTIFY_FILTER_T *filter = 0;bits8_t name[ETC_NOTIFY_FILTER_PROFILE_MAX];ALENGTH_T name_len = ETC_NOTIFY_FILTER_PROFILE_MAX;OBJ_ID_T subtree;int error;/* find all the varbinds that share the same getproc and instance */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);/* gather the indexing information, the index will be of the form:   <len> <profile_name> <subtree>   first we do some minor checks then we attempt to find the notify_filter */if ((tcount > 3) && (tlist[0] != 0) &&    (oid_to_string(tcount, tlist, &name_len, name, 0) == 0) &&    ((bits32_t)(name_len + 1) < (bits32_t)tcount)) {    subtree.num_components = tcount - (name_len + 1);    subtree.component_list = &(tlist[name_len + 1]);    filter = SNMP_Notify_Filter_Lookup(name, name_len, &subtree);    }if (filter == 0) {    for ( ; vbp ; vbp = vbp->vb_link)        getproc_nosuchins(pktp, vbp);    }else {    /* retrieve all the values from the same data structure */    for ( ; vbp ; vbp = vbp->vb_link ) {        if ((error = snmpNotifyFilterEntry_get_value(vbp->vb_ml.ml_last_match,						     pktp, vbp, 						     filter)) != NO_ERROR)            getproc_error(pktp, vbp, error);        }    }}void  snmpNotifyFilterEntry_next(OIDC_T      lastmatch,                             int         tcount,                             OIDC_T     *tlist,                             SNMP_PKT_T *pktp,                             VB_T       *vbp){SNMP_NOTIFY_FILTER_T *filter = 0;bits8_t name[ETC_NOTIFY_FILTER_PROFILE_MAX];ALENGTH_T namelen = 0;int error, rcount, stlen = 0;OIDC_T *st = 0;OIDC_T *rlist;/* group the vbs that are touching the given entry */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);filter = SNMP_Notify_Filter_Next(tcount, tlist);/* install the right info into the vbps */if (filter == 0)    for(; vbp; vbp = vbp->vb_link)        nextproc_no_next(pktp,vbp);else {    /* determine and insert instance information */    namelen = ETC_NOTIFY_FILTER_PROFILE_MAX;    SNMP_Notify_Filter_Name(filter, name, &namelen, &st, &stlen);    rcount = stlen + namelen + 1;    rlist = SNMP_memory_alloc((unsigned int)(rcount * sizeof(OIDC_T)));    if (rlist == 0)        nextproc_error(pktp, vbp, GEN_ERR);    else {        /* build the instance info */        (void) string_to_oid(namelen, name, (int)(namelen + 1), rlist, 0);	MEMCPY(rlist + namelen + 1, st, (stlen * sizeof(OIDC_T)));	for(; vbp; vbp = vbp->vb_link) {	    if ((error = 		 snmpNotifyFilterEntry_get_value(vbp->vb_ml.ml_last_match,						 pktp, vbp, 						 filter)) == NO_ERROR)	        nextproc_next_instance(pktp, vbp, rcount, rlist);	    else	        nextproc_error(pktp, vbp, error);	    }				       	SNMP_memory_free(rlist);        }    }return;}/****************************************************************************NAME: nfilttable_destroy_cleanupPURPOSE: Cleanup after a notify_filter test (delete) succeeded but         some other test failed.  We merely call the DESTROY_BACKOUT         macro to allow the customer to restore any changed state.         Expects the pointer to point to a VB_TPARAMETERS: 	ptr_t A pointer to the vb that points to the notify_filter              that we were going to delete, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void   nfilttable_destroy_cleanup(ptr_t filterptr){SNMP_V3_NFILT_DESTROY_BACKOUT(((VB_T *)filterptr)->vb_priv, 0);}/****************************************************************************NAME: nfilttable_create_cleanupPURPOSE: Cleanup after a notify_filter create test succeeded but some         other test failed.  As this is a create the state pointer         points to a structure that is installed, we need to deinstall         it, call the backout routine, and cleanup the state.	 Expects the pointer to point to a VB_TPARAMETERS: 	ptr_t A pointer to the vb that points to the notify_filter              that we were going to create, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void  nfilttable_create_cleanup(ptr_t filterptr){SNMP_NOTIFY_FILTER_T *filter;filter = (SNMP_NOTIFY_FILTER_T *)(((VB_T *)filterptr)->vb_priv);SNMP_V3_NFILT_CREATE_BACKOUT(0, filter);SNMP_N

⌨️ 快捷键说明

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